veracode

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VeryHigh BusinessCriticality = "VERY_HIGH"
	High     BusinessCriticality = "HIGH"
	Medium   BusinessCriticality = "MEDIUM"
	Low      BusinessCriticality = "LOW"
	VeryLow  BusinessCriticality = "VERY_LOW"

	Static  ScanType = "STATIC"
	Dynamic ScanType = "DYNAMIC"
	Manual  ScanType = "MANUAL"

	Passed          PolicyCompliance = "PASSED"
	ConditionalPass PolicyCompliance = "CONDITIONAL_PASS"
	DidNotPass      PolicyCompliance = "DID_NOT_PASS"
	NotAssessed     PolicyCompliance = "NOT_ASSESSED"
	VendorReview    PolicyCompliance = "VENDOR_REVIEW"
	Determining     PolicyCompliance = "DETERMINING"

	Created                           ScanStatus = "CREATED"
	Unpublished                       ScanStatus = "UNPUBLISHED"
	Deleted                           ScanStatus = "DELETED"
	PartialPublish                    ScanStatus = "PARTIAL_PUBLISH"
	PartialUnpublish                  ScanStatus = "PARTIAL_UNPUBLISH"
	Incomplete                        ScanStatus = "INCOMPLETE"
	ScanSubmitted                     ScanStatus = "SCAN_SUBMITTED"
	InQueue                           ScanStatus = "IN_QUEUE"
	Stopping                          ScanStatus = "STOPPING"
	Pausing                           ScanStatus = "PAUSING"
	InProgress                        ScanStatus = "IN_PROGRESS"
	AnalysisErrors                    ScanStatus = "ANALYSIS_ERRORS"
	ScanCanceled                      ScanStatus = "SCAN_CANCELED"
	InternalReview                    ScanStatus = "INTERNAL_REVIEW"
	VerifyingResults                  ScanStatus = "VERIFYING_RESULTS"
	SubmittedForNtoPreScan            ScanStatus = "SUBMITTED_FOR_NTO_PRE_SCAN"
	SubmittedForDynamicPreScan        ScanStatus = "SUBMITTED_FOR_DYNAMIC_PRE_SCAN"
	PreScanFailed                     ScanStatus = "PRE_SCAN_FAILED"
	ReadyToSubmit                     ScanStatus = "READY_TO_SUBMIT"
	NtoPendingSubmission              ScanStatus = "NTO_PENDING_SUBMISSION"
	PreScanComplete                   ScanStatus = "PRE_SCAN_COMPLETE"
	ModuleSelectionRequired           ScanStatus = "MODULE_SELECTION_REQUIRED"
	PendingVendorAcceptance           ScanStatus = "PENDING_VENDOR_ACCEPTANCE"
	ShowOsrdb                         ScanStatus = "SHOW_OSRDB"
	Published                         ScanStatus = "PUBLISHED"
	PublishedToVendor                 ScanStatus = "PUBLISHED_TO_VENDOR"
	PublishedToEnterprise             ScanStatus = "PUBLISHED_TO_ENTERPRISE"
	PendingAccountApproval            ScanStatus = "PENDING_ACCOUNT_APPROVAL"
	PendingLegalAgreement             ScanStatus = "PENDING_LEGAL_AGREEMENT"
	ScanInProgress                    ScanStatus = "SCAN_IN_PROGRESS"
	ScanInProgressPartialResultsReady ScanStatus = "SCAN_IN_PROGRESS_PARTIAL_RESULTS_READY"
	PromoteInProgress                 ScanStatus = "PROMOTE_IN_PROGRESS"
	PreScanCanceled                   ScanStatus = "PRE_SCAN_CANCELED"
	NtoPreScanCanceled                ScanStatus = "NTO_PRE_SCAN_CANCELED"
	ScanHeldApproval                  ScanStatus = "SCAN_HELD_APPROVAL"
	ScanHeldLoginInstructions         ScanStatus = "SCAN_HELD_LOGIN_INSTRUCTIONS"
	ScanHeldLogin                     ScanStatus = "SCAN_HELD_LOGIN"
	ScanHeldInstructions              ScanStatus = "SCAN_HELD_INSTRUCTIONS"
	ScanHeldHoldsFinished             ScanStatus = "SCAN_HELD_HOLDS_FINISHED"
	ScanRequested                     ScanStatus = "SCAN_REQUESTED"
	TimeFramePendingId                ScanStatus = "TIMEFRAMEPENDING_ID"
	PausedId                          ScanStatus = "PAUSED_ID"
	StaticValidatingUpload            ScanStatus = "STATIC_VALIDATING_UPLOAD"
	PublishedToEnterpriseInt          ScanStatus = "PUBLISHED_TO_ENTERPRISEINT"
)

Variables

View Source
var Regions = map[string]string{
	"e": "https://api.veracode.eu",
	"f": "https://api.veracode.us",
	"g": "https://api.veracode.com",
}

Functions

func GetCredentialsFilePath

func GetCredentialsFilePath() (string, error)

GetCredentialsFilePath gets the Veracode API credentials file path.

func GetProfiles

func GetProfiles(filePath string) (map[string]Profile, error)

GetProfiles returns all of the profiles stored in the Veracode credentials file.

func GetRegionFromCredentials added in v0.5.1

func GetRegionFromCredentials(apiKey string) (string, error)

func LoadVeracodeCredentials

func LoadVeracodeCredentials() (string, string, error)

LoadVeracodeCredentails will get the Veracode API key and secret for set profile from the credentials file. The profile name will be read from the VERACODE_API_PROFILE environmental variable. If the variable is not set, the profile with name "default" will be used. If there is only one profile with no name it will be used. The credentials file should be in the .ini format and should be present in the /.veracode/ folder in the user's home directory. Please refer to the documentation for more information: https://docs.veracode.com/r/c_httpie_tool.

func NewVeracodeError

func NewVeracodeError(resp *http.Response) error

NewVeracodeError unmarshals a response body into a new Veracode error.

func QueryEncode

func QueryEncode(options any) string

QueryEncode takes any object and encodes it to a query string, while replacing "+" with "%20".

The reason I added this function, was because the Veracode APIs does not support "+" to indicate spaces in the URL's query parameters. Example: `?name=foo+bar` will cause a 401 error.

Known bug:

if "+" is part of the query parameter name/value before encoding, it will also be replaced by "%20". I am doing it this way for simplicity, performance (the alternative is to loop through the url.Values map and replace specifically every space before encoding) and because I don't currently have a use case to pass any values that contain "+".

Types

type APICredentials added in v0.5.0

type APICredentials struct {
	ApiId          string   `json:"api_id"`
	ApiSecret      string   `json:"api_secret"`
	ExpirationTs   ctime    `json:"expiration_ts"`
	RevocationUser string   `json:"revocation_user"`
	RevocationTs   ctime    `json:"revocation_ts"`
	Links          NavLinks `json:"_links"`
}

type Application

type Application struct {
	Guid    string             `json:"guid,omitempty"`
	Profile ApplicationProfile `json:"profile,omitempty"`
	Scans   []ApplicationScan  `json:"scans,omitempty"`
}

func NewApplication

func NewApplication(name, policyGuid string, businessCriticality BusinessCriticality) Application

NewApplication creates an Application with all of the required fields.

type ApplicationBusinessOwner

type ApplicationBusinessOwner struct {
	Email string `json:"email,omitempty"`
	Name  string `json:"name,omitempty"`
}

type ApplicationBusinessUnit

type ApplicationBusinessUnit struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Guid string `json:"guid,omitempty"`
}

type ApplicationCustomField

type ApplicationCustomField struct {
	Name      string `json:"name,omitempty"`
	SortOrder int    `json:"sort_order,omitempty"`
}

type ApplicationPolicy

type ApplicationPolicy struct {
	Name                   string           `json:"name,omitempty"`
	Guid                   string           `json:"guid,omitempty"`
	IsDefault              bool             `json:"is_default,omitempty"`
	PolicyComplianceStatus PolicyCompliance `json:"policy_compliance_status,omitempty"`
}

type ApplicationProfile

type ApplicationProfile struct {
	Name           string                   `json:"name,omitempty"`
	Tags           string                   `json:"tags,omitempty"`
	BusinessUnit   *ApplicationBusinessUnit `json:"business_unit,omitempty"`
	BusinessOwners []struct {
		Email string `json:"email,omitempty"`
		Name  string `json:"name,omitempty"`
	} `json:"business_owners,omitempty"`
	ArcherAppName       string              `json:"archer_app_name,omitempty"`
	Policies            []ApplicationPolicy `json:"policies,omitempty"`
	Teams               []ApplicationTeam   `json:"teams,omitempty"`
	CustomFields        []CustomField       `json:"custom_fields,omitempty"`
	Description         string              `json:"description,omitempty"`
	BusinessCriticality BusinessCriticality `json:"business_criticality,omitempty"`
}

type ApplicationScan added in v0.6.0

type ApplicationScan struct {
	InternalStatus string     `json:"internal_status,omitempty"`
	ModifiedDate   time.Time  `json:"modified_date,omitempty"`
	ScanType       string     `json:"scan_type,omitempty"`
	ScanURL        string     `json:"scan_url,omitempty"`
	Status         ScanStatus `json:"status,omitempty"`
}

type ApplicationService

type ApplicationService service

You can use the Applications API to quickly access information about your Veracode applications. For more information, review the documentation: https://docs.veracode.com/r/c_apps_intro

Currently supports V1 of the Applications API

func (*ApplicationService) CreateApplication

func (a *ApplicationService) CreateApplication(ctx context.Context, application Application) (*Application, *Response, error)

CreateApplication creates a new application using the provided Application.

Veracode API documentation:

func (*ApplicationService) CreateCollection

func (c *ApplicationService) CreateCollection(ctx context.Context, collection Collection) (*Collection, *Response, error)

CreateCollection creates a new collection using the provided Collection.

func (*ApplicationService) DeleteApplication

func (a *ApplicationService) DeleteApplication(ctx context.Context, appId string) (*Response, error)

DeleteApplication deletes an application from the Veracode API using the provided appId.

Veracode API documentation:

func (*ApplicationService) DeleteCollection

func (a *ApplicationService) DeleteCollection(ctx context.Context, collectionGuid string) (*Response, error)

GetCollection deletes a collection with the provided collectionGuid.

func (*ApplicationService) GetApplication

func (a *ApplicationService) GetApplication(ctx context.Context, appId string) (*Application, *Response, error)

GetApplication retrieves an Application Profile with the provided appId.

Veracode API documentation: https://app.swaggerhub.com/apis/Veracode/veracode-applications_api_specification/1.0#/Application%20information%20API/getApplicationUsingGET

func (*ApplicationService) GetCollection

func (a *ApplicationService) GetCollection(ctx context.Context, collectionGuid string) (*Collection, *Response, error)

GetCollection retrieves a collection with the provided collectionGuid.

func (*ApplicationService) ListApplications

func (a *ApplicationService) ListApplications(ctx context.Context, options ListApplicationOptions) ([]Application, *Response, error)

ListApplications takes a ListApplicationOptions and returns a list of Applications.

Veracode API documentation: https://docs.veracode.com/r/r_applications_list

func (*ApplicationService) ListCollections

func (c *ApplicationService) ListCollections(ctx context.Context, options ListCollectionOptions) ([]Collection, *Response, error)

ListCollections returns []Collection using provided CollectionListOptions.

func (*ApplicationService) ListCustomFields

ListCustomFields returns a list of the custom fields for the Application Profiles.

func (*ApplicationService) UpdateApplication

func (a *ApplicationService) UpdateApplication(ctx context.Context, application Application) (*Application, *Response, error)

UpdateApplication updates the Application Profile provided. NOTE: When you update an application profile with this API, all properties are required.

Veracode API documentation:

func (*ApplicationService) UpdateCollection

func (c *ApplicationService) UpdateCollection(ctx context.Context, collection Collection) (*Collection, *Response, error)

UpdateCollection updates a collection with collectionId using provided collection.

type ApplicationTeam

type ApplicationTeam struct {
	Guid     string `json:"guid,omitempty"`
	TeamId   int    `json:"team_id,omitempty"`
	TeamName string `json:"team_name,omitempty"`
}

type BusinessCriticality

type BusinessCriticality string

type BusinessUnit

type BusinessUnit struct {
	BuId       string  `json:"bu_id,omitempty"`
	BuLegacyId int     `json:"bu_legacy_id,omitempty"`
	BuName     string  `json:"bu_name,omitempty"`
	IsDefault  *bool   `json:"is_default,omitempty"`
	Teams      *[]Team `json:"teams,omitempty"`
}

type Client

type Client struct {
	HttpClient *http.Client

	Identity    *IdentityService    // See type for documentation.
	Application *ApplicationService // See type for documentation.
	Sandbox     *SandboxService     // See type for documentation.
	Healthcheck *HealthCheckService // See type for documentation.
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, apiKey, apiSecret string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, body any) (*Response, error)

Do is a helper method that executes the provided http.Request and marshals the JSON response body into either the provided any object or into an error if an error occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, endpoint string, method string, body io.Reader) (*http.Request, error)

func (*Client) UpdateCredentials added in v0.5.0

func (c *Client) UpdateCredentials(apiKey, apiSecret string) error

UpdateCredentials is a method that allows the caller to update the credentials for the client after it has been initialized.

type Collection

type Collection struct {
	Assets       []CollectionAsset        `json:"asset_infos,omitempty"`
	BusinessUnit *ApplicationBusinessUnit `json:"business_unit,omitempty"`
	CustomFields []CustomField            `json:"custom_fields,omitempty"`
	Description  string                   `json:"description,omitempty"`
	Name         string                   `json:"name,omitempty"`
	Guid         string                   `json:"guid,omitempty"`
	Restricted   *bool                    `json:"restricted,omitempty"`
}

type CollectionAsset

type CollectionAsset struct {
	Type string `json:"type,omitempty"`
	Guid string `json:"guid,omitempty"`
}

type CollectionResult

type CollectionResult interface {
	GetLinks() NavLinks
	GetPageMeta() PageMeta
}

Any struct that is used to unmarshal a collection of entities, needs to implement the CollectionResult interface in order for the page meta and navigational links to be set in the Response object.

type CreateSandbox added in v0.6.0

type CreateSandbox struct {
	Name         string        `json:"name,omitempty"`
	AutoCreate   bool          `json:"auto_create,omitempty"` // If you are in the time-to-live mode, Automatically re-create the sandbox once the period expires. Documentation: https://docs.veracode.com/r/About_Sandbox_Data_Retention
	CustomFields []CustomField `json:"custom_fields,omitempty"`
}

CreateSandbox contains all of the fields required for creating and updating development sandboxes.

Only the Name field is required.

type CustomField

type CustomField struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

type Error

type Error struct {
	Code     int
	Endpoint string
	Messages []string
}

func (Error) Error

func (v Error) Error() string

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) (err error)

type HealthCheckService added in v0.6.0

type HealthCheckService service

You can use the Healthcheck API to perform a simple test for verifying authenticated connectivity to Veracode.

The Healthcheck API provides this lightweight endpoint: /healthcheck/status

You use the endpoint to verify that Veracode services are available and responding to authentication events, instead of using other API calls that can potentially return large volumes of data.

For more information: https://docs.veracode.com/r/c_healthcheck_intro

func (*HealthCheckService) GetStatus added in v0.6.0

func (h *HealthCheckService) GetStatus(ctx context.Context) (*Response, error)

GetStatus is a lightweight check that indicates whether the authentication services are operational.

If GetStatus does not return an error, then everything is operational.

Documentation: https://app.swaggerhub.com/apis/Veracode/veracode-healthcheck_api_specification/1.0#/Healthcheck%20APIs/get_healthcheck_status

type IdentityService

type IdentityService service

You can use the Identity Service to manage the administrative configuration for your organization that is in the Veracode Platform. For more information: https://docs.veracode.com/r/c_identity_intro.

Currently supports V2 of the Identity API

func (*IdentityService) CreateBusinessUnit

func (i *IdentityService) CreateBusinessUnit(ctx context.Context, bu *BusinessUnit) (*BusinessUnit, *Response, error)

CreateBusinessUnit creates a new bu using the provided BusinessUnit object.

Veracode API documentation:

func (*IdentityService) CreateTeam

func (i *IdentityService) CreateTeam(ctx context.Context, team *Team) (*Team, *Response, error)

CreateTeam creates a new team using the provided Team object.

Veracode API documentation:

func (*IdentityService) CreateUser

func (i *IdentityService) CreateUser(ctx context.Context, user *User, generateApiCredentials bool) (*User, *Response, error)

CreateUser creates a new user using the provided User object. Setting generateApiCredentials to true, will generate API credentials for the user on creation.

Veracode API documentation:

func (*IdentityService) DeleteBusinessUnit

func (i *IdentityService) DeleteBusinessUnit(ctx context.Context, buId string) (*Response, error)

DeleteBusinessUnit deletes a bu from the Veracode API using the provided buId.

Veracode API documentation:

func (*IdentityService) DeleteTeam

func (i *IdentityService) DeleteTeam(ctx context.Context, teamId string) (*Response, error)

DeleteTeam deletes a team from the Veracode API using the provided teamId.

Veracode API documentation:

func (*IdentityService) DeleteUser

func (i *IdentityService) DeleteUser(ctx context.Context, userId string) (*Response, error)

DeleteUser deletes a user using the provided userId. This applies to both a user account and an API service account.

Veracode API documentation:

func (*IdentityService) GenerateCredentialsByUserId added in v0.5.0

func (i *IdentityService) GenerateCredentialsByUserId(ctx context.Context, userId string) (APICredentials, *Response, error)

GenerateCredentialsByUserId generates new API credentials for the provided userId.

Veracode API documentation:

func (*IdentityService) GetBusinessUnit

func (i *IdentityService) GetBusinessUnit(ctx context.Context, buId string) (*BusinessUnit, *Response, error)

GetBusinessUnit returns the BusinessUnit with the provided buId.

Veracode API documentation:

func (*IdentityService) GetCredentialsByKey added in v0.5.0

func (i *IdentityService) GetCredentialsByKey(ctx context.Context, Apikey string) (APICredentials, *Response, error)

GetCredentialsByKey returns the API credentials for the provided API key.

Veracode API documentation:

func (*IdentityService) GetCredentialsByUserId added in v0.5.0

func (i *IdentityService) GetCredentialsByUserId(ctx context.Context, userId string) (APICredentials, *Response, error)

GetCredentialsByUserId returns the API credentials for the provided userId.

Veracode API documentation:

func (*IdentityService) GetTeam

func (i *IdentityService) GetTeam(ctx context.Context, teamId string) (*Team, *Response, error)

GetTeam returns a Team with the provided teamId. Setting detailed to true will include certain hidden fields.

Veracode API documentation:

func (*IdentityService) GetUser

func (i *IdentityService) GetUser(ctx context.Context, userId string, detailed bool) (*User, *Response, error)

GetUser returns user with provided userId. Setting detailed to true will include certain hidden fields.

func (*IdentityService) ListBusinessUnits

func (i *IdentityService) ListBusinessUnits(ctx context.Context, options ListBuOptions) ([]BusinessUnit, *Response, error)

ListBusinessUnits returns a list of business units. A name can optionally be provided to search for BUs by name.

Veracode API documentation:

func (*IdentityService) ListRoles

func (i *IdentityService) ListRoles(ctx context.Context, options PageOptions) ([]Role, *Response, error)

ListRoles takes a PageOptions and returns a list of roles.

Veracode API documentation: https://docs.veracode.com/r/Listing_All_Roles_in_an_Organization_with_the_Identity_API.

func (*IdentityService) ListTeams

func (i *IdentityService) ListTeams(ctx context.Context, options ListTeamOptions) ([]Team, *Response, error)

ListTeams takes a ListTeamsOptions and returns a list of teams.

Veracode API documentation:

func (*IdentityService) ListUsers

func (i *IdentityService) ListUsers(ctx context.Context, options ListUserOptions) ([]User, *Response, error)

ListUsers takes a ListUserOptions and returns a list of users.

Veracode API documentation: https://docs.veracode.com/r/c_identity_list_users.

func (*IdentityService) ListUsersNotInTeam added in v0.5.0

func (i *IdentityService) ListUsersNotInTeam(ctx context.Context, options NotInTeamOptions) ([]User, *Response, error)

SearchUsers takes a SearchUserOptions and returns a list of users.

Veracode API documentation: https://docs.veracode.com/r/c_identity_search_users.

func (*IdentityService) RevokeCredentialsByKey added in v0.5.0

func (i *IdentityService) RevokeCredentialsByKey(ctx context.Context, Apikey string) (*Response, error)

RevokeCredentialsByKey revokes the API credentials for the provided API key.

Veracode API documentation:

func (*IdentityService) RevokeCredentialsByUserId added in v0.5.0

func (i *IdentityService) RevokeCredentialsByUserId(ctx context.Context, userId string) (*Response, error)

RevokeCredentialsByUserId revokes the API credentials for the provided userId.

Veracode API documentation:

func (*IdentityService) SearchUsers

func (i *IdentityService) SearchUsers(ctx context.Context, options SearchUserOptions) ([]User, *Response, error)

SearchUsers takes a SearchUserOptions and returns a list of users.

Veracode API documentation: https://docs.veracode.com/r/c_identity_search_users.

func (*IdentityService) SelfGenerateCredentials added in v0.5.0

func (i *IdentityService) SelfGenerateCredentials(ctx context.Context) (APICredentials, *Response, error)

SelfGenerateCredentials generates a new API credentials for the current user.

Veracode API documentation:

func (*IdentityService) SelfGetCredentials added in v0.5.0

func (i *IdentityService) SelfGetCredentials(ctx context.Context) (APICredentials, *Response, error)

SelfGetCredentials returns the current user's API credentials.

Veracode API documentation:

func (*IdentityService) SelfGetUser added in v0.5.0

func (i *IdentityService) SelfGetUser(ctx context.Context, detailed bool) (*User, *Response, error)

Self returns the requesting user's details. Setting detailed to true will add certain hidden fields.

func (*IdentityService) SelfListTeams added in v0.5.0

func (i *IdentityService) SelfListTeams(ctx context.Context, options ListTeamOptions) ([]Team, *Response, error)

SelfListTeams returns a list of teams that the current user is a part of.

Veracode API documentation:

func (*IdentityService) SelfRevokeCredentials added in v0.5.0

func (i *IdentityService) SelfRevokeCredentials(ctx context.Context) (*Response, error)

SelfRevokeCredentials revokes the current user's API credentials.

Veracode API documentation:

func (*IdentityService) SelfUpdateUser added in v0.5.0

func (i *IdentityService) SelfUpdateUser(ctx context.Context, user *User, options UpdateOptions) (*User, *Response, error)

UpdateSelf updates the requesting user and sets nulls to fields not in the request (if the database allows it) unless partial is set to true. If incremental is set to true, any values in the roles or teams list will be added to the user's roles/teams instead of replacing them.

Veracode API documentation: https://docs.veracode.com/r/c_identity_update_user.

func (*IdentityService) UpdateBusinessUnit

func (i *IdentityService) UpdateBusinessUnit(ctx context.Context, bu *BusinessUnit, options UpdateOptions) (*BusinessUnit, *Response, error)

UpdateBusinessUnit updates a specific bu and sets nulls to fields not in the request (if the database allows it) unless partial is set to true. If incremental is set to true, any values in the teams list will be added to the bu's teams instead of replacing them.

Veracode API documentation:

func (*IdentityService) UpdateTeam

func (i *IdentityService) UpdateTeam(ctx context.Context, team *Team, options UpdateOptions) (*Team, *Response, error)

UpdateTeam updates a specific team and sets nulls to fields not in the request (if the database allows it) unless partial is set to true. If incremental is set to true, any values in the users list will be added to the teams's users instead of replacing them.

Veracode API documentation: https://docs.veracode.com/r/c_identity_update_team

func (*IdentityService) UpdateUser

func (i *IdentityService) UpdateUser(ctx context.Context, user *User, options UpdateOptions) (*User, *Response, error)

UpdateUser updates a specific user and sets nulls to fields not in the request (if the database allows it) unless partial is set to true. If incremental is set to true, any values in the roles or teams list will be added to the user's roles/teams instead of replacing them.

Veracode API documentation: https://docs.veracode.com/r/c_identity_update_user.

type ListApplicationOptions

type ListApplicationOptions struct {
	Page                  int              `url:"page,omitempty"`
	Size                  int              `url:"size,omitempty"`
	Name                  string           `url:"name,omitempty"`                      // Filter Applications by Name (Not an exact match). Documentation Reference: https://docs.veracode.com/r/List_Applications_By_Name
	Tag                   string           `url:"tag,omitempty"`                       // Documentation Reference: https://docs.veracode.com/r/r_applications_any_tag and https://docs.veracode.com/r/r_applications_tag
	Team                  string           `url:"team,omitempty"`                      // Filter the Applications by team name.
	LegacyId              int              `url:"legacy_id,omitempty"`                 // Documentation Reference: https://docs.veracode.com/r/r_applications_info
	ScanType              ScanType         `url:"scan_type,omitempty"`                 // The valid scan_type values are STATIC, DYNAMIC and, for Manual Penetration Testing (MPT), MANUAL. Documentation Reference: https://docs.veracode.com/r/r_applications_scan_type
	ScanStatus            []ScanStatus     `url:"scan_status,omitempty"`               // Filter Applications by a list of scan statuses.
	BusinessUnit          string           `url:"business_unit,omitempty"`             // Return a list of Application Profiles that belong to the BU with this name. Documentation Reference: https://docs.veracode.com/r/r_applications_bu
	PolicyGuid            string           `url:"policy_guid,omitempty"`               // Filter Applications by the Policy that is assigned to them.
	PolicyCompliance      PolicyCompliance `url:"policy_compliance,omitempty"`         // Documentation Reference: https://docs.veracode.com/r/r_applications_compliance
	SortByCustomFieldName string           `url:"sort_by_custom_field_name,omitempty"` // Custom field name on which to sort.

	// You can use the Applications REST API to list the application profiles that have had an event that triggered a policy evaluation after a specific date.
	// The events that trigger policy evaluations are scans, approved mitigations, new component vulnerability releases, and policy changes.
	//
	// The value needs to be in format: 2006-01-02.
	//
	// Documentation Reference: https://docs.veracode.com/r/Listing_Applications_by_Last_Policy_Evaluation_Date_with_the_Applications_API
	PolicyComplianceCheckedAfter string `url:"policy_compliance_checked_after,omitempty"`

	// Send the following request to return the list of application profiles modified after a specific date.
	//
	// The value needs to be in format: 2006-01-02.
	//
	// Documentation Reference: https://docs.veracode.com/r/r_applications_modified_date
	ModifiedAfter string `url:"modified_after,omitempty"`

	// CustomFieldNames and CustomFieldValues need to both be set together.
	// You can use the AddCustomFieldOption method to set/update these fields.
	CustomFieldNames  []string `url:"custom_field_names,omitempty"`
	CustomFieldValues []string `url:"custom_field_values,omitempty"`
}

ListApplicationOptions contains all of the fields that can be passed as query values when calling the ListApplications method. NOTE: the policy field is not currently included.

func (*ListApplicationOptions) AddCustomFieldOption

func (l *ListApplicationOptions) AddCustomFieldOption(customFieldName, customFieldValue string)

AddCustomFieldOption sets the customFieldName and customFieldValue attributes on the ListApplicationOptions. To identify application profiles with any value for a specific custom field, enter the URL-encoded wildcard value %25 for customFieldValue.

Documentation Reference: https://docs.veracode.com/r/r_applications_custom_field

type ListBuOptions added in v0.5.0

type ListBuOptions struct {
	SearchTerm  string `url:"search_term,omitempty"` // You can search for partial strings of the name.
	PageOptions        // can only sort by buName
}

type ListCollectionOptions

type ListCollectionOptions struct {
	Page         int    `url:"page,omitempty"`
	Size         int    `url:"size,omitempty"`
	Name         string `url:"name,omitempty"`          // Filter collections by name (partial match)
	BusinessUnit string `url:"business_unit,omitempty"` // Filter collections by business unit name (partial match)
	Tag          string `url:"tag,omitempty"`           // Filter by tags
	// CustomFieldNames and CustomFieldValues need to both be set together.
	// You can use the AddCustomFieldOption method to set/update these fields.
	CustomFieldNames  []string `url:"custom_field_names,omitempty"`
	CustomFieldValues []string `url:"custom_field_values,omitempty"`
}

func (*ListCollectionOptions) AddCustomFieldOption

func (l *ListCollectionOptions) AddCustomFieldOption(customFieldName, customFieldValue string)

AddCustomFieldOption sets the customFieldName and customFieldValue attributes on the ListApplicationOptions. To identify application profiles with any value for a specific custom field, enter the URL-encoded wildcard value %25 for customFieldValue.

Documentation Reference: https://docs.veracode.com/r/r_applications_custom_field

type ListCustomFieldOptions

type ListCustomFieldOptions struct {
	Page int `url:"page"`
	Size int `url:"size,omitempty"`
}

type ListTeamOptions

type ListTeamOptions struct {
	AllForOrg       *bool  `url:"all_for_org,omitempty"`
	TeamName        string `url:"team_name,omitempty"`
	IgnoreSelfTeams *bool  `url:"ignore_self_teams,omitempty"` // If true, return all teams in the organization. If false, return the teams the current user is a part of.
	OnlyManageable  bool   `url:"only_manageable,omitempty"`   // Only return teams manageable by the requesting user.
	Deleted         bool   `url:"deleted,omitempty"`           // Returns deleted teams.
	PageOptions            // can sort team_name field
}

ListTeamOptions contains all of the fields that can be passed as query values.

type ListUserOptions

type ListUserOptions struct {
	Detailed     string   `url:"detailed,omitempty"`              // Passing detailed will return additional hidden fields. Value should be one of: Yes or No
	UserName     string   `url:"user_name,omitempty"`             // Filter by username. You must specify the full username. The request does not support matching partial usernames.
	EmailAddress []string `url:"email_address,omitempty" del:","` // Filter by email address(es).
	PageOptions
}
type NavLinks struct {
	First link `json:"first"`
	Last  link `json:"last"`
	Next  link `json:"next"`
	Prev  link `json:"prev"`
	Self  link `json:"self"`
}

Container of navigation links.

type NotInTeamOptions added in v0.5.0

type NotInTeamOptions struct {
	SearchTerm string `url:"search_term,omitempty"` // You can search for partial strings of the username, first name, last name, or email address.
	TeamId     string `url:"team_id,omitempty"`
	PageOptions
}

type PageMeta added in v0.6.0

type PageMeta struct {
	Number        int `json:"number"`
	Size          int `json:"size"`
	TotalElements int `json:"total_elements"`
	TotalPages    int `json:"total_pages"`
}

PageMeta contains the meta data for the current API page.

type PageOptions

type PageOptions struct {
	Size int              `url:"size,omitempty"` // Increase the page size.
	Page int              `url:"page"`           // Page through the list.
	Sort []SortQueryField `url:"sort,omitempty"` // Sort by multiple field names. Field names have to be in camelCase. Sort is ascending by default.
}

PageOptions contains fields used to page through an endpoint as well as set page size.

type Permission

type Permission struct {
	Name string `json:"permission_name,omitempty"`
}

type PolicyCompliance

type PolicyCompliance string

type Profile

type Profile struct {
	Name                 string
	VeracodeApiKeyId     string
	VeracodeApiKeySecret string
}

type Response

type Response struct {
	*http.Response
	Page  PageMeta
	Links NavLinks
}

type Role

type Role struct {
	IsApi               bool   `json:"is_api,omitempty"`
	IsScanType          bool   `json:"is_scan_type,omitempty"`
	TeamAdminManageable bool   `json:"team_admin_manageable,omitempty"`
	RoleDescription     string `json:"role_description,omitempty"`
	RoleId              string `json:"role_id,omitempty"`
	RoleName            string `json:"role_name,omitempty"`
	RoleLegacyId        int    `json:"role_legacy_id,omitempty"`
}

type RoleUser

type RoleUser struct {
	RoleDescription string `json:"role_description,omitempty"`
	RoleId          string `json:"role_id,omitempty"`
	RoleName        string `json:"role_name,omitempty"`
}

RoleUser struct contains the fields that are return as part of the user aggregate.

type Sandbox added in v0.6.0

type Sandbox struct {
	ApplicationGuid string        `json:"application_guid,omitempty"`
	Created         time.Time     `json:"created,omitempty"`
	CustomFields    []CustomField `json:"custom_fields,omitempty"`
	Guid            string        `json:"guid,omitempty"`
	Id              int           `json:"id,omitempty"`
	Modified        time.Time     `json:"modified,omitempty"`
	Name            string        `json:"name,omitempty"`
	OrganizationId  int           `json:"organization_id,omitempty"`
	OwnerUsername   string        `json:"owner_username,omitempty"`
}

type SandboxService added in v0.6.0

type SandboxService service

You can use the Development Sandbox API to create, update, and delete development sandboxes. For more information:

Currently supports V1 of the Development Sandbox API

func (*SandboxService) CreateSandbox added in v0.6.0

func (s *SandboxService) CreateSandbox(ctx context.Context, applicationGuid string, sandbox CreateSandbox) (*Sandbox, *Response, error)

CreateSandbox takes an application GUID and a CreateSandbox, and then creates a new sandbox for the provided application.

func (*SandboxService) DeleteSandbox added in v0.6.0

func (s *SandboxService) DeleteSandbox(ctx context.Context, applicationGuid string, sandboxGuid string) (*Response, error)

DeleteSandbox takes an application GUID and a Sandbox GUID and deletes the sandbox with provide GUID.

func (*SandboxService) GetSandbox added in v0.6.0

func (s *SandboxService) GetSandbox(ctx context.Context, applicationGuid string, sandboxGuid string) (*Sandbox, *Response, error)

GetSandbox takes an application GUID string and a sandbox GUID, and then returns the sandbox with the provided GUID.

func (*SandboxService) ListSandboxes added in v0.6.0

func (s *SandboxService) ListSandboxes(ctx context.Context, applicationGuid string, options PageOptions) ([]Sandbox, *Response, error)

ListSandboxes takes an application GUID string and page options, and then returns a list of sandboxes for that application.

func (*SandboxService) PromoteSandbox added in v0.6.0

func (s *SandboxService) PromoteSandbox(ctx context.Context, applicationGuid string, sandboxGuid string, deleteOnPromotion bool) (*Sandbox, *Response, error)

PromoteSandbox promotes the latest scan in a sandbox, to a policy scan. setting deleteOnPromotion to true, will delete said scan once it has been promoted to the policy.

func (*SandboxService) UpdateSandbox added in v0.6.0

func (s *SandboxService) UpdateSandbox(ctx context.Context, applicationGuid string, sandboxGuid string, sandbox CreateSandbox) (*Sandbox, *Response, error)

UpdateSandbox takes an application GUID, a sandbox GUID and a CreateSandbox, and updates the existing sandbox with the new body.

type ScanStatus

type ScanStatus string

type ScanType

type ScanType string

type SearchUserOptions

type SearchUserOptions struct {
	Detailed     string `url:"detailed,omitempty"`      // Passing detailed will return additional hidden fields. Value should be one of: Yes or No
	SearchTerm   string `url:"search_term,omitempty"`   // You can search for partial strings of the username, first name, last name, or email address.
	RoleId       string `url:"role_id,omitempty"`       // Filter users by their role. Value should be a valid Role Id.
	UserType     string `url:"user_type,omitempty"`     // Filter by user type. Value should be one of: user or api
	LoginEnabled string `url:"login_enabled,omitempty"` // Filter by whether the login is enabled. Value should be one of: Yes or No
	LoginStatus  string `url:"login_status,omitempty"`  // Filter by the login status. Value should be one of: Active, Locked or Never
	SamlUser     string `url:"saml_user,omitempty"`     // Filter by whether the user is a SAML user or not. Value should be one of: Yes or No
	TeamId       string `url:"team_id,omitempty"`       // Filter users by team membership. Value should be a valid Team Id.
	ApiId        string `url:"api_id,omitempty"`        // Filter user by their API Id.
	PageOptions
}

type SortQueryField added in v0.5.0

type SortQueryField struct {
	Name   string
	IsDesc bool
}

type Team

type Team struct {
	TeamId       string           `json:"team_id,omitempty"`
	TeamLegacyId int              `json:"team_legacy_id,omitempty"`
	TeamName     string           `json:"team_name,omitempty"`
	Relationship TeamRelationship `json:"relationship,omitempty"`
	Users        *[]User          `json:"users,omitempty"`
	BusinessUnit *BusinessUnit    `json:"business_unit,omitempty"`
}

func (*Team) MarshalJSON

func (t *Team) MarshalJSON() ([]byte, error)

If Relationship.Name is "", create custom struct where TeamRelationship is a pointer and set it to nil. This will omit relationship from the marshalled json.

If Relationship.Name is not "", flatten TeamRelationship to Relationship in Team model.

type TeamRelationship

type TeamRelationship struct {
	Name string `json:"name,omitempty"`
}

type UpdateOptions

type UpdateOptions struct {
	Incremental *bool `url:"incremental,omitempty"` // incremental=true indicates that you are adding items to a list for an object property, such as adding users to a team.
	Partial     *bool `url:"partial,omitempty"`     // partial=true indicates that you are updating only a subset of properties for an object.
}

type User

type User struct {
	// Below fields will be included in /users and /users/search calls
	LoginEnabled *bool  `json:"login_enabled,omitempty"`
	SamlUser     *bool  `json:"saml_user,omitempty"` // Required when creating a new SAML user.
	EmailAddress string `json:"email_address,omitempty"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	UserId       string `json:"user_id,omitempty"`
	LegacyUserId string `json:"legacy_user_id,omitempty"`
	UserName     string `json:"user_name,omitempty"`

	// AccountType is added by passing detailed=true in the URL values.
	// AccountType will be shown in the user model for /users/{id}, /users and /users/search
	AccountType string `json:"account_type,omitempty"`

	Relationship TeamRelationship `json:"relationship,omitempty"` // Only present when the user is included in the Team model.

	// Below fields will only be included in /users/{id} calls
	// BACKLOG: Add remaining fields for model as required.
	Active *bool `json:"active,omitempty"`

	Roles       *[]RoleUser   `json:"roles,omitempty"`       // Be careful when setting a user's roles to an empty list. This will remove even the Administrator role.
	Teams       *[]Team       `json:"teams,omitempty"`       // Giving a user the team admin role will require setting the Team.Relationship.Name to "ADMIN"
	Permissions *[]Permission `json:"permissions,omitempty"` // A permission with name: "apiUser" needs to be set to create a new API user.

	Title       string `json:"title,omitempty"`        // Can be set when creating a new user, but is not available when fetching a user.
	UserType    string `json:"user_type,omitempty"`    // Required when creating a new user.
	SamlSubject string `json:"saml_subject,omitempty"` // Required when creating a new SAML user.
}

func NewAPIUser

func NewAPIUser(userName, emailAddress, firstName, lastName string, teams []Team) *User

NewAPIUser is a helper function that creates a new service account user with all of the required fields to Post successfully to the Veracode API.

Note the following:

  • NewAPIUser adds the "resultsapi" role as the default role for the created user. The caller should update the roles on the returned User.
  • Providing a nil value or an empty slice for parameter "teams", will add the "noteamrestrictionapi" role for the user. This role allows a Service Account to see all applications across the Veracode instance.

func NewSAMLUser

func NewSAMLUser(emailAddress, firstName, lastName, samlSubject string) *User

NewSAMLUser is a helper function that creates a new SAML user with all of the required fields to Post successfully to the Veracode API.

Note that NewSAMLUser adds the "securityinsightsonly" role as the default role for the created user. The caller should update the roles on the returned User.

func NewUser

func NewUser(emailAddress, firstName, lastName string) *User

NewUser is a helper function that creates a new user with all of the required fields to Post to the Veracode API.

Note that NewUser adds the "securityinsightsonly" role as the default role for the created user. The caller should update the roles on the User.

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

If Relationship.Name is "", create custom struct where TeamRelationship is a pointer and set it to nil. This will omit relationship from the marshalled json.

If Relationship.Name is not "", flatten TeamRelationship to Relationship in User model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL