feat(git): bounded clones, Git LFS made visible, app build output left out #450

Merged
sharang merged 1 commits from feat/large-repos into main 2026-10-05 14:05:20 +00:00
Owner

#435, the part needed for tomorrow's first scans (the largest repo is ~830 MB plus ~400 MB LFS).

Clone and fetch with limits (pipeline/git.rs)

  • CloneLimits, set per deployment:
    • GIT_CLONE_TIMEOUT_SECS, default 1800;
    • GIT_CLONE_MAX_MB, default 4096;
    • GIT_CLONE_DEPTH, default unset, meaning the full history.
  • How it stops: libgit2's transfer-progress callback aborts the transfer once either limit is exceeded. The run then fails with that reason ("…did not download within 30 minutes (GIT_CLONE_TIMEOUT_SECS)" / "…larger than the download limit of 4096 MB (GIT_CLONE_MAX_MB)") instead of a generic libgit2 error, or never finishing.
  • No half-finished clone is left behind. Before, the next run would have tried to fetch it.
  • Depth is optional. A shallow history would break the secret scan of earlier commits (gitleaks detect) and the PR review diff, so the default stays the full history.
  • Not covered: a connection that hangs before any data arrives. libgit2's global server timeout needs unsafe.

Git LFS made visible

libgit2 runs no LFS filter, so LFS files stay pointer files in the checkout. They are not downloaded or scanned, which is right for binary assets but used to be invisible.

  • If .gitattributes keeps patterns in LFS, the run now records a skipped stage lfs_objects (new SkipCode::LfsNotFetched, DE/EN) with the patterns.

App build output counts as vendor code (pipeline/vendor.rs)

This is a separate function at the end of is_vendor_dir, so the .NET exclusions from #447 rebase trivially.

  • Gradle: build/ beside a build.gradle(.kts), and .gradle/.
  • iOS: Pods/ beside a Podfile, Carthage/ beside a Cartfile, and DerivedData/.
  • Unity (beside ProjectSettings/): Library/, Temp/, Obj/, Logs/, Builds/, UserSettings/, and the Asset Store packages in Assets/Plugins/.
  • A customer's own tools/build/ or src/plugins/ stays their code (tested).
  • These directories are left out of SAST, mobsfscan, patterns, secrets and lint, and listed as vendor code on the run.

Checks

  • Unit tests:
    • the limits (time, size, defaults);
    • LFS patterns from .gitattributes;
    • mobile and Unity build output left out;
    • build/plugins outside such projects kept.
  • Network test (--ignored, run locally): github/gitignore with a 64 KB limit stops with the GIT_CLONE_MAX_MB message and leaves no directory behind, and octocat/Hello-World clones through the same path.
  • fmt, plus clippy with the CI flags on core, agent and both dashboard feature sets. Tests: agent lib 535, dashboard 80.
  • Docs: "Large Repositories and Git LFS" in repositories.md, and the vendor list in tools.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

#435, the part needed for tomorrow's first scans (the largest repo is ~830 MB plus ~400 MB LFS). ## Clone and fetch with limits (`pipeline/git.rs`) - **`CloneLimits`**, set per deployment: - `GIT_CLONE_TIMEOUT_SECS`, default 1800; - `GIT_CLONE_MAX_MB`, default 4096; - `GIT_CLONE_DEPTH`, default unset, meaning the full history. - **How it stops:** libgit2's transfer-progress callback aborts the transfer once either limit is exceeded. The run then fails with that reason ("…did not download within 30 minutes (GIT_CLONE_TIMEOUT_SECS)" / "…larger than the download limit of 4096 MB (GIT_CLONE_MAX_MB)") instead of a generic libgit2 error, or never finishing. - **No half-finished clone is left behind.** Before, the next run would have tried to `fetch` it. - **Depth is optional.** A shallow history would break the secret scan of earlier commits (`gitleaks detect`) and the PR review diff, so the default stays the full history. - **Not covered:** a connection that hangs before any data arrives. libgit2's global server timeout needs `unsafe`. ## Git LFS made visible libgit2 runs no LFS filter, so LFS files stay pointer files in the checkout. They are not downloaded or scanned, which is right for binary assets but used to be invisible. - If `.gitattributes` keeps patterns in LFS, the run now records a skipped stage `lfs_objects` (new `SkipCode::LfsNotFetched`, DE/EN) with the patterns. ## App build output counts as vendor code (`pipeline/vendor.rs`) This is a separate function at the end of `is_vendor_dir`, so the .NET exclusions from #447 rebase trivially. - **Gradle:** `build/` beside a `build.gradle(.kts)`, and `.gradle/`. - **iOS:** `Pods/` beside a `Podfile`, `Carthage/` beside a `Cartfile`, and `DerivedData/`. - **Unity** (beside `ProjectSettings/`): `Library/`, `Temp/`, `Obj/`, `Logs/`, `Builds/`, `UserSettings/`, and the Asset Store packages in `Assets/Plugins/`. - A customer's own `tools/build/` or `src/plugins/` stays their code (tested). - These directories are left out of SAST, mobsfscan, patterns, secrets and lint, and listed as vendor code on the run. ## Checks - **Unit tests:** - the limits (time, size, defaults); - LFS patterns from `.gitattributes`; - mobile and Unity build output left out; - `build`/`plugins` outside such projects kept. - **Network test** (`--ignored`, run locally): `github/gitignore` with a 64 KB limit stops with the `GIT_CLONE_MAX_MB` message and leaves no directory behind, and `octocat/Hello-World` clones through the same path. - fmt, plus clippy with the CI flags on core, agent and both dashboard feature sets. Tests: agent lib 535, dashboard 80. - Docs: "Large Repositories and Git LFS" in `repositories.md`, and the vendor list in `tools.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-05 13:48:45 +00:00
feat(git): bounded clones, Git LFS made visible, app build output left out
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 10m48s
f9480d3ba2
For large repositories (hundreds of MB plus LFS assets):
- A clone or fetch stops once its transfer exceeds GIT_CLONE_TIMEOUT_SECS
  (default 30 min) or GIT_CLONE_MAX_MB (default 4096), and the run fails
  with that reason instead of holding a scan slot. A failed clone no
  longer leaves a half-cloned directory that the next run would fetch.
  GIT_CLONE_DEPTH optionally clones a shallow history; unset (the
  default) keeps the full history the secret scan and PR reviews need.
- libgit2 runs no LFS filter, so LFS files stay pointer files. A repository
  whose .gitattributes keeps files in LFS now records a skipped
  `lfs_objects` stage (SkipCode::LfsNotFetched) listing the patterns.
- Committed build output and installed third-party code of apps count as
  vendor code: Gradle build/ beside a build.gradle and .gradle/, Pods/
  beside a Podfile, Carthage/ beside a Cartfile, DerivedData/, and in a
  Unity project Library/, Temp/, Obj/, Logs/, Builds/, UserSettings/ and
  Assets/Plugins/. Matched only beside the file that makes them so.

Refs #435.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 2cbd98e5c0 into main 2026-10-05 14:05:20 +00:00
Sign in to join this conversation.