Documentation
¶
Index ¶
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 Attributed ¶ added in v0.25.0
func Attributed(result sdk.DetectionResult, declarations ...ModuleDeclarations) sdk.DetectionResult
Attributed records, on every location the graphs in result carry, which module root's resolution produced that site, what the site's scopes are, and whether the site was declared by its module root or reached through another dependency. It returns result so a detector can wrap the value it was already returning.
Per ADR-0037 the usage unit is (module root, declaration site): scope, relationship, and reachability answer questions about a usage, and a conjunctive filter has to find its conjuncts on one usage rather than on three different ones summarized onto the same node. The node-level Scopes union and Relationship scalar are left exactly as they were — this fills the per-site fields beside them.
One site can belong to more than one module root: workspace members share a lockfile, so the same line is a usage in each member that reaches the package. Each (root, site) pair therefore becomes its own location record, which is why the module root is stored rather than inferred from the path.
A graph with no module node is left untouched: an empty ModuleRoot documents that the producer did not attribute the site, and inventing a root here would put a directory into the join key that nothing observed.
The records survive the SDK fold as well as the workspace partition. Since bomly-sdk v0.11.0 a location's identity in Graph.InsertNode is the usage unit -- path, position and module root -- so two separate nodes each carrying one root's record of the same path keep both records when they are merged into one, and two witnesses of one usage merge their scopes and relationship rather than dropping the second (bomly-dev/bomly-sdk#73). Before that release the fold compared paths and position only, and the second root's record was lost; that is why the module root is stored on the record rather than inferred from the path.
func Unattributed ¶ added in v0.25.0
func Unattributed(result sdk.DetectionResult, reason string) sdk.DetectionResult
Unattributed returns result unchanged and records, in the one place a reviewer looks, why its graphs carry no module root.
It is the typed exemption from the rule that a detection result carrying graphs is returned through Attributed. The rule is enforced by the attributed analyzer in internal/tools/guardcheck, which accepts a result wrapped in either function and reports a bare one; the exemption therefore lives at the site that needs it, with its reason as a required argument, rather than in a path list the analyzer has to keep in step with the tree (ADR-0044 rule 5). The reason is documentation: it is not logged or published. Two detectors qualify today -- the SBOM detector converts a document whose packages were resolved elsewhere, and the GitHub Actions detector reads workflow files that declare no module -- and a third needs the same kind of argument, not a comment.
Types ¶
type ModuleDeclarations ¶ added in v0.25.0
type ModuleDeclarations struct {
// ModuleRoot is the module directory the declarations belong to, in the
// same slash form Attributed derives from a module node's declaring
// manifest ("." for the detector's own working directory).
ModuleRoot string
// Scopes maps a direct dependency's name to the scope this module
// declared it under.
Scopes map[string]sdk.Scope
}
ModuleDeclarations carries what one module root's manifest declared about its direct dependencies, so the attribution below can record a site's real scope instead of the node-level union.
The union is only lossy when a package is reached from more than one module root: a workspace can declare one package as a development dependency in one member and pull the same package in at runtime through another, and the node carries both. Detectors that already read per-module declarations (the node family reads them out of each package.json) pass them here; the rest do not need to, because with one module root the node's scopes are that root's.
Scopes is keyed the way the node detectors already key declared scopes: by the dependency's name, falling back to its qualified name.