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:
| Extractor | Triggers on | What it sends to osv.dev | Confidence |
|---|---|---|---|
vcs/gitrepo | Any .git directory | HEAD commit of that repository, plus the recorded commit of each submodule | Exact commit |
filesystem/vendored | A directory whose parent folder is named 3rdparty, dep, deps, thirdparty, third-party, third_party, libs, external, externals, vendor or vendored | MD5 hashes of .c, .cc, .cpp, .h, .hh, .hpp files, to the experimental determineversion API | Best 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/gitrepoonly fires on a.gitpath that is a directory. In a standard modern checkout, a submodule’s.gitis a small file pointing into the parent’s.git/modules/, so the extractor normally fires once, on the superproject’s.gitdirectory.- 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 queried | No | Yes |
third_party/zlib | Hashed by the vendored extractor; version estimated | Queried by exact recorded commit; vendored extractor skips it |
src/libfoo | Not 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 estimated | Hashed 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:
- The recorded commit wins. If a developer ran
git checkoutinside a submodule but did not commit the new gitlink in the parent repository, OSV-Scanner still queries the commit the parent repository records. - Uninitialised submodules can still be queried. The
Expectedhash comes from the index, not the submodule’s files. The documentation’s advice to rungit submodule updatefirst 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.
| Output | Field | Value for a commit-matched package |
|---|---|---|
| JSON | results[].source.type | git for packages from vcs/gitrepo |
| JSON | results[].packages[].package.ecosystem | "" (empty string) |
| JSON | results[].packages[].package.commit | Full commit hash |
| JSON | results[].packages[].package.version | Usually empty |
| Table | Ecosystem column | GIT |
| Table | Version column | First 8 characters of the commit |
| SARIF | Version shown in the result text | Full 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:
- Read each result’s
groups[].aliasesto find the CVE IDs. - Join those CVEs to the CISA KEV feed and EPSS.
- Fix by moving the submodule to a commit that contains the fix (the
fixedcommit 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
mainbranch has changedscan.goand 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 claim | Source | Status |
|---|---|---|
| Docs say submodules are scanned automatically and root repos are skipped by default | OSV-Scanner: Project Source Scanning | Verified |
vcs/gitrepo disabled unless --include-git-root; vendored ScanGitDir tied to the flag | google/osv-scanner v2.7.1, pkg/osvscanner/scan.go | Verified (source read) |
Flag help text and default false | v2.7.1, cmd/osv-scanner/scan/source/command.go | Verified (source read) |
gitrepo fires on .git directories, queries HEAD and each submodule’s Expected commit | v2.7.1, internal/scalibrextract/vcs/gitrepo/extractor.go | Verified (source read) |
Expected comes from the index entry before the initialisation check | go-git v5.19.3, submodule.go | Verified (source read) |
| Vendored folder names, file extensions, MD5 hashing, 0.15 threshold, 10,000-file cap | v2.7.1, internal/scalibrextract/filesystem/vendored/vendored.go | Verified (source read) |
Default plugin presets lockfile, sbom, directory; directory holds both extractors | v2.7.1, pkg/osvscanner/scan.go, internal/scalibrplugin/presets.go | Verified (source read) |
Output fields, GIT label and 8-character short commit | v2.7.1, pkg/models/results.go, internal/output/table.go, internal/utility/results/results.go | Verified (source read) |
osv.dev accepts a commit hash in /v1/query | osv.dev API: POST /v1/query | Verified |
| determineversion estimates vendored C/C++ versions with a confidence score | osv.dev blog: Using the determineversion API | Verified |
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
