Skip to content

fix(fix): in-place JSON classifies direct dependency upgrades as transitive #3235

Open

Description

@coygeek

Summary

In-place npm remediation reports transitive: true for a package declared directly in the root manifest and lockfile. This supplies an incorrect direct/indirect classification in the stable JSON result intended for automated tooling. The observed dependency upgrade succeeds; no downstream consumer failure or remediation failure was observed.

Runtime or environment

Observed with the Homebrew OSV-Scanner 2.7.0 binary, using Scalibr 0.5.3, on macOS arm64. The source comparisons below refer to those released versions unless explicitly identified as a current-source inspection.

Steps to reproduce

Create a trusted disposable directory containing this package.json:

{"name":"remediation-fixture","version":"1.0.0","private":true,"dependencies":{"lodash":"^4.17.20"}}

Create this package-lock.json, which is the complete observed pre-remediation input:

{
  "name": "remediation-fixture",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "remediation-fixture",
      "version": "1.0.0",
      "dependencies": {
        "lodash": "^4.17.20"
      }
    },
    "node_modules/lodash": {
      "version": "4.17.20",
      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
      "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
      "license": "MIT"
    }
  }
}

Run the following command from that directory, using the tested runtime:

osv-scanner fix --strategy=in-place -M package.json -L package-lock.json --format=json

Inspect patches[0].packageUpdates[0].transitive. This reproduction was executed after reducing a larger fixture to the single direct dependency above. A separate observed invocation with only -L package-lock.json produced the same wrong classification; supplying the manifest does not change it.

Expected behavior

The lodash upgrade should report transitive: false: lodash appears directly in root dependencies, and the exported PackageUpdate.Transitive contract defines false for a direct dependency and true for an indirect dependency. In-place remediation should preserve that distinction in its JSON result.

Actual behavior

The command exited 0 and emitted the following package update:

{
  "name": "lodash",
  "versionFrom": "4.17.20",
  "versionTo": "4.18.1",
  "transitive": true
}

Before remediation, packages["node_modules/lodash"].version in the lockfile was 4.17.20; afterward it was 4.18.1. The manifest and packages[""].dependencies continued to declare lodash directly with constraint ^4.17.20. Thus the wrong field does not indicate that this observed upgrade failed.

Evidence

  • Expected source: The exported PackageUpdate contract defines the field's direct/indirect meaning. The guided-remediation JSON documentation says the format is stable and intended for automated tooling.
  • Failure source: The complete input, executed command, exit status, output field, and observed lockfile change are reproduced inline above. The in-place result constructor assigns Transitive: true when constructing each package update, and Scanner's JSON output function serializes that result directly.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

The primary violation evidence is the emitted classification for the executed direct-dependency fixture. The source inspection explains that observed result.

Restoration check

Run in-place remediation on the supplied fixture and confirm that the successful lodash package update reports transitive: false, while the lockfile still receives the applicable upgrade and the report retains the corresponding advisory results. Also retain correct transitive: true classification for a genuinely indirect upgraded dependency; setting the field uniformly to false would not restore its contract.

Additional context

Inspection of the current Scalibr source also found the unconditional assignment and the same exported field contract; this inspection was not a runtime test of a development build. The failure is reported here as Scanner JSON output, following this repository's contributor routing for CLI/output/config issues; the underlying constructor is in Scalibr.

References

Issue #91 requests dependency-chain and depth information for findings. Its body and full discussion do not describe an existing in-place remediation result assigning the wrong direct/indirect boolean. This report concerns that distinct, already-defined field contract.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: The structured remediation result labels an observed direct dependency as indirect, violating the exported boolean contract in an output format intended for automated tooling. Consumers using that field receive the wrong classification. No downstream consumer failure or remediation failure was observed, and the demonstrated impact is bounded to classification metadata.
  • Workaround status: available
  • Workaround basis: Derive directness from the root manifest or root lockfile dependency declarations instead of this field. Both supplied and observed inputs explicitly contain lodash in the root dependencies before and after remediation, so that distinction remains available without changing the remediation result.

Activity

  1. self-assigned this
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions