Documentation
¶
Index ¶
- Constants
- func EnsureNode(g *sdk.Graph, node *sdk.Dependency) (*sdk.Dependency, error)
- func EnsureOccurrence(g *sdk.Graph, node *sdk.Dependency, qualifier string) (*sdk.Dependency, error)
- func IsProjectOwned(dep *sdk.Dependency) bool
- func OccurrenceID(baseID, qualifier string) string
- func OriginsConflict(left, right *sdk.DependencyOrigin) bool
Constants ¶
const ( // NameNPM, NamePNPM, and NameYarn are the merged per-package-manager // detectors that own an internal lockfile→buildtool strategy order. The // historical lockfile/native names remain as registry aliases. NameNPM = "npm" NameNPMLockfile = "npm-detector" NameNPMNative = "npm-native-detector" NamePNPM = "pnpm" NamePNPMLockfile = "pnpm-detector" NamePNPMNative = "pnpm-native-detector" NameYarn = "yarn" NameYarnLockfile = "yarn-detector" NameBun = "bun-detector" NameBunNative = "bun-native-detector" NameYarnNative = "yarn-native-detector" NameGradle = "gradle-detector" NameMaven = "maven-detector" NameGoMod = "go-detector" NameComposer = "composer-detector" NameBundler = "bundler-detector" NameGitHubActions = "github-actions-detector" NamePip = "pip-detector" NamePipenv = "pipenv-detector" NamePoetry = "poetry-detector" NameUV = "uv-detector" NameNuGet = "nuget-detector" NameCargo = "cargo-detector" NamePub = "pub-detector" NamePubNative = "pub-native-detector" NameCocoaPods = "cocoapods-detector" NameSwiftPM = "swiftpm-detector" NameSwiftPMNative = "swiftpm-native-detector" NameMix = "mix-detector" NameConan = "conan-detector" NameSBT = "sbt-detector" NameSBTNative = "sbt-native-detector" NameSBOM = "sbom-detector" NameSyft = "syft-detector" )
Variables ¶
This section is empty.
Functions ¶
func EnsureNode ¶ added in v0.24.0
func EnsureNode(g *sdk.Graph, node *sdk.Dependency) (*sdk.Dependency, error)
EnsureNode inserts node into g, or returns the node already carrying its ID.
Every detector needs this: a lockfile can name one package more than once, and the graph keeps one node per ID. Doing the existence check by hand is what left a dozen detectors silently discarding duplicate records' data -- each copy of the check was written independently and never revisited. Use this rather than calling Graph.AddNode after a Node lookup, so a detector added later inherits the shared behavior instead of having to know about it.
When it folds, the survivor takes the union of both records' scopes. Scopes answer "where is this package reachable?", so one package listed in two dependency groups is reachable at both -- a manifest's develop entry does not stop being a develop dependency because the default group named the package first. Everything else on the discarded record is dropped: records that genuinely differ are different occurrences and belong in distinct nodes under distinct IDs (the caller decides identity, EnsureOccurrence is the shared rule for resolution-qualified identity).
func EnsureOccurrence ¶ added in v0.24.0
func EnsureOccurrence(g *sdk.Graph, node *sdk.Dependency, qualifier string) (*sdk.Dependency, error)
EnsureOccurrence inserts node, folding it into an existing node only when both records claim the same resolution. When the graph already holds this ID with a *different* ResolvedURL, the manifest has asserted two resolutions of one name@version: the newcomer stays a distinct occurrence under an opaque ID derived from qualifier (its stable positional key -- a lockfile path, entry key, or source string).
This is the one home for the collision rule. Five detectors grew the same hand-written shape one review round at a time before it was centralized; route new sites through here.
func IsProjectOwned ¶ added in v0.24.0
func IsProjectOwned(dep *sdk.Dependency) bool
IsProjectOwned reports whether dep is the scanned project's own artifact -- its root package, a workspace member, a reactor module -- rather than a consumed package. Detectors mark this in two ways, an explicit FirstParty flag or an application package type, and either is enough. The project's own records never take an external origin, never fold into an external occurrence, and never inherit enrichment resolved from a package identity they merely share.
func OccurrenceID ¶ added in v0.24.0
OccurrenceID derives a distinct node ID for an additional occurrence of a package, qualified by what distinguishes it. The qualifier is hashed rather than embedded: node IDs become SBOM component identifiers (CycloneDX bom-refs, SPDX element IDs), and a raw source string can carry credentials or tokens that every other path in this feature exists to keep out of published documents.
func OriginsConflict ¶ added in v0.24.0
func OriginsConflict(left, right *sdk.DependencyOrigin) bool
OriginsConflict reports whether two records assert different publishable origins. Absence is never a conflict, and neither is one location written two ways: contradiction means both publish and they disagree. Callers use this to decide that two records are distinct occurrences deserving distinct nodes, never to pick a winner.
Types ¶
This section is empty.