gcpasset

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ValidateScope(scope string) error

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

func New(ctx context.Context, scope string) (*Client, error)

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

func (c *Client) Close() error

Close releases the underlying connection.

func (*Client) LabelsFor

func (c *Client) LabelsFor(ctx context.Context, resourceName, displayName string) (*Labels, error)

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.

type Labels

type Labels struct {
	// Name is the resource's full name, as Security Command Center and Asset
	// Inventory both spell it.
	Name string
	// Labels are the resource's own labels.
	Labels map[string]string
}

Labels are one resource's labels, plus enough identity to log about it.

Jump to

Keyboard shortcuts

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