feat(git): check out submodules, each URL held to the remote's checks #347

Merged
sharang merged 1 commits from feat/git-submodules into main 2026-09-23 14:29:06 +00:00
Owner

Part of the pilot P0 (#338), item D (submodules). Stacked on #346.

Why

Firmware repositories pull their HAL, RTOS or protocol stack in as submodules. They were never fetched, so a scan missed code the product ships and did not say so.

What

  • New pipeline/git_submodules.rs, GitOps::update_submodules(repo_path, origin_url):
    • checks out submodules recursively, up to 3 levels, after clone/fetch; called by the scan pipeline and by ingest (classification);
    • relative URLs (../hal.git) are resolved against the parent remote the way git does, and cannot climb above the host;
    • every URL goes through reject_ssh_url and check_remote (net guard plus DNS check) with redirects off, like the main remote;
    • the checked URL is written to submodule.<name>.url in the local config, so libgit2 fetches exactly that URL;
    • the repository's token goes only to the main remote's host; other hosts are fetched anonymously.
  • A refused or failed submodule is left out and recorded:
    • a git_submodules skipped stage on the scan run ("not checked out, so not scanned: hal (git@…): SSH git URLs are not supported …");
    • a submodule_skipped fact at ingest;
    • the dashboard labels the stage "Git-Submodule".

Verification

  • Unit tests:
    • relative URL resolution (../, ./, ../../, above the host, absolute);
    • an SSH submodule and a private-address submodule are both reported and not fetched.
  • clippy with the CI flags; fmt.
  • Real-world check (local agent image built from this branch): onboarded https://github.com/libopencm3/libopencm3-template (its libopencm3 submodule is on GitHub) as a git target and scanned it:
    • the run completed with no skipped stage;
    • libopencm3/ was checked out in both the scan clone and the ingest clone (COPYING.GPL3, Makefile, … present).
  • Still to do on staging: a submodule on the same private host as the main repository, so the token is reused for it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Part of the pilot P0 (#338), item D (submodules). **Stacked on #346.** ## Why Firmware repositories pull their HAL, RTOS or protocol stack in as submodules. They were never fetched, so a scan missed code the product ships and did not say so. ## What - New `pipeline/git_submodules.rs`, `GitOps::update_submodules(repo_path, origin_url)`: - checks out submodules recursively, up to 3 levels, after clone/fetch; called by the scan pipeline and by ingest (classification); - relative URLs (`../hal.git`) are resolved against the parent remote the way git does, and cannot climb above the host; - every URL goes through `reject_ssh_url` and `check_remote` (net guard plus DNS check) with redirects off, like the main remote; - the checked URL is written to `submodule.<name>.url` in the local config, so libgit2 fetches exactly that URL; - the repository's token goes only to the main remote's host; other hosts are fetched anonymously. - A refused or failed submodule is left out and **recorded**: - a `git_submodules` skipped stage on the scan run ("not checked out, so not scanned: hal (git@…): SSH git URLs are not supported …"); - a `submodule_skipped` fact at ingest; - the dashboard labels the stage "Git-Submodule". ## Verification - Unit tests: - relative URL resolution (`../`, `./`, `../../`, above the host, absolute); - an SSH submodule and a private-address submodule are both reported and not fetched. - clippy with the CI flags; fmt. - **Real-world check (local agent image built from this branch):** onboarded `https://github.com/libopencm3/libopencm3-template` (its `libopencm3` submodule is on GitHub) as a git target and scanned it: - the run **completed** with no skipped stage; - `libopencm3/` was checked out in both the scan clone and the ingest clone (`COPYING.GPL3`, `Makefile`, … present). - Still to do on staging: a submodule on the same private host as the main repository, so the token is reused for it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang changed target branch from feat/git-credentials to main 2026-09-23 14:19:26 +00:00
sharang added 1 commit 2026-09-23 14:19:26 +00:00
feat(git): check out submodules, each URL held to the remote's checks
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 9m9s
7c638c1068
Firmware repositories pull their HAL, RTOS or protocol stack in as
submodules. They were never fetched, so a scan of such a repository
missed code the product ships and did not say so.

- Submodules are checked out after the clone or fetch, recursively up to
  three levels, for the scan and for classification.
- Each URL (relative ones resolved as git does) must pass the same checks
  as the main remote: HTTPS only, a public host, no redirects. The URL
  that was checked is written to the local config, so it is the one
  fetched.
- The repository's token is offered only to the main remote's host; a
  submodule elsewhere is fetched anonymously.
- A submodule that is refused or fails is left out and recorded: a
  `git_submodules` skipped stage on the scan run (with a German label in
  the dashboard) and a `submodule_skipped` fact at ingest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/git-submodules from 7c7657d90b to 7c638c1068 2026-09-23 14:19:26 +00:00 Compare
sharang merged commit 338849d050 into main 2026-09-23 14:29:06 +00:00
Sign in to join this conversation.