You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: apply pubspec.yaml dependency_overrides in Dart scans #678
In Dart and Flutter projects, dependency_overrides: in pubspec.yaml forces the version that actually gets resolved, whatever dependencies: or dev_dependencies: ask for:
parsePubspecYaml in src/core-open/scanners/dart-scanner.ts (around lines 203–300) only enters a section for dependencies: and dev_dependencies:. Any other top-level key, including dependency_overrides:, resets the section, so overrides are ignored. As a result, a project scanned without a pubspec.lock reports the ^0.13.0 constraint for http, even though the project builds with 1.2.1. A package that appears only in dependency_overrides is not reported at all.
What to do
Read dependency_overrides: entries in the same forms already supported for the other sections (one-line version, { version: … } maps, path: and git: entries).
When a package is both declared and overridden, use the override's spec for that package's row and keep it as a production or development dependency according to where it was declared.
Decide what to do with override-only packages (for example, report them as production rows) and write the choice down in the function's doc comment.
Add a test next to test/dart-pubspec-map.test.ts.
Acceptance
With the example above, vg scan reports http at 1.2.1, not ^0.13.0.
An overridden dev_dependencies package keeps its development flag.
Projects with no dependency_overrides: section produce exactly the same output as before.
Thanks, this is a real accuracy gap for Flutter projects scanned without a lockfile. Some notes from the code to help whoever takes it:
parsePubspecYaml in src/core-open/scanners/dart-scanner.ts tracks currentSection as 'dependencies' | 'dev_dependencies' | null, and the indent === 0 && /^\w+:/ branch resets it for every other top-level key. That is where dependency_overrides: is currently thrown away. Adding it as a third section that goes through the same one-line, { version: … } flow-map and nested version: / path: / git: handling means you get all the existing forms for free.
The tricky part is the merge, because overrides can appear before or after the declarations in the file. It's simplest to collect overrides into their own Map<name, spec> while parsing and apply them once at the end: replace the spec on an existing row but keep its isDev flag, and add any override-only names as new rows (production is a reasonable default, as the issue suggests). Please write whichever rule you choose into the doc comment above the function, which already explains how duplicates across the two sections are handled.
Watch the SDK skip logic: an override such as flutter_test: { sdk: flutter } should still be skipped, and the sdk: line at the top of the loop must not be treated as a Dart version when it sits inside the overrides section.
test/dart-pubspec-map.test.ts and test/sbom-dart-dev-dependencies.test.ts show the fixture style. Covering the example in the issue, an overridden dev dependency, an override-only package, and a pubspec with no overrides (output unchanged) would pin all four acceptance points.
If a pubspec.lock is present it still wins, so this change only affects lockfile-less scans.
Activity
vibgrate-team commentedon Nov 13, 2026
Thanks, this is a real accuracy gap for Flutter projects scanned without a lockfile. Some notes from the code to help whoever takes it:
parsePubspecYamlinsrc/core-open/scanners/dart-scanner.tstrackscurrentSectionas'dependencies' | 'dev_dependencies' | null, and theindent === 0 && /^\w+:/branch resets it for every other top-level key. That is wheredependency_overrides:is currently thrown away. Adding it as a third section that goes through the same one-line,{ version: … }flow-map and nestedversion:/path:/git:handling means you get all the existing forms for free.Map<name, spec>while parsing and apply them once at the end: replace the spec on an existing row but keep itsisDevflag, and add any override-only names as new rows (production is a reasonable default, as the issue suggests). Please write whichever rule you choose into the doc comment above the function, which already explains how duplicates across the two sections are handled.flutter_test: { sdk: flutter }should still be skipped, and thesdk:line at the top of the loop must not be treated as a Dart version when it sits inside the overrides section.test/dart-pubspec-map.test.tsandtest/sbom-dart-dev-dependencies.test.tsshow the fixture style. Covering the example in the issue, an overridden dev dependency, an override-only package, and a pubspec with no overrides (output unchanged) would pin all four acceptance points.If a
pubspec.lockis present it still wins, so this change only affects lockfile-less scans.