v1

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 33 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MAX_RETRIES int           = 3
	RETRY_DELAY time.Duration = time.Second * 5
)
View Source
var (
	ErrAPINotPublic = errors.New("control api is not public")
)

Functions

func GetCVEExceptionByDesignator

func GetCVEExceptionByDesignator(baseURL, customerGUID string, designators *identifiers.PortalDesignator, headers map[string]string) ([]armotypes.VulnerabilityExceptionPolicy, error)

func GetPostureReportUrl

func GetPostureReportUrl(eventReceiverRestUrl, customerGUID, contextName, reportID string) (*url.URL, error)

func GetRegistryRepositoriesUrl

func GetRegistryRepositoriesUrl(eventReceiverRestUrl, customerGUID, registryName, jobID string) (*url.URL, error)

func GetReporterClusterReportsWebsocketUrl

func GetReporterClusterReportsWebsocketUrl(eventReceiverWebsocketUrl, accountID, clusterName string) (*url.URL, error)

func GetRootGatewayUrl

func GetRootGatewayUrl(gatewayUrl string) (*url.URL, error)

func GetSystemReportURL

func GetSystemReportURL(eventReceiverUrl, customerGUID string) (*url.URL, error)

func GetVulnerabilitiesReportURL

func GetVulnerabilitiesReportURL(eventReceiverUrl, customerGUID string) (*url.URL, error)

func MockAPIServer

func MockAPIServer(t testing.TB, opts ...mockAPIOption) *testServer

func TestFrameworkFile

func TestFrameworkFile(framework string) string

Types

type AttackTrack

type AttackTrack = v1alpha1.AttackTrack

AttackTrack is an alias to the API type definition for attack tracks.

type BaseReportSender

type BaseReportSender struct {
	// contains filtered or unexported fields
}

func NewBaseReportSender

func NewBaseReportSender(eventReceiverUrl string, httpClient httputils.IHttpClient, headers map[string]string, report *systemreports.BaseReport) *BaseReportSender

func (*BaseReportSender) AddError

func (sender *BaseReportSender) AddError(errorString string)

func (*BaseReportSender) GetActionID

func (sender *BaseReportSender) GetActionID() string

func (*BaseReportSender) GetActionIDN

func (sender *BaseReportSender) GetActionIDN() int

func (*BaseReportSender) GetActionName

func (sender *BaseReportSender) GetActionName() string

func (*BaseReportSender) GetBaseReport

func (sender *BaseReportSender) GetBaseReport() *systemreports.BaseReport

func (*BaseReportSender) GetCustomerGUID

func (sender *BaseReportSender) GetCustomerGUID() string

func (*BaseReportSender) GetDetails

func (sender *BaseReportSender) GetDetails() string

func (*BaseReportSender) GetErrorList

func (sender *BaseReportSender) GetErrorList() []string

func (*BaseReportSender) GetJobID

func (sender *BaseReportSender) GetJobID() string

func (*BaseReportSender) GetNextActionId

func (sender *BaseReportSender) GetNextActionId() string

func (*BaseReportSender) GetParentAction

func (sender *BaseReportSender) GetParentAction() string

func (*BaseReportSender) GetReportID

func (sender *BaseReportSender) GetReportID() string

func (*BaseReportSender) GetReporter

func (sender *BaseReportSender) GetReporter() string

func (*BaseReportSender) GetStatus

func (sender *BaseReportSender) GetStatus() string

func (*BaseReportSender) GetTarget

func (sender *BaseReportSender) GetTarget() string

func (*BaseReportSender) GetTimestamp

func (sender *BaseReportSender) GetTimestamp() time.Time

func (*BaseReportSender) NextActionID

func (sender *BaseReportSender) NextActionID()

func (*BaseReportSender) Send

func (s *BaseReportSender) Send() (int, string, error)

Send - send http request. returns-> http status code, return message (jobID/OK), http/go error

func (*BaseReportSender) SendAction

func (sender *BaseReportSender) SendAction(actionName string, sendReport bool)

func (*BaseReportSender) SendAsRoutine

func (sender *BaseReportSender) SendAsRoutine(progressNext bool)

The caller must read the errChan, to prevent the goroutine from waiting in memory forever

func (*BaseReportSender) SendDetails

func (sender *BaseReportSender) SendDetails(details string, sendReport bool)

func (*BaseReportSender) SendError

func (sender *BaseReportSender) SendError(err error, sendReport bool, initErrors bool)

func (*BaseReportSender) SendStatus

func (sender *BaseReportSender) SendStatus(status string, sendReport bool)

func (*BaseReportSender) SendWarning

func (sender *BaseReportSender) SendWarning(warnMsg string, sendReport bool, initWarnings bool)

func (*BaseReportSender) SetActionID

func (sender *BaseReportSender) SetActionID(val string)

func (*BaseReportSender) SetActionIDN

func (sender *BaseReportSender) SetActionIDN(val int)

func (*BaseReportSender) SetActionName

func (sender *BaseReportSender) SetActionName(val string)

func (*BaseReportSender) SetCustomerGUID

func (sender *BaseReportSender) SetCustomerGUID(val string)

func (*BaseReportSender) SetDetails

func (sender *BaseReportSender) SetDetails(val string)

func (*BaseReportSender) SetJobID

func (sender *BaseReportSender) SetJobID(val string)

func (*BaseReportSender) SetParentAction

func (sender *BaseReportSender) SetParentAction(val string)

func (*BaseReportSender) SetReporter

func (sender *BaseReportSender) SetReporter(val string)

func (*BaseReportSender) SetStatus

func (sender *BaseReportSender) SetStatus(val string)

func (*BaseReportSender) SetTarget

func (sender *BaseReportSender) SetTarget(val string)

func (*BaseReportSender) SetTimestamp

func (sender *BaseReportSender) SetTimestamp(val time.Time)

func (*BaseReportSender) SimpleReportAnnotations

func (sender *BaseReportSender) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)

type Control

type Control = reporthandling.Control

Control is an alias to the API type definition for a control.

type CustomerConfig

type CustomerConfig = armotypes.CustomerConfig

CustomerConfig is an alias to the API type definition for a customer configuration.

type Framework

type Framework = reporthandling.Framework

Framework is an alias to the API type definition for a framework.

type HttpReportSender added in v0.0.3

type HttpReportSender struct {
	// contains filtered or unexported fields
}

func (*HttpReportSender) Send added in v0.0.3

func (s *HttpReportSender) Send(serverURL string, headers map[string]string, reqBody []byte) (int, string, error)

Send sends an HTTP request to a server and returns the HTTP status code, return message, and any errors.

type HttpReportSenderMock added in v0.0.3

type HttpReportSenderMock struct {
}

func (*HttpReportSenderMock) Send added in v0.0.3

func (sm *HttpReportSenderMock) Send(serverURL string, headers map[string]string, reqBody []byte) (int, string, error)

type IHttpSender added in v0.0.3

type IHttpSender interface {
	Send(serverURL string, headers map[string]string, reqBody []byte) (int, string, error)
}

type IReportSender

type IReportSender interface {
	systemreports.IReporter

	Send() (int, string, error) //send logic here

	/*
		SendAsRoutine
		@input:
		collector []string - leave as empty (a way to hold all previous failed reports and send them in bulk)
		progressNext bool - increase actionID, sometimes u send parallel jobs that have the same order - (vuln scanning a cluster for eg. all wl scans have the same order)
		errChan - chan to allow the goroutine to return the errors inside
	*/
	SendAsRoutine(bool) //goroutine wrapper

	// set methods
	SendAction(action string, sendReport bool)
	SendError(err error, sendReport bool, initErrors bool)
	SendStatus(status string, sendReport bool)
	SendDetails(details string, sendReport bool)
	SendWarning(warning string, sendReport bool, initWarnings bool)
}

type KSCloudAPI

type KSCloudAPI struct {
	*KsCloudOptions
	// contains filtered or unexported fields
}

KSCloudAPI allows to access the API of the Kubescape Cloud offering.

func NewEmptyKSCloudAPI

func NewEmptyKSCloudAPI(opts ...KSCloudOption) *KSCloudAPI

NewEmptyKSCloudAPI creates a new KSCloudAPI without any hosts set.

func NewKSCloudAPI

func NewKSCloudAPI(apiURL, reportURL, accountID, accessKey string, opts ...KSCloudOption) (*KSCloudAPI, error)

func (*KSCloudAPI) GetAccessKey added in v0.0.10

func (api *KSCloudAPI) GetAccessKey() string

func (*KSCloudAPI) GetAccountConfig

func (api *KSCloudAPI) GetAccountConfig(clusterName string) (*CustomerConfig, error)

GetAccountConfig yields the account configuration.

func (*KSCloudAPI) GetAccountID

func (api *KSCloudAPI) GetAccountID() string

GetAccountID returns the customer account's GUID.

func (*KSCloudAPI) GetAttackTracks

func (api *KSCloudAPI) GetAttackTracks() ([]AttackTrack, error)

func (*KSCloudAPI) GetCloudAPIURL

func (api *KSCloudAPI) GetCloudAPIURL() string

func (*KSCloudAPI) GetCloudReportURL

func (api *KSCloudAPI) GetCloudReportURL() string

func (*KSCloudAPI) GetControl

func (api *KSCloudAPI) GetControl(ID string) (*Control, error)

GetControl is currently not exposed as a public API endpoint.

func (*KSCloudAPI) GetControlsInputs

func (api *KSCloudAPI) GetControlsInputs(clusterName string) (map[string][]string, error)

GetControlsInputs returns the controls inputs configured in the account configuration.

func (*KSCloudAPI) GetExceptions

func (api *KSCloudAPI) GetExceptions(clusterName string) ([]PostureExceptionPolicy, error)

GetExceptions returns exception policies.

func (*KSCloudAPI) GetFramework

func (api *KSCloudAPI) GetFramework(frameworkName string) (*Framework, error)

GetFramework retrieves a framework by name.

func (*KSCloudAPI) GetFrameworks

func (api *KSCloudAPI) GetFrameworks() ([]Framework, error)

GetFrameworks returns all registered frameworks.

func (*KSCloudAPI) ListControls

func (api *KSCloudAPI) ListControls() ([]string, error)

ListControls is currently not exposed as a public API endpoint.

func (*KSCloudAPI) ListCustomFrameworks

func (api *KSCloudAPI) ListCustomFrameworks() ([]string, error)

ListCustomFrameworks lists the names of all non-native frameworks that have been registered for this account.

func (*KSCloudAPI) ListFrameworks

func (api *KSCloudAPI) ListFrameworks() ([]string, error)

ListFrameworks list the names of all registered frameworks.

func (*KSCloudAPI) SetAccessKey added in v0.0.11

func (api *KSCloudAPI) SetAccessKey(value string)

func (*KSCloudAPI) SetAccountID added in v0.0.11

func (api *KSCloudAPI) SetAccountID(value string)

func (*KSCloudAPI) SetCloudAPIURL added in v0.0.11

func (api *KSCloudAPI) SetCloudAPIURL(cloudAPIURL string) (err error)

func (*KSCloudAPI) SetCloudReportURL added in v0.0.11

func (api *KSCloudAPI) SetCloudReportURL(cloudReportURL string) (err error)

func (*KSCloudAPI) SubmitReport

func (api *KSCloudAPI) SubmitReport(report *PostureReport) (string, error)

SubmitReport uploads a posture report.

type KSCloudOption

type KSCloudOption func(*KsCloudOptions)

KSCloudOption allows to configure the behavior of the KS Cloud client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) KSCloudOption

WithHTTPClient overrides the default http.Client used by the KS Cloud client.

func WithTimeout

func WithTimeout(timeout time.Duration) KSCloudOption

WithTimeout sets a global timeout on a operations performed by the KS Cloud client.

A value of 0 means no timeout.

The default is 61s.

func WithTrace

func WithTrace(enabled bool) KSCloudOption

WithTrace toggles requests dump for inspection & debugging.

type KsCloudOptions

type KsCloudOptions struct {
	// contains filtered or unexported fields
}

ksCloudOptions holds all the configurable parts of the KS Cloud client.

type PostureExceptionPolicy

type PostureExceptionPolicy = armotypes.PostureExceptionPolicy

PostureExceptionPolicy is an alias to the API type definition for posture exception policy.

type PostureReport

type PostureReport = reporthandlingv2.PostureReport

PostureReport is an alias to the API type definition for a posture report.

type RequestOption added in v0.0.7

type RequestOption func(*RequestOptions)

request option instructs post/get/delete to alter the outgoing request

func WithContentJSON added in v0.0.7

func WithContentJSON(enabled bool) RequestOption

WithContentJSON sets JSON content type for a request

func WithHeaders added in v0.0.7

func WithHeaders(headers map[string]string) RequestOption

WithContentJSON sets JSON content type for a request

type RequestOptions added in v0.0.7

type RequestOptions struct {
	// contains filtered or unexported fields
}

RequestOptions knows how to enrich a request with headers

Jump to

Keyboard shortcuts

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