OSV-Scanner Git Submodules: What --include-git-root Changes

In OSV-Scanner v2.7.1 source, the extractor that queries submodule commit hashes runs only with --include-git-root. Without it, a C/C++ submodule is found only if it sits under a folder such as third_party or vendor, and its version is guessed from file hashes. Here is how each path works, what the JSON output fields mean, and how to check your own scan.

Close-up of a dense tangle of bare reddish-brown branches crossing over one another
Photo by Giggle Jutsu on Unsplash

Short answer: OSV-Scanner’s documentation says it “will automatically scan git submodules”, but in the v2.7.1 source the extractor that sends submodule commit hashes to osv.dev only runs when you pass --include-git-root. Without the flag, a C/C++ submodule is found only if it sits directly under a folder such as third_party/ or vendor/, and its version is estimated from file hashes rather than read from Git. If your C/C++ dependencies are submodules, run osv-scanner scan source -r --include-git-root . and check the JSON for packages with a commit field.

We reached this by reading the source at tag v2.7.1 (tagged 9 November 2026, the latest release tag on 4 December 2026). We could not run the OSV-Scanner binary in our environment, so the behaviour below is what the code does, not an observed scan. The last section shows how to confirm it on your own repository in a few minutes.

Two ways OSV-Scanner finds C/C++ code

C and C++ projects rarely have a lockfile, so OSV-Scanner’s C/C++ support is “based on commit-level data”. The directory plugin preset, which is on by default for source scans alongside lockfile and sbom, holds two extractors:

ExtractorTriggers onWhat it sends to osv.devConfidence
vcs/gitrepoAny .git directoryHEAD commit of that repository, plus the recorded commit of each submoduleExact commit
filesystem/vendoredA directory whose parent folder is named 3rdparty, dep, deps, thirdparty, third-party, third_party, libs, external, externals, vendor or vendoredMD5 hashes of .c, .cc, .cpp, .h, .hh, .hpp files, to the experimental determineversion APIBest match, used only if its score is above 0.15

Both produce a package with a commit and no ecosystem. osv.dev’s /v1/query endpoint accepts “the commit hash to query for”. The commit-level data in OSV records comes from GIT ranges, which we covered in OSV GIT ranges: commit hashes, fixed vs limit events.

What --include-git-root actually switches

Two lines in pkg/osvscanner/scan.go at v2.7.1 decide the behaviour:

// configuring the vendored extractor
ScanGitDir: !actions.IncludeGitRoot,

// building the plugin list
if !actions.IncludeGitRoot {
    actions.PluginsDisabled = append(actions.PluginsDisabled, gitrepo.Name)
}

The flag’s help text is “include scanning git root (non-submoduled) repositories”, and it defaults to false. But disabling vcs/gitrepo turns off more than root scanning:

  • vcs/gitrepo only fires on a .git path that is a directory. In a standard modern checkout, a submodule’s .git is a small file pointing into the parent’s .git/modules/, so the extractor normally fires once, on the superproject’s .git directory.
  • From there it calls go-git’s Worktree().Submodules() and emits one commit query per submodule. That loop is the only place in the v2.7.1 source that enumerates submodules.

So with the default settings, no submodule commit reaches osv.dev from this extractor. With --include-git-root, you get the superproject’s own HEAD commit and every submodule’s commit.

The flag also flips the vendored extractor’s ScanGitDir setting. With the flag, the vendored extractor skips any directory that contains a .git entry, which avoids reporting a submodule twice (once by exact commit, once by hash estimate).

The two configurations side by side

Assume a repository with a submodule at third_party/zlib and another at src/libfoo.

Default--include-git-root
Superproject HEAD commit queriedNoYes
third_party/zlibHashed by the vendored extractor; version estimatedQueried by exact recorded commit; vendored extractor skips it
src/libfooNot scanned (parent folder src is not on the vendored list, and gitrepo is off)Queried by exact recorded commit
Plain copied code in vendor/libbar (no .git)Hashed and estimatedHashed and estimated

The superproject HEAD query is usually harmless for private code, because osv.dev has no GIT ranges for your repository. It matters if you are scanning a fork of a public project that does have OSV records.

Which commit is queried for a submodule

vcs/gitrepo uses status.Expected from go-git. In go-git v5.19.3, the version OSV-Scanner v2.7.1 pins, Expected is set from the superproject’s index entry for the submodule path, before go-git checks whether the submodule is initialised. Two practical results:

  1. The recorded commit wins. If a developer ran git checkout inside a submodule but did not commit the new gitlink in the parent repository, OSV-Scanner still queries the commit the parent repository records.
  2. Uninitialised submodules can still be queried. The Expected hash comes from the index, not the submodule’s files. The documentation’s advice to run git submodule update first still matters for the vendored extractor, which needs the files on disk to hash them.

If go-git returns an error for a submodule’s status, the extractor skips that submodule silently (continue), so a broken submodule checkout can drop out of results without a warning.

Reading commit-based results

Commit-matched packages look different from lockfile packages in every output format. Field names below are from pkg/models/results.go at v2.7.1.

OutputFieldValue for a commit-matched package
JSONresults[].source.typegit for packages from vcs/gitrepo
JSONresults[].packages[].package.ecosystem"" (empty string)
JSONresults[].packages[].package.commitFull commit hash
JSONresults[].packages[].package.versionUsually empty
TableEcosystem columnGIT
TableVersion columnFirst 8 characters of the commit
SARIFVersion shown in the result textFull commit hash

In the v2.7.1 source, the location recorded for a submodule is the .git directory path joined with the submodule path, so expect source.path values ending in .git/third_party/zlib rather than third_party/zlib.

Check your own repository

These commands are illustrative; they use flags documented for OSV-Scanner v2 and fields from the v2.7.1 result model. Run them from the superproject root.

git submodule status            # list submodules and the commit each is pinned to

osv-scanner scan source -r --format json . > default.json
osv-scanner scan source -r --include-git-root --format json . > gitroot.json

# Packages found by commit in each run
for f in default.json gitroot.json; do
  echo "== $f"
  jq -r '.results[] | .source as $s | .packages[]
         | select(.package.commit != null)
         | [$s.type, $s.path, .package.commit[0:12], (.vulnerabilities // [] | length)]
         | @tsv' "$f"
done

If a submodule from git submodule status appears in gitroot.json but not in default.json, your default scans have been missing it.

From commit findings to a patch decision

A commit match gives you OSV IDs, not a package version to bump. To decide what to fix first:

  1. Read each result’s groups[].aliases to find the CVE IDs.
  2. Join those CVEs to the CISA KEV feed and EPSS.
  3. Fix by moving the submodule to a commit that contains the fix (the fixed commit in the OSV record or a descendant of it), then commit the new gitlink in the parent repository.

The full flow from CVE record to ticket is in our vulnerability prioritization workflow.

Limits of this article

  • This is a source reading of OSV-Scanner v2.7.1, not a test run. The main branch has changed scan.go and the source command since that tag, though the lines quoted above have not moved in meaning.
  • The documentation and the code disagree on whether submodules are scanned by default. Our search did not turn up an issue explaining the intent. If a later release changes the behaviour, the documentation may become correct.
  • Commit-level coverage is incomplete. The OSV-Scanner documentation warns that “there may be vulnerabilities in their dependencies that could be excluded from OSV-Scanner results”.
  • The vendored extractor needs osv.dev. The source disables it when OSV-Scanner runs in offline comparison mode.

Sources and verification

Important claimSourceStatus
Docs say submodules are scanned automatically and root repos are skipped by defaultOSV-Scanner: Project Source ScanningVerified
vcs/gitrepo disabled unless --include-git-root; vendored ScanGitDir tied to the flaggoogle/osv-scanner v2.7.1, pkg/osvscanner/scan.goVerified (source read)
Flag help text and default falsev2.7.1, cmd/osv-scanner/scan/source/command.goVerified (source read)
gitrepo fires on .git directories, queries HEAD and each submodule’s Expected commitv2.7.1, internal/scalibrextract/vcs/gitrepo/extractor.goVerified (source read)
Expected comes from the index entry before the initialisation checkgo-git v5.19.3, submodule.goVerified (source read)
Vendored folder names, file extensions, MD5 hashing, 0.15 threshold, 10,000-file capv2.7.1, internal/scalibrextract/filesystem/vendored/vendored.goVerified (source read)
Default plugin presets lockfile, sbom, directory; directory holds both extractorsv2.7.1, pkg/osvscanner/scan.go, internal/scalibrplugin/presets.goVerified (source read)
Output fields, GIT label and 8-character short commitv2.7.1, pkg/models/results.go, internal/output/table.go, internal/utility/results/results.goVerified (source read)
osv.dev accepts a commit hash in /v1/queryosv.dev API: POST /v1/queryVerified
determineversion estimates vendored C/C++ versions with a confidence scoreosv.dev blog: Using the determineversion APIVerified

Frequently asked questions

Does OSV-Scanner scan git submodules by default?

The documentation says it does. In the v2.7.1 source, the extractor that reads submodule commit hashes (vcs/gitrepo) is disabled unless --include-git-root is passed. Without the flag, a submodule is only picked up by the vendored-directory extractor, and only when its parent folder has one of 11 names such as third_party or vendor. Run your scan both ways and compare the JSON output to see which applies to your repository.

What does --include-git-root do in OSV-Scanner?

It enables the vcs/gitrepo extractor. For each .git directory found, that extractor queries osv.dev with the repository's HEAD commit and with the commit recorded for every submodule. It also tells the vendored extractor to skip directories that contain a .git entry, so a submodule is reported once, by exact commit, rather than by a hash-based estimate.

Which commit does OSV-Scanner use for a submodule?

The Expected hash from go-git's submodule status, which is the gitlink stored in the superproject's index. If someone checked out a different commit inside the submodule without committing the change in the parent repository, OSV-Scanner still queries the recorded commit.

Why do some OSV-Scanner results have no ecosystem or version?

Packages found by commit, from vcs/gitrepo or the vendored extractor, have no package name, version or ecosystem from a lockfile. They carry a commit instead. The JSON output shows ecosystem as an empty string and adds a commit field; the table output prints GIT as the ecosystem and the first 8 characters of the commit as the version.

Osv-ScannerOsvGit SubmodulesC/C++Vendored DependenciesScaSupply ChainVulnerability Management