configaudit

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 35 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CargoReadReason added in v1.18.0

func CargoReadReason(err error, path string, volume func(string) bool) string

CargoReadReason maps a guarded-read failure to a Cargo reason code, separating a skipped network volume from a protected directory.

func GoPathKey added in v1.18.0

func GoPathKey(goos, p string) string

GoPathKey is p as the target's filesystem compares names: Windows and macOS fold case by default, Linux does not. Module paths never go through it. ponytail: conflates names on a case-sensitive APFS volume; probe the volume if that matters.

func GoProtection added in v1.18.0

func GoProtection(home string, includeNetworkVolumes *bool) (protected func(string) string, volume func(string) bool)

GoProtection builds the Go collector's guards. Protected directories stay excluded whatever another scanner's include_tcc_protected says, and match case-insensitively because tcc compares bytes while APFS folds case by default. volume matches only the skipped network volumes, which even the exact default-file exception may not enter.

func GoReadReason added in v1.18.0

func GoReadReason(err error) string

GoReadReason maps a guarded-read failure to a Go reason code. A guard's own refusal already speaks that vocabulary.

func GoSourceID added in v1.18.0

func GoSourceID(identity, kind, path string) string

GoSourceID is the stable source identity shared by both Go sections: sha256 of the canonical JSON tuple [identity, kind, clean path].

func GoWithinRoots added in v1.18.0

func GoWithinRoots(goos, path string, roots []string) bool

GoWithinRoots reports whether path is one of roots or below one, compared as goos's filesystem compares names.

func RubyGemName added in v1.18.0

func RubyGemName(s string) bool

RubyGemName is the bounded package-name grammar, with at least one letter.

func RubyToken added in v1.18.0

func RubyToken(s string) bool

RubyToken bounds artifact platforms and group/platform labels.

func SanitizeCargoURL added in v1.18.0

func SanitizeCargoURL(raw string) (string, bool)

SanitizeCargoURL strips userinfo, query and fragment from a URL; anything that still carries an '@' is redacted whole.

func SanitizeComposerURL added in v1.18.0

func SanitizeComposerURL(raw string) (string, bool)

SanitizeComposerURL parses the entire URL, never whitespace-split fragments. Local Windows paths are checked before URL parsing so drives are not schemes.

func SanitizeRubyURL added in v1.18.0

func SanitizeRubyURL(raw string) (string, bool)

SanitizeRubyURL is the shared whole-URL redactor, except that SCP-like Git remotes are never rewritten to an inequivalent ssh:// URI.

func TrustedPipUserPaths added in v1.17.0

func TrustedPipUserPaths(exec executor.Executor, home string) []string

TrustedPipUserPaths returns the static home-confined pip user paths without locating or executing a package manager.

Types

type BunDetector added in v1.12.0

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

BunDetector audits bun: bunfig.toml at user + XDG + project scopes, plus any .npmrc bun would read as an auth side-channel.

func NewBunDetector added in v1.12.0

func NewBunDetector(exec executor.Executor) *BunDetector

NewBunDetector returns a detector with platform-specific hooks wired in.

func (*BunDetector) Detect added in v1.12.0

func (d *BunDetector) Detect(ctx context.Context, searchDirs []string, loggedInUser *user.User) model.BunAudit

Detect runs the full bun audit.

func (*BunDetector) WithLogger added in v1.14.0

func (d *BunDetector) WithLogger(log *progress.Logger) *BunDetector

WithLogger injects a logger (used to surface exec fallbacks when metadata version resolution misses). Chainable, like WithSkipper.

func (*BunDetector) WithSkipper added in v1.12.0

func (d *BunDetector) WithSkipper(s *tcc.Skipper) *BunDetector

WithSkipper attaches a TCC skipper so discovery skips macOS-protected dirs.

type CargoConfigDetector added in v1.18.0

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

CargoConfigDetector audits Cargo's configuration sources without running Cargo. It must be built with the raw executor: UserAwareExecutor.Getenv sources a login shell for some keys.

func NewCargoConfigDetector added in v1.18.0

func NewCargoConfigDetector(exec executor.Executor) *CargoConfigDetector

func (*CargoConfigDetector) Detect added in v1.18.0

Detect returns the audit and the snapshot inventory uses.

type CargoConfigScope added in v1.18.0

type CargoConfigScope struct {
	Username string   // resolved developer identity, part of every source ID
	Home     string   // from the OS user record
	Roots    []string // approved scope for ancestor .cargo probes
	// Protected returns a reason code for a path that must not be touched.
	Protected func(path string) string
	// Volume reports a skipped network volume.
	Volume func(path string) bool
	// ProcessVerified means this process runs as the developer, so its own
	// environment is an observed context for that developer.
	ProcessVerified bool
	// CargoHome is the effective Cargo home; empty when it is unresolved.
	CargoHome string
	// Contexts are the directories Cargo would be invoked in.
	Contexts []CargoContextDir
	// RegistryNames are registry aliases named by manifests, whose process
	// environment keys are probed.
	RegistryNames []string
}

CargoConfigScope is what the Cargo config audit may read, decided by the caller from the resolved developer identity.

type CargoConfigSnapshot added in v1.18.0

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

CargoConfigSnapshot is the sanitized view inventory uses: per-context registry and lockfile values plus configured roots. Token values are never held.

func (CargoConfigSnapshot) DirectorySources added in v1.18.0

func (s CargoConfigSnapshot) DirectorySources() []string

DirectorySources are the resolved source.<name>.directory roots.

func (CargoConfigSnapshot) InstallRoots added in v1.18.0

func (s CargoConfigSnapshot) InstallRoots() []string

InstallRoots are the resolved install.root values and an absolute CARGO_INSTALL_ROOT.

func (CargoConfigSnapshot) LocalPaths added in v1.18.0

func (s CargoConfigSnapshot) LocalPaths() []string

LocalPaths are package directories named by config paths and patch entries.

func (CargoConfigSnapshot) LocalRegistries added in v1.18.0

func (s CargoConfigSnapshot) LocalRegistries() []string

LocalRegistries are the resolved source.<name>.local-registry roots.

func (CargoConfigSnapshot) LockfilePath added in v1.18.0

func (s CargoConfigSnapshot) LockfilePath(contextDir string) (path string, unresolved bool)

LockfilePath is the resolver.lockfile-path selected in contextDir. path is empty for the default location; unresolved means a value or a source could not be established, so the returned path is not known to be the one Cargo uses.

func (CargoConfigSnapshot) RegistryIndex added in v1.18.0

func (s CargoConfigSnapshot) RegistryIndex(contextDir, alias string) (string, bool)

RegistryIndex returns the index URL a context maps alias to; ok is false when no readable source defines it, or when a config file of the context was not read and so may redefine it.

type CargoContextDir added in v1.18.0

type CargoContextDir struct{ Project, Workspace string }

CargoContextDir is one invocation directory and the workspace root it belongs to, if any.

type ComposerConfigDetector added in v1.18.0

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

func NewComposerConfigDetector added in v1.18.0

func NewComposerConfigDetector(exec executor.Executor) *ComposerConfigDetector

func (*ComposerConfigDetector) Detect added in v1.18.0

type ComposerConfigScope added in v1.18.0

type ComposerConfigScope struct {
	Username, Home  string
	Protected       func(string) string
	Volume          func(string) bool
	ProcessVerified bool
}

ComposerConfigScope comes from the resolved developer, never a login shell.

type ComposerConfigSnapshot added in v1.18.0

type ComposerConfigSnapshot struct {
	Homes                   []string
	Caches                  []string
	Home, AlternateManifest string
	SelectionPartial        bool
	// contains filtered or unexported fields
}

ComposerConfigSnapshot accumulates observed config as manifests are discovered. This permits vendor pruning before descent without a second config-file walk.

func (*ComposerConfigSnapshot) Finish added in v1.18.0

func (*ComposerConfigSnapshot) KeepProjects added in v1.18.0

func (a *ComposerConfigSnapshot) KeepProjects(paths map[string]bool)

KeepProjects drops candidates later recognized as installed vendor packages. Discovery order must not turn a dependency's config into a root audit.

func (*ComposerConfigSnapshot) Project added in v1.18.0

func (a *ComposerConfigSnapshot) Project(manifest string, data []byte, status string, reasons []string, globalHome string) ComposerPaths

Project uses the manifest bytes already read by inventory. Inactive homes get their own global config, never another home's settings.

type ComposerPaths added in v1.18.0

type ComposerPaths struct {
	Vendor, Cache string
	Partial       bool
}

ComposerPaths contains only locations needed for inventory discovery.

type GoEnvDetector added in v1.18.0

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

GoEnvDetector audits Go's configuration sources without running Go. It must be built with the raw executor: UserAwareExecutor.Getenv sources a login shell for some keys.

func NewGoEnvDetector added in v1.18.0

func NewGoEnvDetector(exec executor.Executor) *GoEnvDetector

func (*GoEnvDetector) Detect added in v1.18.0

Detect returns the audit and the snapshot inventory uses to resolve roots.

type GoEnvScope added in v1.18.0

type GoEnvScope struct {
	Username string   // resolved developer identity, part of every source ID
	Home     string   // from the OS user record
	Roots    []string // approved filesystem scope: home plus configured search roots
	// Protected returns a reason code for a path that must not be touched, "" to
	// allow it. It must stay on regardless of other scanners' TCC opt-ins.
	Protected func(path string) string
	// Volume reports a skipped network volume, which even the exact default-file
	// exception may not enter.
	Volume func(path string) bool
	// ProcessVerified means this process runs as the developer, so its own
	// environment is an observed context for that developer.
	ProcessVerified bool
}

GoEnvScope is what the Go config audit may read, all decided by the caller from the resolved developer identity rather than from the process.

type GoEnvSnapshot added in v1.18.0

type GoEnvSnapshot struct {

	// RedirectUnknown is set when the user env file could not be established,
	// so a default root may not be the one Go uses.
	RedirectUnknown bool
	// contains filtered or unexported fields
}

GoEnvSnapshot carries effective raw values, by Go precedence, from the sources the audit could read. It stays in memory: values may hold secrets.

func (GoEnvSnapshot) BinRoot added in v1.18.0

func (s GoEnvSnapshot) BinRoot(home string) (string, bool)

BinRoot is GOBIN, else the first GOPATH entry's bin.

func (GoEnvSnapshot) DefaultModCacheRoot added in v1.18.0

func (s GoEnvSnapshot) DefaultModCacheRoot(home string) (string, bool)

DefaultModCacheRoot is gopath0/pkg/mod, which a project walk skips even when GOMODCACHE points elsewhere.

func (GoEnvSnapshot) ModCacheRoot added in v1.18.0

func (s GoEnvSnapshot) ModCacheRoot(home string) (string, bool)

ModCacheRoot is GOMODCACHE, else the first GOPATH entry's pkg/mod. ok is false for a relative value, which Go itself rejects.

func (GoEnvSnapshot) Modfile added in v1.18.0

func (s GoEnvSnapshot) Modfile() (modfile string, ok bool)

Modfile is the last -modfile in the effective GOFLAGS, as written; ok is false when GOFLAGS cannot be split as Go would.

type NPMRCDetector

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

NPMRCDetector audits npm configuration: discovers all .npmrc files, parses them, captures the merged effective view, and surfaces relevant env vars.

The detector intentionally keeps file metadata collection (owner, mode, hashes) and git-tracking checks pluggable so unit tests don't need real syscalls or a git binary.

func NewNPMRCDetector

func NewNPMRCDetector(exec executor.Executor) *NPMRCDetector

NewNPMRCDetector returns a detector with default platform-specific metadata helpers wired in.

func (*NPMRCDetector) Detect

func (d *NPMRCDetector) Detect(ctx context.Context, searchDirs []string, loggedInUser *user.User) model.NPMRCAudit

Detect runs the full audit. searchDirs are the dirs to walk for project- level .npmrc files (typically the user's $HOME plus any extra dirs configured by the operator). loggedInUser is the username whose ~/.npmrc we resolve for the user-scope file.

func (*NPMRCDetector) WithSkipper added in v1.11.4

func (d *NPMRCDetector) WithSkipper(s *tcc.Skipper) *NPMRCDetector

WithSkipper attaches a TCC skipper so .npmrc discovery skips macOS-protected directories. A nil skipper is a no-op. Returns the detector for chaining.

type NuGetConfigDetector added in v1.18.0

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

func NewNuGetConfigDetector added in v1.18.0

func NewNuGetConfigDetector(exec executor.Executor) *NuGetConfigDetector

func (*NuGetConfigDetector) Detect added in v1.18.0

type NuGetConfigScope added in v1.18.0

type NuGetConfigScope struct {
	Username, Home  string
	Roots           []string // approved scope for ancestor NuGet.Config probes
	Protected       func(string) string
	Volume          func(string) bool
	ProcessVerified bool
}

NuGetConfigScope comes from the resolved developer, never a login shell.

type NuGetConfigSnapshot added in v1.18.0

type NuGetConfigSnapshot struct {
	GlobalPackages string   // effective expanded-package root for the user context
	CLIHome        string   // profile root for tools and templates
	PackageRoots   []string // every configured fallback, custom and legacy root
	// contains filtered or unexported fields
}

NuGetConfigSnapshot accumulates observed NuGet configuration as the inventory discovers projects and restore graphs.

func (*NuGetConfigSnapshot) Ambient added in v1.18.0

func (a *NuGetConfigSnapshot) Ambient(dir string, leading ...*model.NuGetConfigFile) NuGetPaths

Ambient records the config sources NuGet would load for a project in dir: the leading records (process, project files), the directory chain inside approved roots, then user and machine configuration.

func (*NuGetConfigSnapshot) Finish added in v1.18.0

func (*NuGetConfigSnapshot) ProjectFile added in v1.18.0

func (a *NuGetConfigSnapshot) ProjectFile(path, status string, reasons []string, props map[string]string, projectDir string) *model.NuGetConfigFile

ProjectFile records the allowlisted literal properties of an MSBuild file already read by inventory. Property values that need evaluation are skipped. projectDir is the consuming project; a shared Directory.*.props/targets passes "" and leaves project-relative paths to each consumer's record.

func (*NuGetConfigSnapshot) Restore added in v1.18.0

func (a *NuGetConfigSnapshot) Restore(assets, project string, paths []string)

Restore records the ordered config input one assets file recorded. Paths outside approved roots get a targeted read only.

type NuGetPaths added in v1.18.0

type NuGetPaths struct {
	Repository string // legacy repositoryPath, resolved
	Partial    bool
}

NuGetPaths are the locations an ambient context selects for inventory.

type PipConfigDetector

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

PipConfigDetector performs the read-only pip config audit.

func NewPipConfigDetector

func NewPipConfigDetector(exec executor.Executor) *PipConfigDetector

NewPipConfigDetector wires platform-specific hooks; tests override.

func (*PipConfigDetector) Detect

func (d *PipConfigDetector) Detect(ctx context.Context, loggedInUser *user.User) model.PipAudit

Detect runs the full audit.

loggedInUser drives where we look for the user's pip config when running as root (launchd / systemd context). Pass nil when the agent is already running as the user.

type PipUserConfigDiscovery added in v1.17.0

type PipUserConfigDiscovery struct {
	AllowedUserPaths  []string
	ExistingUserPaths []string
	Invocations       [][]string
}

PipUserConfigDiscovery is the trusted user-tier path and invocation set used by package policy enforcement. Paths are resolved beneath the interactive user's home; pip output can only confirm entries already in that allowlist.

func DiscoverPipUserConfig added in v1.17.0

func DiscoverPipUserConfig(ctx context.Context, exec executor.Executor) (PipUserConfigDiscovery, error)

DiscoverPipUserConfig discovers every supported pip invocation and only documented user-tier configuration paths for the resolved interactive user.

type PnpmDetector added in v1.12.0

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

PnpmDetector audits pnpm configuration. pnpm reads the same .npmrc syntax as npm; only the effective view (different key set, no source attribution) and env-var list diverge.

func NewPnpmDetector added in v1.12.0

func NewPnpmDetector(exec executor.Executor) *PnpmDetector

NewPnpmDetector returns a detector with platform-specific hooks wired in.

func (*PnpmDetector) Detect added in v1.12.0

func (d *PnpmDetector) Detect(ctx context.Context, searchDirs []string, loggedInUser *user.User) model.PnpmAudit

Detect runs the full pnpm audit.

func (*PnpmDetector) WithSkipper added in v1.12.0

func (d *PnpmDetector) WithSkipper(s *tcc.Skipper) *PnpmDetector

WithSkipper attaches a TCC skipper so .npmrc discovery skips macOS-protected directories. nil is a no-op. Returns the detector for chaining.

type RubyConfigDetector added in v1.18.0

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

func NewRubyConfigDetector added in v1.18.0

func NewRubyConfigDetector(exec executor.Executor) *RubyConfigDetector

func (*RubyConfigDetector) Detect added in v1.18.0

type RubyConfigScope added in v1.18.0

type RubyConfigScope struct {
	Username, Home  string
	Protected       func(string) string
	Volume          func(string) bool
	ProcessVerified bool
}

RubyConfigScope comes from the resolved developer, never a login shell.

type RubyConfigSnapshot added in v1.18.0

type RubyConfigSnapshot struct {
	GemHomes              []string
	UserCache, UserPlugin string
	Gemfile               string
	// contains filtered or unexported fields
}

RubyConfigSnapshot accumulates RubyGems and Bundler observations as inventory discovers interpreter prefixes and projects.

func (*RubyConfigSnapshot) ContentGuard added in v1.18.0

func (a *RubyConfigSnapshot) ContentGuard(path string) string

ContentGuard keeps credential files existence-only, including redirected reads.

func (*RubyConfigSnapshot) Env added in v1.18.0

func (a *RubyConfigSnapshot) Env(key string) string

Env returns a verified developer-process root selector as a safe absolute path, or "" when unset, unverified or unsafe.

func (*RubyConfigSnapshot) Finish added in v1.18.0

func (*RubyConfigSnapshot) Prefixes added in v1.18.0

func (a *RubyConfigSnapshot) Prefixes(prefixes, incomplete []string)

Prefixes observes each discovered interpreter's compiled sysconfdir gemrc. These are bounded candidates, not a claim that every runtime uses each one. An incomplete prefix search may have omitted a file, so the audit and the RubyGems context are partial; files that were read keep their settings.

func (*RubyConfigSnapshot) Project added in v1.18.0

Project observes one Bundler project's manifests and local config and selects installation leads with Bundler's Settings#path rule: the first level (local, process, global) holding path, path.system or disable_shared_gems decides; deployment applies only when none does.

type RubyManifest added in v1.18.0

type RubyManifest struct {
	Path, Status string
	Reasons      []string
	Sources      []RubyManifestSource
	Lockfile     string
	NoLockfile   bool
}

RubyManifest is a manifest already read by inventory, so this package never parses Ruby. Status uses the file-status vocabulary.

type RubyManifestSource added in v1.18.0

type RubyManifestSource struct{ Type, URL, Cooldown string }

RubyManifestSource is one literal Gemfile source. URL is raw and stays in memory; only its sanitized display is serialized.

type RubyProject added in v1.18.0

type RubyProject struct {
	Dir       string
	Manifests []RubyManifest
}

RubyProject is one Bundler project: its root manifest first, then manifests it evaluates.

type RubyProjectLeads added in v1.18.0

type RubyProjectLeads struct {
	Path, CachePath, AppConfig, Lockfile string
	Partial                              bool
}

RubyProjectLeads are discovery locations, not a claimed effective config. An empty Path means Bundler uses shared gem homes found independently.

type YarnDetector added in v1.12.0

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

YarnDetector audits both yarn flavors. Both file shapes are always discovered — a v1 binary with a berry file (or vice versa) is itself a signal the renderer surfaces.

func NewYarnDetector added in v1.12.0

func NewYarnDetector(exec executor.Executor) *YarnDetector

NewYarnDetector returns a detector with platform-specific hooks wired in.

func (*YarnDetector) Detect added in v1.12.0

func (d *YarnDetector) Detect(ctx context.Context, searchDirs []string, loggedInUser *user.User) model.YarnAudit

Detect runs the full yarn audit.

func (*YarnDetector) WithLogger added in v1.14.0

func (d *YarnDetector) WithLogger(log *progress.Logger) *YarnDetector

WithLogger injects a logger (used to surface exec fallbacks when metadata version resolution misses). Chainable, like WithSkipper.

func (*YarnDetector) WithSkipper added in v1.12.0

func (d *YarnDetector) WithSkipper(s *tcc.Skipper) *YarnDetector

WithSkipper attaches a TCC skipper so discovery skips macOS-protected dirs.

Jump to

Keyboard shortcuts

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