Dependency provenance and SBOM
Prerequisite: node-ci-test-and-build-stages. Objective: Review synthetic inventory. Each example is independent. Tested with Node.js 22.16.0 on Linux. Save as main.mjs in a fresh disposable directory and run node main.mjs. These are static code blocks; external system behavior is not established by a local model.
How it works
Review dependencies, transitive versions, licenses, package origin, lifecycle scripts and advisories. A lockfile records dependency resolution, but neither a lockfile nor an SBOM proves safety. npm can produce supported SBOM formats from its dependency information; actual format validation and completeness depend on tool and inputs. Verify attestations against trusted identity and expected artifact digest, not only an unsigned claim. Never include credentials in inventories.
Hash an original local artifact
import assert from 'node:assert/strict';import {createHash} from 'node:crypto';const hash=s=>createHash('sha256').update(s).digest('hex');assert.notEqual(hash('catalog-v1'),hash('catalog-v2'));console.log(hash('catalog-v1').length);Expected output:
64SHA-256 hex has 64 characters; trust depends on an independently trusted expected digest.
Keep component version identity
import assert from 'node:assert/strict';const components=[{name:'fictional-lib',version:'1.0.0'},{name:'fictional-lib',version:'2.0.0'}];const keys=components.map(c=>`${c.name}@${c.version}`);assert.equal(new Set(keys).size,2);console.log(keys.join(','));Expected output:
fictional-lib@1.0.0,fictional-lib@2.0.0A simplified inventory retains both versions; it is not a standard-format SBOM.
Common mistake
Do not mistake a matching hash for a trusted signature, or an inventory for a vulnerability scan.
Practice
Identify two components with different versions and explain why deduplicating only by package name loses information.
Reference candidate: node-dependency-provenance-and-sbom-lookup (route unverified). Documentation anchors: https://docs.npmjs.com/cli/v10/commands/npm-sbom/, https://docs.github.com/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations. External versions and full integration are pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Dependency provenance and SBOM — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
What is an SBOM?
What does a matching hash establish?
Why retain both versions of a dependency?