<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Git Submodules | FirewallSync</title><link>https://firewallsync.com/tags/git-submodules/</link><description>Practical cybersecurity writing for engineering teams that ship fast.</description><language>en-us</language><image><url>https://firewallsync.com/icon-512.png</url><title>FirewallSync</title><link>https://firewallsync.com/</link></image><lastBuildDate>Fri, 04 Dec 2026 04:40:00 +0000</lastBuildDate><atom:link href="https://firewallsync.com/tags/git-submodules/index.xml" rel="self" type="application/rss+xml"/><item><title>OSV-Scanner Git Submodules: What --include-git-root Changes</title><link>https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/</link><guid>https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/</guid><pubDate>Fri, 04 Dec 2026 04:40:00 +0000</pubDate><dc:creator>John Marshall</dc:creator><category>AppSec &amp; APIs</category><description>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.</description><enclosure url="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" type="image/jpeg" length="0"/><media:content url="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" medium="image" type="image/jpeg" width="1200" height="630"/><content:encoded><![CDATA[<p><img src="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" alt="Close-up of a dense tangle of bare reddish-brown branches crossing over one another" width="1200" height="630"></p><p><strong>Short answer:</strong> OSV-Scanner&rsquo;s documentation says it &ldquo;will automatically scan git submodules&rdquo;, but in the v2.7.1 source the extractor that sends submodule commit hashes to osv.dev only runs when you pass <code>--include-git-root</code>. Without the flag, a C/C++ submodule is found only if it sits directly under a folder such as <code>third_party/</code> or <code>vendor/</code>, and its version is estimated from file hashes rather than read from Git. If your C/C++ dependencies are submodules, run <code>osv-scanner scan source -r --include-git-root .</code> and check the JSON for packages with a <code>commit</code> field.</p>
<p>We reached this by reading the source at tag <code>v2.7.1</code> (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.</p>
<h2 id="two-ways-osv-scanner-finds-cc-code">Two ways OSV-Scanner finds C/C++ code</h2>
<p>C and C++ projects rarely have a lockfile, so OSV-Scanner&rsquo;s <a href="https://google.github.io/osv-scanner-v1/supported-languages-and-lockfiles/">C/C++ support</a> is &ldquo;based on commit-level data&rdquo;. The <code>directory</code> plugin preset, which is on by default for source scans alongside <code>lockfile</code> and <code>sbom</code>, holds two extractors:</p>
<table>
  <thead>
      <tr>
          <th>Extractor</th>
          <th>Triggers on</th>
          <th>What it sends to osv.dev</th>
          <th>Confidence</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>vcs/gitrepo</code></td>
          <td>Any <code>.git</code> <strong>directory</strong></td>
          <td>HEAD commit of that repository, plus the recorded commit of each submodule</td>
          <td>Exact commit</td>
      </tr>
      <tr>
          <td><code>filesystem/vendored</code></td>
          <td>A directory whose <strong>parent folder</strong> is named <code>3rdparty</code>, <code>dep</code>, <code>deps</code>, <code>thirdparty</code>, <code>third-party</code>, <code>third_party</code>, <code>libs</code>, <code>external</code>, <code>externals</code>, <code>vendor</code> or <code>vendored</code></td>
          <td>MD5 hashes of <code>.c</code>, <code>.cc</code>, <code>.cpp</code>, <code>.h</code>, <code>.hh</code>, <code>.hpp</code> files, to the experimental determineversion API</td>
          <td>Best match, used only if its score is above 0.15</td>
      </tr>
  </tbody>
</table>
<p>Both produce a package with a commit and no ecosystem. osv.dev&rsquo;s <a href="https://google.github.io/osv.dev/post-v1-query/"><code>/v1/query</code> endpoint</a> accepts &ldquo;the commit hash to query for&rdquo;. The commit-level data in OSV records comes from <code>GIT</code> ranges, which we covered in <a href="/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/">OSV GIT ranges: commit hashes, fixed vs limit events</a>.</p>
<h2 id="what---include-git-root-actually-switches">What <code>--include-git-root</code> actually switches</h2>
<p>Two lines in <code>pkg/osvscanner/scan.go</code> at v2.7.1 decide the behaviour:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#75715e">// configuring the vendored extractor
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#a6e22e">ScanGitDir</span>: !<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">IncludeGitRoot</span>,
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// building the plugin list
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">if</span> !<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">IncludeGitRoot</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">PluginsDisabled</span> = append(<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">PluginsDisabled</span>, <span style="color:#a6e22e">gitrepo</span>.<span style="color:#a6e22e">Name</span>)
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The flag&rsquo;s help text is &ldquo;include scanning git root (non-submoduled) repositories&rdquo;, and it defaults to <code>false</code>. But disabling <code>vcs/gitrepo</code> turns off more than root scanning:</p>
<ul>
<li><code>vcs/gitrepo</code> only fires on a <code>.git</code> path that is a directory. In a standard modern checkout, a submodule&rsquo;s <code>.git</code> is a small file pointing into the parent&rsquo;s <code>.git/modules/</code>, so the extractor normally fires once, on the superproject&rsquo;s <code>.git</code> directory.</li>
<li>From there it calls go-git&rsquo;s <code>Worktree().Submodules()</code> and emits one commit query per submodule. That loop is the only place in the v2.7.1 source that enumerates submodules.</li>
</ul>
<p>So with the default settings, no submodule commit reaches osv.dev from this extractor. With <code>--include-git-root</code>, you get the superproject&rsquo;s own HEAD commit <strong>and</strong> every submodule&rsquo;s commit.</p>
<p>The flag also flips the vendored extractor&rsquo;s <code>ScanGitDir</code> setting. With the flag, the vendored extractor skips any directory that contains a <code>.git</code> entry, which avoids reporting a submodule twice (once by exact commit, once by hash estimate).</p>
<h2 id="the-two-configurations-side-by-side">The two configurations side by side</h2>
<p>Assume a repository with a submodule at <code>third_party/zlib</code> and another at <code>src/libfoo</code>.</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>Default</th>
          <th><code>--include-git-root</code></th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Superproject HEAD commit queried</td>
          <td>No</td>
          <td>Yes</td>
      </tr>
      <tr>
          <td><code>third_party/zlib</code></td>
          <td>Hashed by the vendored extractor; version estimated</td>
          <td>Queried by exact recorded commit; vendored extractor skips it</td>
      </tr>
      <tr>
          <td><code>src/libfoo</code></td>
          <td><strong>Not scanned</strong> (parent folder <code>src</code> is not on the vendored list, and gitrepo is off)</td>
          <td>Queried by exact recorded commit</td>
      </tr>
      <tr>
          <td>Plain copied code in <code>vendor/libbar</code> (no <code>.git</code>)</td>
          <td>Hashed and estimated</td>
          <td>Hashed and estimated</td>
      </tr>
  </tbody>
</table>
<p>The superproject HEAD query is usually harmless for private code, because osv.dev has no <code>GIT</code> ranges for your repository. It matters if you are scanning a fork of a public project that does have OSV records.</p>
<h2 id="which-commit-is-queried-for-a-submodule">Which commit is queried for a submodule</h2>
<p><code>vcs/gitrepo</code> uses <code>status.Expected</code> from go-git. In go-git v5.19.3, the version OSV-Scanner v2.7.1 pins, <code>Expected</code> is set from the superproject&rsquo;s index entry for the submodule path, before go-git checks whether the submodule is initialised. Two practical results:</p>
<ol>
<li><strong>The recorded commit wins.</strong> If a developer ran <code>git checkout</code> inside a submodule but did not commit the new gitlink in the parent repository, OSV-Scanner still queries the commit the parent repository records.</li>
<li><strong>Uninitialised submodules can still be queried.</strong> The <code>Expected</code> hash comes from the index, not the submodule&rsquo;s files. The documentation&rsquo;s advice to run <code>git submodule update</code> first still matters for the vendored extractor, which needs the files on disk to hash them.</li>
</ol>
<p>If go-git returns an error for a submodule&rsquo;s status, the extractor skips that submodule silently (<code>continue</code>), so a broken submodule checkout can drop out of results without a warning.</p>
<h2 id="reading-commit-based-results">Reading commit-based results</h2>
<p>Commit-matched packages look different from lockfile packages in every output format. Field names below are from <code>pkg/models/results.go</code> at v2.7.1.</p>
<table>
  <thead>
      <tr>
          <th>Output</th>
          <th>Field</th>
          <th>Value for a commit-matched package</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>JSON</td>
          <td><code>results[].source.type</code></td>
          <td><code>git</code> for packages from <code>vcs/gitrepo</code></td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.ecosystem</code></td>
          <td><code>&quot;&quot;</code> (empty string)</td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.commit</code></td>
          <td>Full commit hash</td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.version</code></td>
          <td>Usually empty</td>
      </tr>
      <tr>
          <td>Table</td>
          <td>Ecosystem column</td>
          <td><code>GIT</code></td>
      </tr>
      <tr>
          <td>Table</td>
          <td>Version column</td>
          <td>First 8 characters of the commit</td>
      </tr>
      <tr>
          <td>SARIF</td>
          <td>Version shown in the result text</td>
          <td>Full commit hash</td>
      </tr>
  </tbody>
</table>
<p>In the v2.7.1 source, the location recorded for a submodule is the <code>.git</code> directory path joined with the submodule path, so expect <code>source.path</code> values ending in <code>.git/third_party/zlib</code> rather than <code>third_party/zlib</code>.</p>
<h2 id="check-your-own-repository">Check your own repository</h2>
<p>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.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>git submodule status            <span style="color:#75715e"># list submodules and the commit each is pinned to</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>osv-scanner scan source -r --format json . &gt; default.json
</span></span><span style="display:flex;"><span>osv-scanner scan source -r --include-git-root --format json . &gt; gitroot.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Packages found by commit in each run</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> f in default.json gitroot.json; <span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;== </span>$f<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>  jq -r <span style="color:#e6db74">&#39;.results[] | .source as $s | .packages[]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | select(.package.commit != null)
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | [$s.type, $s.path, .package.commit[0:12], (.vulnerabilities // [] | length)]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | @tsv&#39;</span> <span style="color:#e6db74">&#34;</span>$f<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span></code></pre></div><p>If a submodule from <code>git submodule status</code> appears in <code>gitroot.json</code> but not in <code>default.json</code>, your default scans have been missing it.</p>
<h2 id="from-commit-findings-to-a-patch-decision">From commit findings to a patch decision</h2>
<p>A commit match gives you OSV IDs, not a package version to bump. To decide what to fix first:</p>
<ol>
<li>Read each result&rsquo;s <code>groups[].aliases</code> to find the CVE IDs.</li>
<li>Join those CVEs to the <a href="/posts/cisa-kev-json-feed-what-each-field-means-and-how-to-match-it-against-a-scanner-export/">CISA KEV feed</a> and EPSS.</li>
<li>Fix by moving the submodule to a commit that contains the fix (the <code>fixed</code> commit in the OSV record or a descendant of it), then commit the new gitlink in the parent repository.</li>
</ol>
<p>The full flow from CVE record to ticket is in our <a href="/posts/vulnerability-prioritization-workflow-cve-record-to-patch-ticket/">vulnerability prioritization workflow</a>.</p>
<h2 id="limits-of-this-article">Limits of this article</h2>
<ul>
<li>This is a source reading of OSV-Scanner v2.7.1, not a test run. The <code>main</code> branch has changed <code>scan.go</code> and the source command since that tag, though the lines quoted above have not moved in meaning.</li>
<li>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.</li>
<li>Commit-level coverage is incomplete. The OSV-Scanner documentation warns that &ldquo;there may be vulnerabilities in their dependencies that could be excluded from OSV-Scanner results&rdquo;.</li>
<li>The vendored extractor needs osv.dev. The source disables it when OSV-Scanner runs in offline comparison mode.</li>
</ul>
<h2 id="sources-and-verification">Sources and verification</h2>
<table>
  <thead>
      <tr>
          <th>Important claim</th>
          <th>Source</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Docs say submodules are scanned automatically and root repos are skipped by default</td>
          <td><a href="https://google.github.io/osv-scanner/usage/scan-source">OSV-Scanner: Project Source Scanning</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td><code>vcs/gitrepo</code> disabled unless <code>--include-git-root</code>; vendored <code>ScanGitDir</code> tied to the flag</td>
          <td><a href="https://github.com/google/osv-scanner">google/osv-scanner</a> v2.7.1, <code>pkg/osvscanner/scan.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Flag help text and default <code>false</code></td>
          <td>v2.7.1, <code>cmd/osv-scanner/scan/source/command.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>gitrepo fires on <code>.git</code> directories, queries HEAD and each submodule&rsquo;s <code>Expected</code> commit</td>
          <td>v2.7.1, <code>internal/scalibrextract/vcs/gitrepo/extractor.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td><code>Expected</code> comes from the index entry before the initialisation check</td>
          <td><a href="https://github.com/go-git/go-git">go-git</a> v5.19.3, <code>submodule.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Vendored folder names, file extensions, MD5 hashing, 0.15 threshold, 10,000-file cap</td>
          <td>v2.7.1, <code>internal/scalibrextract/filesystem/vendored/vendored.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Default plugin presets <code>lockfile</code>, <code>sbom</code>, <code>directory</code>; <code>directory</code> holds both extractors</td>
          <td>v2.7.1, <code>pkg/osvscanner/scan.go</code>, <code>internal/scalibrplugin/presets.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Output fields, <code>GIT</code> label and 8-character short commit</td>
          <td>v2.7.1, <code>pkg/models/results.go</code>, <code>internal/output/table.go</code>, <code>internal/utility/results/results.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>osv.dev accepts a commit hash in <code>/v1/query</code></td>
          <td><a href="https://google.github.io/osv.dev/post-v1-query/">osv.dev API: POST /v1/query</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>determineversion estimates vendored C/C++ versions with a confidence score</td>
          <td><a href="https://osv.dev/blog/posts/using-the-determineversion-api/">osv.dev blog: Using the determineversion API</a></td>
          <td>Verified</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item></channel></rss>