Skip to main content

populate_submodules

Function populate_submodules 

Source
pub fn populate_submodules(worktree: &Path) -> Result<Vec<String>>
Expand description

Recursively check out a super-repo’s submodules inside worktree so their files are present for analysis. Best-effort: a repo with no .gitmodules is a no-op, and a submodule whose fetch fails simply stays empty (its per-submodule breakdown is then blank) rather than failing the whole scan.

Security: git submodule update would clone whatever URLs .gitmodules records, which bypasses the SSRF gate that guards the top-level clone. Every recorded submodule URL is therefore validated with the same [validate_clone_url] check first; a submodule whose URL is rejected is skipped (and its name returned) instead of being fetched. Relative submodule URLs resolve against the superproject origin and cannot target a new host, so they are allowed; absolute local/file:// submodule references are refused (a legitimate local super-repo references its submodules by relative path).

Returns the names of submodules that were skipped as unsafe.

§Errors

Returns an error only if the working tree cannot be inspected; a failed submodule fetch is swallowed (best-effort).