audit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Ecosystem  string
	Name       string
	Version    string
	Source     string
	SourceType SourceType
}

type ExcludeSet

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

ExcludeSet holds package suppressions loaded from an exclude file. Any audited dependency that matches an entry is dropped from findings — used to silence known false positives. Entries are "ecosystem:name"; an ecosystem of "*" matches any ecosystem.

func LoadExcludeFile

func LoadExcludeFile(path string) (ExcludeSet, error)

LoadExcludeFile reads newline-separated "ecosystem:name" entries from path. Blank lines and lines beginning with '#' are ignored. An ecosystem of "*" matches any ecosystem. The ecosystem/name split is on the first colon, so Maven coordinates ("Maven:group:artifact") are preserved. Malformed lines return an error citing the line number.

func (ExcludeSet) Empty

func (s ExcludeSet) Empty() bool

Empty reports whether the set has no entries.

func (ExcludeSet) Has

func (s ExcludeSet) Has(ecosystem, name string) bool

Has reports whether the given ecosystem/name pair is excluded.

type Finding

type Finding struct {
	Verdict    string    `json:"verdict"`
	Ecosystem  string    `json:"ecosystem"`
	Name       string    `json:"name"`
	Version    string    `json:"version"`
	IDs        []string  `json:"ids"`
	Summary    string    `json:"summary,omitempty"`
	Published  time.Time `json:"published_at,omitempty"`
	ModifiedAt time.Time `json:"modified_at,omitempty"`
	Source     string    `json:"source,omitempty"`
	SourceType string    `json:"source_type,omitempty"`
	Lockfile   string    `json:"lockfile,omitempty"`
	ProjectDir string    `json:"project_dir,omitempty"`
	ProjectURL string    `json:"project_url,omitempty"`
	PackageURL string    `json:"registry_url,omitempty"`
}

type GitHubOptions

type GitHubOptions struct {
	Client   *github.Client
	CacheDir string
}

GitHubOptions configures optional GitHub SBOM audit inputs.

type Lockfile

type Lockfile struct {
	Path         string `json:"path"`
	Type         string `json:"type,omitempty"`
	Ecosystem    string `json:"ecosystem"`
	Dependencies int    `json:"dependencies"`
}

type Options

type Options struct {
	Progress     *Progress
	GitHub       *GitHubOptions
	DisplayPaths []string // optional user-facing targets (e.g. org URL vs expanded repos)

	// Exclude suppresses matched packages from findings (known false
	// positives). Excluded matches are silently counted as clean.
	Exclude ExcludeSet

	// SBOMExport, when set, writes an SBOM of the audited dependencies to this
	// path. SBOMFormat is optional ("cyclonedx" default, or "spdx").
	SBOMExport      string
	SBOMFormat      string
	SBOMToolVersion string
}

type Progress

type Progress struct {
	OnDiscover   func(found int, currentPath string)
	OnDiscovered func(lockfileCount int, root string)
	OnLockfile   func(index, total int, path string, depCount int)
	OnSource     func(index, total int, path string, sourceType SourceType, depCount int)
	OnIndex      func(loaded, total int)
	OnQuery      func(checked, total int, lockfile string)
	OnFinding    func(Finding)
	OnStatus     func(msg string)
	OnComplete   func()
}

type Result

type Result struct {
	Paths            []string   `json:"paths"`
	Lockfiles        []Lockfile `json:"lockfiles"`
	Dependencies     int        `json:"dependencies"`
	Summary          Summary    `json:"summary"`
	Findings         []Finding  `json:"findings"`
	FindingsStreamed bool       `json:"-"`
	Mode             string     `json:"mode,omitempty"`
	DurationMS       int64      `json:"duration_ms,omitempty"`
	SBOMPath         string     `json:"sbom_path,omitempty"`
}

type Service

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

func NewService

func NewService(provider intel.Provider, reg *registry.Client, cacheDir string) *Service

func (*Service) Audit

func (s *Service) Audit(ctx context.Context, paths []string) (*Result, error)

func (*Service) AuditWithOptions

func (s *Service) AuditWithOptions(ctx context.Context, paths []string, opts Options) (*Result, error)

type SourceType

type SourceType string
const (
	SourceTypeLockfile SourceType = "lockfile"
	SourceTypeSBOM     SourceType = "sbom"
)

type Summary

type Summary struct {
	Lockfiles           int `json:"lockfiles"`
	Total               int `json:"total"`
	Malicious           int `json:"malicious"`
	Quarantined         int `json:"quarantined,omitempty"`
	Suspicious          int `json:"suspicious"`
	Clean               int `json:"clean"`
	SkippedPlaceholders int `json:"skipped_placeholders,omitempty"`
}

Jump to

Keyboard shortcuts

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