Skip to content

Bug: Cargo [dependencies.<crate>] sub-tables are ignored by vg scan #546

Closed

Description

@vibgrate-team

Context

Cargo lets a dependency be written as its own table:

[dependencies.serde]
version = "1.0"
features = ["derive"]

[dev-dependencies.criterion]
version = "0.5"

cargoDependencyHeader in src/core-open/scanners/rust-scanner.ts documents that any header other than the dependency tables themselves, "including [dependencies.<crate>]", is not a dependency table, and gap 8 in docs/sbom-dependency-scope.md confirms the sub-table form is not parsed. Crates declared this way are missing from vg scan drift results and from vg sbom export direct rows. The form is common in larger workspaces and generated manifests.

What to do

  • Recognise [dependencies.<crate>], [dev-dependencies.<crate>], [build-dependencies.<crate>], and the [target.<spec>.<kind>.<crate>] variants, reading version, optional, path, git and workspace keys the same way the inline-table form does.
  • Apply the existing section precedence rules (production beats dev/build; non-target beats target).
  • Update gap 8 in docs/sbom-dependency-scope.md.

Acceptance

  • The example above yields serde as a dependencies row and criterion as a devDependencies row.
  • optional = true inside a [dependencies.<crate>] table yields an optionalDependencies row.
  • A path = or git = sub-table is handled the same as its inline-table equivalent.
  • Tests pin each form.

Activity

  1. added
    bug
    on Nov 2, 2026
  2. vibgrate-team commented on Nov 2, 2026

    @vibgrate-team
    ContributorAuthor

    Confirmed: cargoDependencyHeader in rust-scanner.ts returns null for [dependencies.<crate>], and parseCargoToml then ignores every line until the next real dependency table. One way in is to let the header parser return the table kind plus an optional crate name, then in parseCargoToml collect the key = value lines of that sub-table into the same object shape the inline-table branch builds, and push it when the next header starts (and at end of file). That way version, optional, path, git and workspace = true reuse the existing handling, and dedupeCargoDeps applies the current precedence for free. Remember to flush the pending crate before switching tables, otherwise the last sub-table in a file is easy to lose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions