rest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 11 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)

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

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

func (*APIClient) GetResponseBody

func (c *APIClient) GetResponseBody(endpoint string) ([]byte, 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() ([]byte, error)

func (*APIClient) GetTeams

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

func (*APIClient) GetTriagedResultsByScanID

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

func (*APIClient) GetUsers

func (c *APIClient) GetUsers() ([]byte, 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
	GetResponseBody(endpoint string) ([]byte, error)
	PostResponseBody(endpoint string, body io.Reader) ([]byte, error)
	GetUsers() ([]byte, error)
	GetRoles() ([]byte, error)
	GetTeams() ([]byte, error)
	GetLdapServers() ([]byte, error)
	GetLdapRoleMappings() ([]byte, error)
	GetLdapTeamMappings() ([]byte, error)
	GetSamlIdentityProviders() ([]byte, error)
	GetSamlRoleMappings() ([]byte, error)
	GetSamlTeamMappings() ([]byte, error)
	GetProjectsWithLastScanID(fromDate string, offset, limit int) (*[]ProjectWithLastScanID, error)
	GetTriagedResultsByScanID(scanID int) (*[]TriagedScanResult, error)
	CreateScanReport(scanID int, reportType string, retry Retry) ([]byte, error)
}

type ODataProjectsWithLastScanID

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

type ODataTriagedResultsByScan

type ODataTriagedResultsByScan struct {
	Value []TriagedScanResult
}

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

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

Jump to

Keyboard shortcuts

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