Documentation
¶
Overview ¶
Package settings loads a project's scanoss.json (or settings.json): the BOM rules (include/identify/ignore/remove/replace) and the skip rules (patterns and size bounds per operation). Resolve locates and parses the file, and ScanFilter maps the skip rules onto pkg/filter's Options.
Index ¶
Constants ¶
const ( OperationScanning = "scanning" OperationFingerprinting = "fingerprinting" OperationDependencies = "dependencies" )
Operation identifies which set of skip rules applies. Mirrors the operations enumerated in the scanoss.json settings schema.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
Detect looks for a settings file in the given directory. It checks for both "scanoss.json" and "settings.json" (in that order). Returns the path to the first found file, or empty string if none found.
func FormatSBOMParam ¶
FormatSBOMParam formats BOM entries into the SBOM parameter string Deprecated: Use GetSBOMData instead for compatibility with scanoss.py The format is: "type=identify\npurl1\npurl2\ntype=ignore\npurl3\n..."
Types ¶
type BOM ¶
type BOM struct {
// Include specifies components that should be included in scan results (new format)
Include []BOMEntry `json:"include,omitempty"`
// Identify specifies components that should be identified as declared dependencies
Identify []BOMEntry `json:"identify,omitempty"`
// Ignore specifies components that should be ignored/whitelisted in scan results
Ignore []BOMEntry `json:"ignore,omitempty"`
// Remove specifies components that should be removed/blacklisted from scan results
Remove []BOMEntry `json:"remove,omitempty"`
// Replace specifies components that should be replaced with alternatives
Replace []BOMEntry `json:"replace,omitempty"`
}
BOM represents the Bill of Materials section in the settings file. It contains lists of components to identify, ignore, or remove from scan results.
type BOMEntry ¶
type BOMEntry struct {
// PURL (Package URL) identifying the component. Supports glob patterns (e.g., pkg:npm/lodash@*)
Purl string `json:"purl"`
// Path optional file path pattern to scope this entry
Path string `json:"path,omitempty"`
// ReplaceWith specifies the PURL to replace with (only for Replace entries)
ReplaceWith string `json:"replace_with,omitempty"`
}
BOMEntry represents a single BOM (Bill of Materials) entry that specifies how the scanner should handle a particular component.
type SBOMData ¶
type SBOMData struct {
Assets string // JSON-serialized SBOM: {"components": [{"purl": "pkg:..."}, ...]}
Type string // "identify" or "blacklist"
}
SBOMData represents SBOM data to be sent to the API
func GetSBOMData ¶
GetSBOMData converts BOM entries into the format expected by SCANOSS API (compatible with scanoss.py) Returns nil if there are no BOM entries that should be sent to the API Note: Remove entries are NOT sent to the API - they are applied as post-processing
type Settings ¶
type Settings struct {
BOM BOM `json:"bom"`
// Settings holds the input-filtering rules (the scanoss.json "settings"
// section). Optional.
Settings Tuning `json:"settings,omitempty"`
}
Settings represents the scanoss settings file structure.
func Resolve ¶
Resolve determines the settings file to use based on the provided flag value and the scan target path. The --settings flag takes highest priority; if not provided, auto-detection in the scan folder is attempted.
Returns the loaded Settings (or nil if no settings file), and an error if loading fails.
func (*Settings) ScanFilter ¶
ScanFilter returns the file-collection filter for the scanning operation, derived from the scanoss.json skip rules. Returns nil when s is nil.
type SizeRule ¶
type SizeRule struct {
Patterns []string `json:"patterns"`
Min int64 `json:"min"`
Max int64 `json:"max"`
}
SizeRule is one entry under settings.skip.sizes.<operation>: files matching any of Patterns are skipped when smaller than Min or larger than Max (0 disables a bound).
type Skip ¶
type Skip struct {
Patterns SkipPatternsByOp `json:"patterns,omitempty"`
Sizes SkipSizesByOp `json:"sizes,omitempty"`
}
Skip mirrors the settings.skip section of scanoss.json.
type SkipPatternsByOp ¶
type SkipPatternsByOp struct {
Scanning []string `json:"scanning,omitempty"`
Fingerprinting []string `json:"fingerprinting,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
}
SkipPatternsByOp mirrors settings.skip.patterns: glob patterns per operation.
type SkipSizesByOp ¶
type SkipSizesByOp struct {
Scanning []SizeRule `json:"scanning,omitempty"`
Fingerprinting []SizeRule `json:"fingerprinting,omitempty"`
Dependencies []SizeRule `json:"dependencies,omitempty"`
}
SkipSizesByOp mirrors settings.skip.sizes: size rules per operation.
type Tuning ¶
type Tuning struct {
Skip Skip `json:"skip,omitempty"`
}
Tuning mirrors the top-level settings section of scanoss.json: the input-filtering skip rules applied during file collection.
func (Tuning) SkipPatterns ¶
SkipPatterns returns the skip patterns for the given operation, or nil.