azureinv

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: 9 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 azureinv reads an Azure resource's tags from Azure Resource Graph.

The tags patchy needs are not reliably in the payload that brought the finding. A scanner delivery describes the resource (ARM resource ID, type, subscription), but its tags are optional, point-in-time extras, so ownership is looked up separately. Unlike AWS there is no backend to choose: Resource Graph is free, always on, and tenant-wide. One KQL lookup by resource ID answers for every subscription the caller's identity can read, optionally narrowed to a management group.

Credentials come from the Azure default chain. In-cluster that means Microsoft Entra Workload ID or workload identity federation, so no key material exists anywhere. This read-only lookup is the only reason context-controller talks to Azure.

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 an Azure SDK type.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource not found in azure inventory")

ErrNotFound reports that the inventory has no record of the resource. It is a permanent answer: the resource may have been deleted since the finding was raised, live in a subscription outside the configured scope, or not be indexed yet. Callers do not retry it.

Functions

This section is empty.

Types

type Client

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

Client reads resource tags from Azure Resource Graph. 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, cfg Config) (*Client, error)

New builds a client and verifies Resource Graph answers at all. A broken identity binding or a management group the identity cannot read fails here, at client build (a retryable hold), rather than silently per finding. Credentials come from the Azure default chain (Microsoft Entra Workload ID on AKS, workload identity federation elsewhere), so no key material exists anywhere.

func (*Client) Close

func (c *Client) Close() error

Close releases nothing, since the SDK client holds no connection of its own. It exists so the enhancer can treat every cloud client alike.

func (*Client) TagsFor

func (c *Client) TagsFor(ctx context.Context, id string) (*Tags, error)

TagsFor returns the tags of one resource, named by its ARM resource ID. The ID is an exact identifier (compared case-insensitively, as ARM does), so there is no fallback search: a miss means the resource is unrecorded, not misspelled.

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 Config

type Config struct {
	// ManagementGroup narrows the query to one management group; empty means
	// every subscription the ambient identity can read (the tenant, in
	// practice).
	ManagementGroup string
}

Config bounds the Resource Graph query scope.

type Tags

type Tags struct {
	// Name is the resource's own name when the inventory reports one, else
	// its ARM resource ID.
	Name string
	// Tags are the resource's tags.
	Tags map[string]string
}

Tags are one resource's tags, 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