Documentation
¶
Overview ¶
Package gcpasset reads a Google Cloud resource's labels through Cloud Asset Inventory.
The labels patchy needs are not in the notification that brought the finding. A Security Command Center message describes the resource (name, type, project) but carries none of its labels, so ownership is looked up separately. That read-only lookup is the only reason context-controller holds a Google Cloud credential.
The client is one struct with one lookup method, so the enhancer that uses it can be tested against a hand-written fake, and neither the enhancer nor anything in pkg/ names a Google Cloud type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("resource not found in cloud asset inventory")
ErrNotFound reports that Cloud Asset Inventory has no record of the resource. It is a permanent answer: the resource may have been deleted since the finding was raised, or sit outside the configured scope. Callers do not retry it.
Functions ¶
func ValidateScope ¶
ValidateScope reports whether scope is one Asset Inventory accepts. It runs at construction so a typo fails at startup rather than on the first finding.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads resource labels from Cloud Asset Inventory. This package declares no interface for it: the consumer declares the one-method interface it needs, and Client satisfies it.
func New ¶
New builds a client searching within scope, which must name an organization, folder, or project ("organizations/123", "folders/456", "projects/foo"). Credentials come from Application Default Credentials. In cluster that means workload identity, so no key file exists anywhere.
func (*Client) LabelsFor ¶
LabelsFor returns the labels of one resource, named as Security Command Center names it. When the exact name misses and the caller supplied a display name, one fallback search by display name runs. It covers sources (Wiz) whose identifiers cannot always be rewritten into Asset Inventory's form. The fallback requires a unique hit: two resources with the same display name are ambiguous, and guessing an owner would be worse than handing the finding to a human.
ErrNotFound is final; every other error is worth retrying. The enhancer chain uses that to decide between advancing a finding and holding it for another try.