Documentation
¶
Index ¶
- Constants
- Variables
- func GetCVEExceptionByDesignator(ctx context.Context, backendURL, customerGUID string, ...) ([]armotypes.VulnerabilityExceptionPolicy, error)
- func GetCVEExceptionByRawQuery(ctx context.Context, backendURL, customerGUID string, rawQuery *url.Values, ...) ([]armotypes.VulnerabilityExceptionPolicy, error)
- func GetPostureReportUrl(eventReceiverRestUrl, customerGUID, contextName, reportID string) (*url.URL, error)
- func GetRegistryRepositoriesUrl(eventReceiverRestUrl, customerGUID, registryName, jobID string) (*url.URL, error)
- func GetReporterClusterReportsWebsocketUrl(eventReceiverWebsocketUrl, accountID, clusterName string) (*url.URL, error)
- func GetRootGatewayUrl(gatewayUrl string) (*url.URL, error)
- func GetSystemReportURL(eventReceiverUrl, customerGUID string) (*url.URL, error)
- func GetVulnerabilitiesReportURL(eventReceiverUrl, customerGUID string) (*url.URL, error)
- func MarshalSBOM(sbom *v1beta1.SBOMSyft) (io.Reader, error)
- func MockAPIServer(t testing.TB, opts ...mockAPIOption) *testServer
- func TestFrameworkFile(framework string) string
- func UnmarshalSBOM(r io.Reader) (*v1beta1.SBOMSyft, error)
- type AttackTrack
- type BaseReportSender
- func (sender *BaseReportSender) AddError(errorString string)
- func (sender *BaseReportSender) GetActionID() string
- func (sender *BaseReportSender) GetActionIDN() int
- func (sender *BaseReportSender) GetActionName() string
- func (sender *BaseReportSender) GetBaseReport() *systemreports.BaseReport
- func (sender *BaseReportSender) GetCustomerGUID() string
- func (sender *BaseReportSender) GetDetails() string
- func (sender *BaseReportSender) GetErrorList() []string
- func (sender *BaseReportSender) GetJobID() string
- func (sender *BaseReportSender) GetNextActionId() string
- func (sender *BaseReportSender) GetParentAction() string
- func (sender *BaseReportSender) GetReportID() string
- func (sender *BaseReportSender) GetReporter() string
- func (sender *BaseReportSender) GetStatus() string
- func (sender *BaseReportSender) GetTarget() string
- func (sender *BaseReportSender) GetTimestamp() time.Time
- func (sender *BaseReportSender) NextActionID()
- func (s *BaseReportSender) Send() (int, string, error)
- func (sender *BaseReportSender) SendAction(actionName string, sendReport bool)
- func (sender *BaseReportSender) SendAsRoutine(progressNext bool)
- func (sender *BaseReportSender) SendDetails(details string, sendReport bool)
- func (sender *BaseReportSender) SendError(err error, sendReport bool, initErrors bool)
- func (sender *BaseReportSender) SendStatus(status string, sendReport bool)
- func (sender *BaseReportSender) SendWarning(warnMsg string, sendReport bool, initWarnings bool)
- func (sender *BaseReportSender) SetActionID(val string)
- func (sender *BaseReportSender) SetActionIDN(val int)
- func (sender *BaseReportSender) SetActionName(val string)
- func (sender *BaseReportSender) SetCustomerGUID(val string)
- func (sender *BaseReportSender) SetDetails(val string)
- func (sender *BaseReportSender) SetJobID(val string)
- func (sender *BaseReportSender) SetParentAction(val string)
- func (sender *BaseReportSender) SetReporter(val string)
- func (sender *BaseReportSender) SetStatus(val string)
- func (sender *BaseReportSender) SetTarget(val string)
- func (sender *BaseReportSender) SetTimestamp(val time.Time)
- func (sender *BaseReportSender) SimpleReportAnnotations(setParent bool, setCurrent bool) (string, string)
- type Control
- type CustomerConfig
- type Framework
- type GRPCConfig
- type HttpReportSender
- type HttpReportSenderMock
- type IHttpSender
- type IReportSender
- type KSCloudAPI
- func (api *KSCloudAPI) GetAccessKey() string
- func (api *KSCloudAPI) GetAccountConfig(clusterName string, opts ...RequestOption) (*CustomerConfig, error)
- func (api *KSCloudAPI) GetAccountID() string
- func (api *KSCloudAPI) GetAttackTracks() ([]AttackTrack, error)
- func (api *KSCloudAPI) GetCloudAPIURL() string
- func (api *KSCloudAPI) GetCloudReportURL() string
- func (api *KSCloudAPI) GetControl(ID string) (*Control, error)
- func (api *KSCloudAPI) GetControlsInputs(clusterName string) (map[string][]string, error)
- func (api *KSCloudAPI) GetControlsInputsWithContext(ctx context.Context, clusterName string, opts ...RequestOption) (map[string][]string, error)
- func (api *KSCloudAPI) GetExceptions(clusterName string) ([]PostureExceptionPolicy, error)
- func (api *KSCloudAPI) GetExceptionsWithContext(ctx context.Context, clusterName string, opts ...RequestOption) ([]PostureExceptionPolicy, error)
- func (api *KSCloudAPI) GetFramework(frameworkName string) (*Framework, error)
- func (api *KSCloudAPI) GetFrameworks() ([]Framework, error)
- func (api *KSCloudAPI) ListControls() ([]string, error)
- func (api *KSCloudAPI) ListCustomFrameworks() ([]string, error)
- func (api *KSCloudAPI) ListFrameworks() ([]string, error)
- func (api *KSCloudAPI) SetAccessKey(value string)
- func (api *KSCloudAPI) SetAccountID(value string)
- func (api *KSCloudAPI) SetCloudAPIURL(cloudAPIURL string) (err error)
- func (api *KSCloudAPI) SetCloudReportURL(cloudReportURL string) (err error)
- func (api *KSCloudAPI) SubmitReport(report *PostureReport) (string, error)
- func (api *KSCloudAPI) SubmitReportWithContext(ctx context.Context, report *PostureReport, opts ...RequestOption) (string, error)
- type KSCloudOption
- type KsCloudOptions
- type PostureExceptionPolicy
- type PostureReport
- type ProfileOption
- type ProfileOptions
- type RequestOption
- type RequestOptions
- type StorageClient
- func (c *StorageClient) Close() error
- func (c *StorageClient) Connect() error
- func (c *StorageClient) GetAccessKey() string
- func (c *StorageClient) GetAccountID() string
- func (c *StorageClient) GetAddress() string
- func (c *StorageClient) GetApplicationProfile(ctx context.Context, namespace, name string, opts ...ProfileOption) (*legacyv1beta1.ApplicationProfile, error)
- func (c *StorageClient) GetCluster() string
- func (c *StorageClient) GetContainerProfile(ctx context.Context, namespace, name string, opts ...ProfileOption) (*v1beta1.ContainerProfile, error)deprecated
- func (c *StorageClient) GetContainerProfileStream(ctx context.Context, namespace, name string, opts ...ProfileOption) (*v1beta1.ContainerProfile, error)
- func (c *StorageClient) GetGRPCConfig() *GRPCConfig
- func (c *StorageClient) GetNetworkNeighborhood(ctx context.Context, namespace, name string, opts ...ProfileOption) (*legacyv1beta1.NetworkNeighborhood, error)
- func (c *StorageClient) GetSBOMStream(ctx context.Context, imageDigest, syftVersion string, metadataOnly bool) (*proto.GetSBOMChunkMetadata, io.ReadCloser, error)
- func (c *StorageClient) IsConnected() bool
- func (c *StorageClient) ListApplicationProfiles(ctx context.Context, namespace string, limit int64, cont string, ...) (*legacyv1beta1.ApplicationProfileList, error)
- func (c *StorageClient) ListNetworkNeighborhoods(ctx context.Context, namespace string, limit int64, cont string, ...) (*legacyv1beta1.NetworkNeighborhoodList, error)
- func (c *StorageClient) PatchSBOMAnnotations(ctx context.Context, imageDigest, syftVersion string, set map[string]string, ...) (*proto.SBOMMetadata, error)
- func (c *StorageClient) PutSBOMStream(ctx context.Context, imageDigest, syftVersion string, source proto.SBOMSource, ...) (*proto.PutSBOMResponse, error)
- func (c *StorageClient) SendContainerProfile(ctx context.Context, profile *v1beta1.ContainerProfile) (*proto.SendContainerProfileResponse, error)deprecated
- func (c *StorageClient) SendContainerProfileStream(ctx context.Context, profile *v1beta1.ContainerProfile) (*proto.SendContainerProfileResponse, error)
- func (c *StorageClient) SetAccessKey(value string)
- func (c *StorageClient) SetAccountID(value string)
- func (c *StorageClient) SetCluster(value string)
- type StorageClientOption
- type StorageClientOptions
Constants ¶
const ( DefaultGRPCPort = 50051 // Non-secure gRPC DefaultGRPCSPort = 50052 // Secure gRPC )
Default gRPC ports
const ChecksumAlgorithmSHA256Prefix = "sha256:"
ChecksumAlgorithmSHA256Prefix is the required prefix for every value carried in GetContainerProfileStreamChunkMetadata.checksum and GetContainerProfileStreamRequest.known_checksum: "sha256:<64 lowercase hex characters>". Tagging the algorithm costs nothing now and is the only thing that makes a future change of hash function a detectable format change instead of a silent semantic one — two differently-hashed values could otherwise coincidentally look like a match or a mismatch for the wrong reason.
This is the canonical, kubescape/backend-owned definition of the convention; other repositories producing or comparing these values (armosec/postgres-connector, armosec/cadashboardbe) are expected to depend on this constant rather than hardcoding the string. As of this change, no producer in this pipeline emits a prefixed value yet — GetContainerProfileStream will not stamp a checksum that lacks it (see maxStampedChecksumLength's sibling check), which degrades the optimization to inert rather than failing the fetch, exactly like an oversized checksum. Producers are expected to adopt the prefix in a follow-up change.
const ContainerProfileChecksumAnnotationKey = "backend.kubescape.io/container-profile-checksum"
ContainerProfileChecksumAnnotationKey is the ObjectMeta annotation under which GetContainerProfileStream stamps the server-reported content checksum of a fetched ContainerProfile, so callers can store it and present it back via WithProfileKnownChecksum on a later fetch.
STABLE CROSS-REPO CONTRACT: this exact string is read by consumers outside this repository (armosec/private-node-agent's storage adapter, which re-keys it into kubescape/node-agent's own vocabulary). Changing its value is a breaking change for those consumers even though the Go symbol stays the same — do not rename the value.
Variables ¶
var (
ErrAPINotPublic = errors.New("control api is not public")
)
var ErrProfileUnchanged = errors.New("container profile unchanged")
ErrProfileUnchanged is returned by GetContainerProfileStream when the caller supplied a known checksum via WithProfileKnownChecksum and the server reported that its stored ContainerProfile still matches it. No profile is returned: the caller must keep the copy it already holds. Match it with errors.Is.
Functions ¶
func GetCVEExceptionByDesignator ¶
func GetCVEExceptionByDesignator(ctx context.Context, backendURL, customerGUID string, designators *identifiers.PortalDesignator, headers map[string]string) ([]armotypes.VulnerabilityExceptionPolicy, error)
func GetCVEExceptionByRawQuery ¶ added in v0.0.21
func GetPostureReportUrl ¶
func GetSystemReportURL ¶
func MarshalSBOM ¶ added in v0.0.43
MarshalSBOM marshals a typed SBOMSyft to its proto wire bytes and returns a reader over them, ready for PutSBOM. The full marshaled blob is held in memory; for very large SBOMs callers may prefer to write pre-marshaled bytes to a temp file and pass an *os.File to PutSBOM.
func MockAPIServer ¶
func TestFrameworkFile ¶
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 GRPCConfig ¶ added in v0.0.33
GRPCConfig represents the parsed gRPC connection configuration
func ParseGRPCURL ¶ added in v0.0.33
func ParseGRPCURL(grpcURL string) (*GRPCConfig, error)
ParseGRPCURL parses a gRPC URL and returns the configuration
func (*GRPCConfig) String ¶ added in v0.0.33
func (c *GRPCConfig) String() string
String returns a string representation of the config
type HttpReportSender ¶ added in v0.0.3
type HttpReportSender struct {
// contains filtered or unexported fields
}
type HttpReportSenderMock ¶ added in v0.0.3
type HttpReportSenderMock struct {
}
type IHttpSender ¶ added in v0.0.3
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, opts ...RequestOption) (*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) GetControlsInputsWithContext ¶ added in v0.0.46
func (api *KSCloudAPI) GetControlsInputsWithContext(ctx context.Context, clusterName string, opts ...RequestOption) (map[string][]string, error)
GetControlsInputsWithContext returns the controls inputs configured in the account configuration with the provided context.
func (*KSCloudAPI) GetExceptions ¶
func (api *KSCloudAPI) GetExceptions(clusterName string) ([]PostureExceptionPolicy, error)
GetExceptions returns exception policies.
func (*KSCloudAPI) GetExceptionsWithContext ¶ added in v0.0.46
func (api *KSCloudAPI) GetExceptionsWithContext(ctx context.Context, clusterName string, opts ...RequestOption) ([]PostureExceptionPolicy, error)
GetExceptionsWithContext returns exception policies with the provided context.
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.
func (*KSCloudAPI) SubmitReportWithContext ¶ added in v0.0.48
func (api *KSCloudAPI) SubmitReportWithContext(ctx context.Context, report *PostureReport, opts ...RequestOption) (string, error)
SubmitReportWithContext uploads a posture report with the provided context.
Cancelling the context aborts the upload that is already in flight, instead of waiting for the client timeout.
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 ProfileOption ¶ added in v0.0.39
type ProfileOption func(*ProfileOptions)
ProfileOption allows to configure profile queries
func WithProfileCloudAccountIdentifier ¶ added in v0.0.39
func WithProfileCloudAccountIdentifier(cloudAccountIdentifier string) ProfileOption
WithProfileCloudAccountIdentifier sets the cloud account identifier for non-k8s scoped resources (e.g. AWS account ID, GCP project ID)
func WithProfileKnownChecksum ¶ added in v0.0.49
func WithProfileKnownChecksum(checksum string) ProfileOption
WithProfileKnownChecksum sets the content checksum of the profile the caller already holds. It is advisory: an empty value (the default) requests the body unconditionally, and a server that does not understand it streams the body as before. When the server recognises it and the checksums match, GetContainerProfileStream returns ErrProfileUnchanged instead of a profile. Only GetContainerProfileStream honours this option.
func WithProfileRegion ¶ added in v0.0.39
func WithProfileRegion(region string) ProfileOption
WithProfileRegion sets the region for non-k8s scoped resources
type ProfileOptions ¶ added in v0.0.39
ProfileOptions holds configuration for profile queries
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 WithContext ¶ added in v0.0.46
func WithContext(ctx context.Context) RequestOption
WithContext sets the context for the 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
type StorageClient ¶ added in v0.0.33
type StorageClient struct {
*StorageClientOptions
// contains filtered or unexported fields
}
StorageClient provides a gRPC client for the Kubescape storage server
func NewStorageClient ¶ added in v0.0.33
func NewStorageClient(grpcURL, accountID, accessKey, cluster string, opts ...StorageClientOption) (*StorageClient, error)
NewStorageClient creates a new StorageClient instance from a gRPC URL grpcURL is the full gRPC URL with scheme (e.g., "grpc://storage-server:50051" or "grpcs://storage.example.com:443") accountID is the customer GUID accessKey is the API access token cluster is the cluster name opts allow configuring optional parameters like hostType, hostID, timeout, etc.
func (*StorageClient) Close ¶ added in v0.0.33
func (c *StorageClient) Close() error
Close closes the gRPC connection
func (*StorageClient) Connect ¶ added in v0.0.33
func (c *StorageClient) Connect() error
Connect establishes a gRPC connection to the storage server
func (*StorageClient) GetAccessKey ¶ added in v0.0.33
func (c *StorageClient) GetAccessKey() string
GetAccessKey returns the API access key
func (*StorageClient) GetAccountID ¶ added in v0.0.33
func (c *StorageClient) GetAccountID() string
GetAccountID returns the customer account GUID
func (*StorageClient) GetAddress ¶ added in v0.0.33
func (c *StorageClient) GetAddress() string
GetAddress returns the storage server address
func (*StorageClient) GetApplicationProfile ¶ added in v0.0.33
func (c *StorageClient) GetApplicationProfile(ctx context.Context, namespace, name string, opts ...ProfileOption) (*legacyv1beta1.ApplicationProfile, error)
GetApplicationProfile retrieves an aggregated ApplicationProfile from the storage server For backward compatibility, region and cloudAccountIdentifier can be provided via ProfileOption Old way: GetApplicationProfile(ctx, "ns", "name") New way: GetApplicationProfile(ctx, "ns", "name", WithProfileRegion("us-east-1"), WithProfileCloudAccountIdentifier("123"))
func (*StorageClient) GetCluster ¶ added in v0.0.34
func (c *StorageClient) GetCluster() string
GetCluster returns the cluster name
func (*StorageClient) GetContainerProfile
deprecated
added in
v0.0.41
func (c *StorageClient) GetContainerProfile(ctx context.Context, namespace, name string, opts ...ProfileOption) (*v1beta1.ContainerProfile, error)
GetContainerProfile retrieves a ContainerProfile from the storage server.
Deprecated: use GetContainerProfileStream. The unary form goes through GetProfile, which is capped at gRPC's default 4 MiB message size; profiles with many or large entries can exceed this and fail on the wire. The streaming variant has no such bound.
func (*StorageClient) GetContainerProfileStream ¶ added in v0.0.43
func (c *StorageClient) GetContainerProfileStream(ctx context.Context, namespace, name string, opts ...ProfileOption) (*v1beta1.ContainerProfile, error)
GetContainerProfileStream is the streaming replacement for the ContainerProfile branch of GetProfile. Use whenever the profile may exceed the default 4 MiB unary gRPC message limit. The chunks are reassembled and the marshaled bytes are unmarshaled internally — the caller receives a typed *v1beta1.ContainerProfile just as with the existing GetContainerProfile wrapper.
func (*StorageClient) GetGRPCConfig ¶ added in v0.0.33
func (c *StorageClient) GetGRPCConfig() *GRPCConfig
GetGRPCConfig returns the parsed gRPC configuration (if created from URL)
func (*StorageClient) GetNetworkNeighborhood ¶ added in v0.0.33
func (c *StorageClient) GetNetworkNeighborhood(ctx context.Context, namespace, name string, opts ...ProfileOption) (*legacyv1beta1.NetworkNeighborhood, error)
GetNetworkNeighborhood retrieves an aggregated NetworkNeighborhood from the storage server For backward compatibility, region and cloudAccountIdentifier can be provided via ProfileOption Old way: GetNetworkNeighborhood(ctx, "ns", "name") New way: GetNetworkNeighborhood(ctx, "ns", "name", WithProfileRegion("us-east-1"), WithProfileCloudAccountIdentifier("123"))
func (*StorageClient) GetSBOMStream ¶ added in v0.0.43
func (c *StorageClient) GetSBOMStream(ctx context.Context, imageDigest, syftVersion string, metadataOnly bool) (*proto.GetSBOMChunkMetadata, io.ReadCloser, error)
GetSBOMStream probes for or fetches an SBOM by (image_digest, syft_version).
Contract:
- Server-reported failure → returns a non-nil error along with the metadata. Caller's `if err != nil { ... }` is enough; no need to inspect metadata.Success separately.
- Row does not exist OR metadataOnly is true → returns (md, nil, nil). Caller consults `md.Exists` to distinguish probe-hit from miss. On a hit, md.SbomMetadata carries the indexed view including the SBOM's annotations (md.SbomMetadata.Annotations), so callers that only need to branch on annotations can stay on the metadata_only path instead of downloading and unmarshaling the full blob.
- Row exists and metadataOnly is false → returns (md, reader, nil). The reader streams the marshaled SBOMSyft proto bytes; use UnmarshalSBOM (or read into your own buffer) to reconstruct the typed object. The caller MUST Close the reader to release the underlying gRPC stream.
The underlying RPC is server-streaming; the caller never needs to know the response size in advance.
func (*StorageClient) IsConnected ¶ added in v0.0.33
func (c *StorageClient) IsConnected() bool
IsConnected returns true if the client is connected to the server
func (*StorageClient) ListApplicationProfiles ¶ added in v0.0.33
func (c *StorageClient) ListApplicationProfiles(ctx context.Context, namespace string, limit int64, cont string, opts ...ProfileOption) (*legacyv1beta1.ApplicationProfileList, error)
ListApplicationProfiles lists all ApplicationProfiles in a namespace (returns metadata only, nil Spec) For backward compatibility, region and cloudAccountIdentifier can be provided via ProfileOption Old way: ListApplicationProfiles(ctx, "ns", 100, "") New way: ListApplicationProfiles(ctx, "ns", 100, "", WithProfileRegion("us-east-1"), WithProfileCloudAccountIdentifier("123"))
func (*StorageClient) ListNetworkNeighborhoods ¶ added in v0.0.33
func (c *StorageClient) ListNetworkNeighborhoods(ctx context.Context, namespace string, limit int64, cont string, opts ...ProfileOption) (*legacyv1beta1.NetworkNeighborhoodList, error)
ListNetworkNeighborhoods lists all NetworkNeighborhoods in a namespace (returns metadata only, nil Spec) For backward compatibility, region and cloudAccountIdentifier can be provided via ProfileOption Old way: ListNetworkNeighborhoods(ctx, "ns", 100, "") New way: ListNetworkNeighborhoods(ctx, "ns", 100, "", WithProfileRegion("us-east-1"), WithProfileCloudAccountIdentifier("123"))
func (*StorageClient) PatchSBOMAnnotations ¶ added in v0.0.52
func (c *StorageClient) PatchSBOMAnnotations(ctx context.Context, imageDigest, syftVersion string, set map[string]string, del []string) (*proto.SBOMMetadata, error)
PatchSBOMAnnotations updates only the annotations of an existing SBOM row, atomically and without rewriting the S3 blob. Merge-patch semantics: keys in `set` are added or overwritten, keys in `del` are removed, all other annotations are left untouched. Returns the post-merge SBOMMetadata on success.
func (*StorageClient) PutSBOMStream ¶ added in v0.0.43
func (c *StorageClient) PutSBOMStream(ctx context.Context, imageDigest, syftVersion string, source proto.SBOMSource, r io.Reader) (*proto.PutSBOMResponse, error)
PutSBOMStream uploads an SBOM identified by (image_digest, syft_version, source). The payload is the marshaled SBOMSyft proto, read from r and sent to the server in chunks of sbomStreamChunkSize. Callers with a typed *v1beta1.SBOMSyft should use MarshalSBOM to obtain r.
The underlying RPC is client-streaming; the caller never needs to know the payload size in advance.
func (*StorageClient) SendContainerProfile
deprecated
added in
v0.0.33
func (c *StorageClient) SendContainerProfile(ctx context.Context, profile *v1beta1.ContainerProfile) (*proto.SendContainerProfileResponse, error)
SendContainerProfile sends a container profile to the storage server.
Deprecated: use SendContainerProfileStream. The unary form is silently capped at gRPC's default 4 MiB message size; profiles with many or large entries can exceed this and fail on the wire. The streaming variant has no such bound.
func (*StorageClient) SendContainerProfileStream ¶ added in v0.0.43
func (c *StorageClient) SendContainerProfileStream(ctx context.Context, profile *v1beta1.ContainerProfile) (*proto.SendContainerProfileResponse, error)
SendContainerProfileStream is the streaming replacement for SendContainerProfile. The profile is marshaled and sent to the server in chunks of sbomStreamChunkSize. Use this whenever you might write a large container profile (many entries, long stack traces, long paths).
func (*StorageClient) SetAccessKey ¶ added in v0.0.33
func (c *StorageClient) SetAccessKey(value string)
SetAccessKey sets the API access key
func (*StorageClient) SetAccountID ¶ added in v0.0.33
func (c *StorageClient) SetAccountID(value string)
SetAccountID sets the customer account GUID
func (*StorageClient) SetCluster ¶ added in v0.0.34
func (c *StorageClient) SetCluster(value string)
SetCluster sets the cluster name
type StorageClientOption ¶ added in v0.0.33
type StorageClientOption func(*StorageClientOptions)
StorageClientOption allows to configure the behavior of the Storage client
func WithCallTimeout ¶ added in v0.0.33
func WithCallTimeout(timeout time.Duration) StorageClientOption
WithCallTimeout sets the timeout for individual gRPC calls A value of 0 means no timeout. The default is 30 seconds.
func WithHostID ¶ added in v0.0.39
func WithHostID(hostID string) StorageClientOption
WithHostID sets the host ID (e.g., EC2 instance ID) Required for non-cluster-based host types
func WithHostType ¶ added in v0.0.39
func WithHostType(hostType string) StorageClientOption
WithHostType sets the host type (e.g., "kubernetes", "ec2", "ecs") If not set, defaults to "kubernetes" on the server side
func WithStorageTrace ¶ added in v0.0.33
func WithStorageTrace(enabled bool) StorageClientOption
WithStorageTrace toggles request/response tracing for debugging
type StorageClientOptions ¶ added in v0.0.33
type StorageClientOptions struct {
// contains filtered or unexported fields
}
StorageClientOptions holds all the configurable parts of the Storage client