rest

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ScanReportTypeXML defines SAST report type XML
	ScanReportTypeXML = "XML"
)

Variables

This section is empty.

Functions

func CreateAccessTokenRequest

func CreateAccessTokenRequest(baseURL, username, password string) (*retryablehttp.Request, error)

func CreateRequest

func CreateRequest(httpMethod, requestURL string, requestBody io.Reader, token *AccessToken) (*retryablehttp.Request, error)

func GetFilterForProjects added in v1.0.4

func GetFilterForProjects(fromDate, teamName, projectIds string) string

GetFilterForProjects get filter string for projects list

func GetFilterForProjectsWithLastScan added in v1.0.4

func GetFilterForProjectsWithLastScan(fromDate, teamName, projectIds string) string

GetFilterForProjectsWithLastScan get filter string for projects list with last scan

Types

type APIClient

type APIClient struct {
	BaseURL string
	Adapter RetryableHTTPAdapter
	Token   *AccessToken
}

func NewSASTClient

func NewSASTClient(baseURL string, adapter RetryableHTTPAdapter) (*APIClient, error)

func (*APIClient) Authenticate

func (c *APIClient) Authenticate(username, password string) error

func (*APIClient) CreateScanReport

func (c *APIClient) CreateScanReport(scanID int, reportType string, retry Retry) ([]byte, error)

func (*APIClient) GetEngineServers added in v1.2.0

func (c *APIClient) GetEngineServers() ([]*EngineServer, error)

func (*APIClient) GetLdapRoleMappings

func (c *APIClient) GetLdapRoleMappings() ([]byte, error)

func (*APIClient) GetLdapServers

func (c *APIClient) GetLdapServers() ([]byte, error)

func (*APIClient) GetLdapTeamMappings

func (c *APIClient) GetLdapTeamMappings() ([]byte, error)

func (*APIClient) GetPresets added in v1.0.4

func (c *APIClient) GetPresets() ([]*PresetShort, error)

func (*APIClient) GetProjects added in v1.0.4

func (c *APIClient) GetProjects(fromDate, teamName, projectIds string, offset, limit int) ([]*Project, error)

func (*APIClient) GetProjectsWithLastScanID

func (c *APIClient) GetProjectsWithLastScanID(fromDate, teamName, projectsIds string, offset, limit int) (*[]ProjectWithLastScanID, error)

func (*APIClient) GetRoles

func (c *APIClient) GetRoles() ([]byte, error)

func (*APIClient) GetSamlIdentityProviders

func (c *APIClient) GetSamlIdentityProviders() ([]byte, error)

func (*APIClient) GetSamlRoleMappings

func (c *APIClient) GetSamlRoleMappings() ([]byte, error)

func (*APIClient) GetSamlTeamMappings

func (c *APIClient) GetSamlTeamMappings() ([]*SamlTeamMapping, error)

func (*APIClient) GetTeams

func (c *APIClient) GetTeams() ([]*Team, error)

func (*APIClient) GetTriagedResultsByScanID

func (c *APIClient) GetTriagedResultsByScanID(scanID int) (*[]TriagedScanResult, error)

func (*APIClient) GetUsers

func (c *APIClient) GetUsers() ([]*User, error)

func (*APIClient) PostResponseBody

func (c *APIClient) PostResponseBody(endpoint string, body io.Reader) ([]byte, error)

type APIError

type APIError struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

type AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
}

type Client

type Client interface {
	Authenticate(username, password string) error
	PostResponseBody(endpoint string, body io.Reader) ([]byte, error)
	GetUsers() ([]*User, error)
	GetRoles() ([]byte, error)
	GetTeams() ([]*Team, error)
	GetProjects(fromDate, teamName, projectIds string, offset, limit int) ([]*Project, error)
	GetPresets() ([]*PresetShort, error)
	GetLdapServers() ([]byte, error)
	GetLdapRoleMappings() ([]byte, error)
	GetLdapTeamMappings() ([]byte, error)
	GetSamlIdentityProviders() ([]byte, error)
	GetSamlRoleMappings() ([]byte, error)
	GetSamlTeamMappings() ([]*SamlTeamMapping, error)
	GetProjectsWithLastScanID(fromDate, teamName, projectsIds string, offset, limit int) (*[]ProjectWithLastScanID, error)
	GetTriagedResultsByScanID(scanID int) (*[]TriagedScanResult, error)
	CreateScanReport(scanID int, reportType string, retry Retry) ([]byte, error)
	GetEngineServers() ([]*EngineServer, error)
}

type Configuration added in v1.0.4

type Configuration struct {
	CustomFields []*CustomField `json:"customFields"`
}

type CustomField added in v1.0.4

type CustomField struct {
	FieldName  string `json:"fieldName"`
	FieldValue string `json:"fieldValue"`
}

type EngineServer added in v1.2.0

type EngineServer struct {
	ID                             int                           `json:"id"`
	Name                           string                        `json:"name"`
	URI                            string                        `json:"uri"`
	MinLoc                         int                           `json:"minLoc"`
	MaxLoc                         int                           `json:"maxLoc"`
	MaxScans                       int                           `json:"maxScans"`
	CxVersion                      string                        `json:"cxVersion"`
	OperatingSystem                string                        `json:"operatingSystem"`
	Status                         StatusEngineServer            `json:"status"`
	Link                           LinkEngineServer              `json:"link"`
	OfflineReasonCode              OfflineReasonCodeEngineServer `json:"offlineReasonCode"`
	OfflineReasonMessage           string                        `json:"offlineReasonMessage"`
	OfflineReasonMessageParameters string                        `json:"offlineReasonMessageParameters"`
}

type LinkEngineServer added in v1.2.0

type LinkEngineServer struct {
	Rel string `json:"rel"`
	URI string `json:"uri"`
}

type ODataProjectsWithCustomFields added in v1.0.4

type ODataProjectsWithCustomFields struct {
	Value []ProjectWithCustomFields `json:"value"`
}

type ODataProjectsWithLastScanID

type ODataProjectsWithLastScanID struct {
	OdataContext string                  `json:"@odata.context"`
	Value        []ProjectWithLastScanID `json:"value"`
}

type ODataTriagedResultsByScan

type ODataTriagedResultsByScan struct {
	Value []TriagedScanResult
}

type OfflineReasonCodeEngineServer added in v1.2.0

type OfflineReasonCodeEngineServer struct {
	ID    int    `json:"id"`
	Value string `json:"value"`
}

type PresetShort added in v1.0.4

type PresetShort struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	OwnerName string `json:"ownerName"`
}

type Project added in v1.0.4

type Project struct {
	ID            int            `json:"id"`
	TeamID        int            `json:"teamId"`
	Name          string         `json:"name"`
	IsPublic      bool           `json:"isPublic"`
	PresetID      int            `json:"presetId"`
	CreatedDate   string         `json:"createdDate"`
	Configuration *Configuration `json:"configuration"`
}

type ProjectOData added in v1.0.4

type ProjectOData struct {
	ID           int            `json:"Id"`
	CreatedDate  string         `json:"CreatedDate"`
	CustomFields []*CustomField `json:"CustomFields"`
}

type ProjectWithCustomFields added in v1.0.4

type ProjectWithCustomFields struct {
	ID           int            `json:"Id"`
	TeamID       int            `json:"OwningTeamId"`
	Name         string         `json:"Name"`
	IsPublic     bool           `json:"IsPublic"`
	PresetID     int            `json:"PresetId"`
	CreatedDate  string         `json:"CreatedDate"`
	CustomFields []*CustomField `json:"CustomFields"`
}

type ProjectWithLastScanID

type ProjectWithLastScanID struct {
	ID         int `json:"Id"`
	LastScanID int `json:"LastScanId"`
}

type ReportRequest

type ReportRequest struct {
	ReportType string `json:"reportType"`
	ScanID     int    `json:"scanId"`
}

type ReportResponse

type ReportResponse struct {
	ReportID int `json:"ReportId" groups:"out"`
	Links    struct {
		Report struct {
			Rel string `json:"rel"`
			URI string `json:"uri"`
		} `json:"ReportResponse"`
		Status struct {
			Rel string `json:"rel"`
			URI string `json:"uri"`
		} `json:"status"`
	} `json:"links"`
}

type Retry

type Retry struct {
	Attempts int
	MinSleep,
	MaxSleep time.Duration
}

type RetryableHTTPAdapter

type RetryableHTTPAdapter interface {
	Do(req *retryablehttp.Request) (*http.Response, error)
}

type SamlTeamMapping added in v1.0.3

type SamlTeamMapping struct {
	ID                     int    `json:"id"`
	SamlIdentityProviderID int    `json:"samlIdentityProviderId"`
	TeamID                 int    `json:"teamId"`
	TeamFullPath           string `json:"teamFullPath"`
	SamlAttributeValue     string `json:"samlAttributeValue"`
}

type StatusEngineServer added in v1.2.0

type StatusEngineServer struct {
	ID    int    `json:"id"`
	Value string `json:"value"`
}

type StatusResponse

type StatusResponse struct {
	Link struct {
		Rel string `json:"rel"`
		URI string `json:"uri"`
	} `json:"link"`
	ContentType string `json:"contentType"`
	Status      struct {
		ID    int    `json:"id"`
		Value string `json:"value"`
	} `json:"status"`
}

type Team added in v1.0.3

type Team struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	FullName string `json:"fullName"`
	ParendID int    `json:"parentId"`
}

type TriagedScanResult

type TriagedScanResult struct {
	ID int `json:"Id"`
}

type User added in v1.0.3

type User struct {
	ID                       int      `json:"id"`
	UserName                 string   `json:"userName"`
	LastLoginDate            string   `json:"lastLoginDate"`
	RoleIDs                  []int    `json:"roleIds"`
	TeamIDs                  []int    `json:"teamIds"`
	AuthenticationProviderID int      `json:"authenticationProviderId"`
	CreationDate             string   `json:"creationDate"`
	FirstName                string   `json:"firstName"`
	LastName                 string   `json:"lastName"`
	Email                    string   `json:"email"`
	PhoneNumber              string   `json:"phoneNumber"`
	CellPhoneNumber          string   `json:"cellPhoneNumber"`
	JobTitle                 string   `json:"jobTitle"`
	Other                    string   `json:"other"`
	Country                  string   `json:"country"`
	Active                   bool     `json:"active"`
	ExpirationDate           string   `json:"expirationDate"`
	AllowedIPList            []string `json:"allowedIpList"`
	LocaleID                 int      `json:"localeId"`
}

Jump to

Keyboard shortcuts

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