rest

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 10 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) 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)
	GetLdapServers() ([]byte, error)
	GetLdapRoleMappings() ([]byte, error)
	GetLdapTeamMappings() ([]byte, error)
	GetSamlIdentityProviders() ([]byte, error)
	GetSamlRoleMappings() ([]byte, error)
	GetSamlTeamMappings() ([]*SamlTeamMapping, 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 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 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