veracode

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERY_HIGH BusinessCriticality = "VERY_HIGH"
	HIGH      BusinessCriticality = "HIGH"
	MEDIUM    BusinessCriticality = "MEDIUM"
	LOW       BusinessCriticality = "LOW"
	VERY_LOW  BusinessCriticality = "VERY_LOW"

	STATIC  ScanType = "STATIC"
	DYNAMIC ScanType = "DYNAMIC"
	MANUAL  ScanType = "MANUAL"

	PASSED           PolicyCompliance = "PASSED"
	CONDITIONAL_PASS PolicyCompliance = "CONDITIONAL_PASS"
	DID_NOT_PASS     PolicyCompliance = "DID_NOT_PASS"
	NOT_ASSESSED     PolicyCompliance = "NOT_ASSESSED"
	VENDOR_REVIEW    PolicyCompliance = "VENDOR_REVIEW"
	DETERMINING      PolicyCompliance = "DETERMINING"

	CREATED                                ScanStatus = "CREATED"
	UNPUBLISHED                            ScanStatus = "UNPUBLISHED"
	DELETED                                ScanStatus = "DELETED"
	PARTIAL_PUBLISH                        ScanStatus = "PARTIAL_PUBLISH"
	PARTIAL_UNPUBLISH                      ScanStatus = "PARTIAL_UNPUBLISH"
	INCOMPLETE                             ScanStatus = "INCOMPLETE"
	SCAN_SUBMITTED                         ScanStatus = "SCAN_SUBMITTED"
	IN_QUEUE                               ScanStatus = "IN_QUEUE"
	STOPPING                               ScanStatus = "STOPPING"
	PAUSING                                ScanStatus = "PAUSING"
	IN_PROGRESS                            ScanStatus = "IN_PROGRESS"
	ANALYSIS_ERRORS                        ScanStatus = "ANALYSIS_ERRORS"
	SCAN_CANCELED                          ScanStatus = "SCAN_CANCELED"
	INTERNAL_REVIEW                        ScanStatus = "INTERNAL_REVIEW"
	VERIFYING_RESULTS                      ScanStatus = "VERIFYING_RESULTS"
	SUBMITTED_FOR_NTO_PRE_SCAN             ScanStatus = "SUBMITTED_FOR_NTO_PRE_SCAN"
	SUBMITTED_FOR_DYNAMIC_PRE_SCAN         ScanStatus = "SUBMITTED_FOR_DYNAMIC_PRE_SCAN"
	PRE_SCAN_FAILED                        ScanStatus = "PRE_SCAN_FAILED"
	READY_TO_SUBMIT                        ScanStatus = "READY_TO_SUBMIT"
	NTO_PENDING_SUBMISSION                 ScanStatus = "NTO_PENDING_SUBMISSION"
	PRE_SCAN_COMPLETE                      ScanStatus = "PRE_SCAN_COMPLETE"
	MODULE_SELECTION_REQUIRED              ScanStatus = "MODULE_SELECTION_REQUIRED"
	PENDING_VENDOR_ACCEPTANCE              ScanStatus = "PENDING_VENDOR_ACCEPTANCE"
	SHOW_OSRDB                             ScanStatus = "SHOW_OSRDB"
	PUBLISHED                              ScanStatus = "PUBLISHED"
	PUBLISHED_TO_VENDOR                    ScanStatus = "PUBLISHED_TO_VENDOR"
	PUBLISHED_TO_ENTERPRISE                ScanStatus = "PUBLISHED_TO_ENTERPRISE"
	PENDING_ACCOUNT_APPROVAL               ScanStatus = "PENDING_ACCOUNT_APPROVAL"
	PENDING_LEGAL_AGREEMENT                ScanStatus = "PENDING_LEGAL_AGREEMENT"
	SCAN_IN_PROGRESS                       ScanStatus = "SCAN_IN_PROGRESS"
	SCAN_IN_PROGRESS_PARTIAL_RESULTS_READY ScanStatus = "SCAN_IN_PROGRESS_PARTIAL_RESULTS_READY"
	PROMOTE_IN_PROGRESS                    ScanStatus = "PROMOTE_IN_PROGRESS"
	PRE_SCAN_CANCELED                      ScanStatus = "PRE_SCAN_CANCELED"
	NTO_PRE_SCAN_CANCELED                  ScanStatus = "NTO_PRE_SCAN_CANCELED"
	SCAN_HELD_APPROVAL                     ScanStatus = "SCAN_HELD_APPROVAL"
	SCAN_HELD_LOGIN_INSTRUCTIONS           ScanStatus = "SCAN_HELD_LOGIN_INSTRUCTIONS"
	SCAN_HELD_LOGIN                        ScanStatus = "SCAN_HELD_LOGIN"
	SCAN_HELD_INSTRUCTIONS                 ScanStatus = "SCAN_HELD_INSTRUCTIONS"
	SCAN_HELD_HOLDS_FINISHED               ScanStatus = "SCAN_HELD_HOLDS_FINISHED"
	SCAN_REQUESTED                         ScanStatus = "SCAN_REQUESTED"
	TIMEFRAMEPENDING_ID                    ScanStatus = "TIMEFRAMEPENDING_ID"
	PAUSED_ID                              ScanStatus = "PAUSED_ID"
	STATIC_VALIDATING_UPLOAD               ScanStatus = "STATIC_VALIDATING_UPLOAD"
	PUBLISHED_TO_ENTERPRISEINT             ScanStatus = "PUBLISHED_TO_ENTERPRISEINT"
)

Variables

This section is empty.

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 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 Application

type Application struct {
	Guid    string             `json:"guid,omitempty"`
	Profile ApplicationProfile `json:"profile,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"`
}

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 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

	// 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
	Identity *IdentityService
	// 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
	Application *ApplicationService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(region Region, 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) SetBaseURL

func (c *Client) SetBaseURL(region Region) error

SetBaseURL takes a Region and updates the Client's baseURL. It write locks the sync.RWMutex to prevent any concurrent reads while writing (just in case).

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 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 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) 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) 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, searchTerm string) ([]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) 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) Self

func (i *IdentityService) Self(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) 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) UpdateSelf

func (i *IdentityService) UpdateSelf(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) 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 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 {
	Size      int   `url:"size,omitempty"`
	Page      int   `url:"page,omitempty"`
	AllForOrg *bool `url:"all_for_org,omitempty"`
}

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
	Page         int      `url:"page,omitempty"`                  // Page through the list.
	Size         int      `url:"size,omitempty"`                  // Increase the page size.
	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).
}

type PageOptions

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

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 Region

type Region string
const (
	RegionEurope       Region = "https://api.veracode.eu"
	RegionUnitedStates Region = "https://api.veracode.us"
	RegionCommercial   Region = "https://api.veracode.com"
)

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 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
	Page         int    `url:"page,omitempty"`          // Page through the list.
	Size         int    `url:"size,omitempty"`          // Increase the page size.
	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.
}

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