security
Use a lockfile to explain an unexpected dependency
Trace a package finding through resolved lockfile paths and the deployed build. Find which direct dependency or separate workspace brought it in.
TrustIvan · · 10 min read
One component scan reports fixture-archive-codec@2.3.0 in a receipt worker image. The application manifest never declares it. The same name appears twice in the monorepo's current lockfile, once at a newer version. An engineer could assign the issue to the repository owner and ask for a global upgrade. Before doing that, establish which dependency chain the deployed worker used and what build put the affected bytes into the release.
A lockfile can connect a resolved version to its asking packages. Use it with the exact source, build inputs and observed artifact. Its presence alone does not show that a file shipped, and a scanner can observe a package from somewhere outside the selected language workspace. The goal is a traceable answer about one release with enough evidence for an owner to change and verify it.
Record the finding at the point of observation
Take the component name and ecosystem, version, package URL if available, path, scanner record and immutable artifact identity. Note whether the scanner obtained the result from package-manager metadata, an SBOM, filesystem inspection, or another detection mechanism. Copy only allowed identifiers into the handoff. Different ecosystem packages can share a name, and the given version can represent a package, an embedded copy or a value inferred from a binary.
Keep the target workload and deployment observation too. An active image and a historical build cache might each be scanned and show the same issue. The question changes if the affected component was packaged in an old release, retained in a build environment, or observed on the current workload. A reliable issue record preserves all applicable scopes with separate observations. It does not assume one result proves them all.
For instance, a report saying /srv/worker/node_modules/fixture-archive-codec/package.json in image W17 is a useful starting point. Another report that finds the package name in a source-only project inventory applies to its declared source scope. Preserve the path, artifact and evidence type before comparing them. The same version in both results supports a hypothesis that needs the build link.
Recover the dependency inputs for that build
Find the source commit that produced W17 using the release system's approved provenance or build logs. Locate the exact workspace and lockfile used during that build. Record the lockfile digest and package-manager version with install settings, operating system, architecture, build stages and any private registry relevant to the observation. Avoid looking up the revision of the deployment template and assuming it is also the revision that produced the image.
An npm package lock documents the resolved dependency tree for a project. Record which lockfile format and root directory the build used. If a monorepo has a common lockfile and independently built packages, record the actual workspace selection, source paths and build context. Check for local package inputs or scoped dependencies resolved under a particular configuration. npm package-lock documentation.
Use the worktree or release assets tied to the source revision instead of replacing the working checkout. A newly updated default branch can move the affected package to a different version or change which direct package requires it. Reproduce any install only in the team's approved test environment with the matching toolchain and trusted package inputs. If the original run's install flags or platform are uncertain, describe that limit before drawing conclusions about the release.
Identify all parents of the observed package instance
Look up the exact version in the relevant lockfile, then find the dependency edges that resolve to that installed instance. Follow each edge toward a direct dependency of the target workspace. A package can be used by more than one parent even when a hoisted installation places one copy at the top of a dependency directory. The directory layout may obscure which dependency asked for the version. Distinguish the actual graph from a guess based on neighboring paths.
An npm team can use the supported npm explain command against a faithful installed tree to see why an installed dependency exists. If packages are duplicated, qualify the installed location for the specific instance. Contrast this output with the exact source lockfile and the verified path in the release. A successfully recreated install helps explain dependency selection. It cannot establish which files the release packaged unless the build evidence connects them. npm explain documentation.
Watch for aliases, optional requirements, peer resolution, a local workspace link and transitive edges introduced by different packages. A direct parent may be able to take a new patch version while another parent requires the old release line. Record both until you can tell which instance shipped. Where two versions coexist for legitimate reasons, assign and verify affected cases based on exact versions and scope, not on a global package-name search result.
Walk a synthetic monorepo from lockfile to image
The inert fixture includes a receipt worker and a browser report app. The immutable receipt image W17 was built from commit R17 with the original lockfile. The current repository is at R18, which already changed one version. Preserve both source snapshots and label which is relevant.
| Observed scope | Resolved or inspected evidence | What it establishes |
|---|---|---|
| Receipt workspace at R17 | Direct sample-mailer@4.8.0 requires fixture-archive-codec@2.3.0 | Candidate dependency path for W17 |
| Browser report workspace at R17 | Direct sample-viewer@8.0.0 requires codec 3.0.1 | Separate version in the same project |
| Receipt build-only package | Test fixture runner resolves codec 2.3.0 in its tools install | A separate build-time path to check |
| Receipt image W17 | Package metadata at the worker runtime path matches codec 2.3.0 | The scanned artifact contains this instance |
| Receipt workspace at R18 | Direct mailer upgraded and locked to codec 2.4.2 | Source migration candidate, deployment evidence pending |
Ask the reviewer to trace the worker artifact back to R17 and explain why the report app's codec 3.0.1 does not answer the receipt finding. Then ask them to distinguish its runtime copy from the test fixture runner's duplicate. Both carry the same version. A distinct install path, build stage and packaged content record can separate those observations. Give the worker team the exact parent transition to test rather than asking it to upgrade one shared name everywhere.
Change one fixture fact next. The receipt image contains codec 2.3.0 at a copied vendor directory and the application install contains 2.4.2. Check whether the scanner links the finding to the copied path. Locate its inventory through the producing job or the approved base and vendor evidence. Retain the unresolved provenance if you cannot show where the copy originated. That case cannot be closed by changing only the receipt lockfile.
Distinguish resolved, installed and shipped dependencies
A package manager can resolve dependencies that an installation excludes. npm's omit configuration, for example, can leave types like development dependencies represented in the lockfile while excluding them from the installed tree. Platform conditions can also change what is installed. Record which options apply to the actual build and use evidence from its installation, rather than extrapolating from your workstation. npm ci configuration.
A build may then package only some installed files, or bundle code into a distributable asset. Another build can use a package solely during compilation. Distinguish the finding's exposure from the source of its presence. Build-only tools can still deserve review because they run with build privileges or influence shipped content. Their verification owners and release conditions may differ from those for a package available to runtime application code.
Look outside the lockfile if the exact package is absent. Review the image ancestry, copied distributions, generated packages, foreign language dependencies, downloaded plugins and vendored code using your approved artifact review process. The vendored dependency guide covers missing package-manager relationships. Give each alternate source a corresponding proof request. An SBOM can provide a useful observed component identity when its selection and origin are visible, even if the package was not installed through the current app lockfile.
Make a change that the right owner can verify
Give a candidate fix to the direct dependency owner with the subject artifact, observed path and verified parent edges. Consider updating the direct parent, applying an approved scoped resolution, changing the base image, or replacing the copied component according to its origin. A transitive override can need separate compatibility review, especially where peer constraints and multiple workspaces use different ranges. Record why the chosen edit applies to the affected path and what behavior should be tested.
Rebuild the exact worker scope under a new immutable release identity. Preserve the source and lockfile changes with a comparison of the packaged component. Run an approved scan with equivalent scope and policy. Test the application behavior affected by the dependency, such as opening a representative synthetic archive and reporting an unsupported format cleanly. Track the test-runner copy separately if it remains a build-time action and needs another resolution. The runtime claim is tied to the files you inspected in the tested worker image.
Verify which release actually runs after deployment. The new source resolution will not change a scheduled job that still pins W17. Check standby or rollback artifacts in their agreed scope. Where an old artifact stays active, leave a corresponding tracking record. Verify a container fix on its deployed artifact describes the identity evidence that supports closure.
Verify concurrent changes to two dependency paths
In a separate replay, let the browser team and the receipt team update the shared lockfile in parallel. The browser update changes the 3.0.1 branch first. Rebasing the receipt team's work can legitimately rearrange many locked records. Require both teams to preserve the tested parent edges and to rerun their own build paths before interpreting the merged lockfile. A large lockfile diff can contain formatting churn or changed placement alongside a real version transition. The reviewer should be able to point to the runtime artifact, its linked lockfile digest and the resolved replacement rather than scanning the diff for one removed string.
Track whether an approved register or registry migration also changes how a package is identified. A package with the same display name and version can refer to a different source. Verify the recorded origin and integrity metadata according to the package manager and your trust policy. Leave replacement releases as separate observations when source identity is uncertain, and route the difference to the person who can verify provenance.
Run a fair comparison between dependency analysis workflows
Give each evaluator the same source commit, lockfile, build configuration, release artifact and fixture finding. Ask them to trace the relevant parent, locate the duplicate with a different version, and show whether the affected path shipped. Give them the replaced scope and an unchanged historical artifact afterward. A useful workflow can identify which issue changed while preserving history for the prior artifact.
Check which evidence a reviewer can export: dependency relationships, source revision, packaged paths, platform and deployment observation. Document where the distinction needs extra tooling and which team owns the work. Do not count a prettier dependency graph as proof that the integration knows which variant was deployed. The Semgrep comparison provides related criteria when evaluating dependency analysis capabilities.
Keep the evidence needed to repeat the investigation in the issue. That means the scanner record, artifact identity and path, build receipt, exact lockfile and parent edges, plus the new result and verified rollout state. An engineer should be able to reproduce why the dependency was present and know which evidence would show it has left the affected scope.