Skip to content

fix(ingestion): keep host Git templates out of URL scans - #1161

Open
rng1995 wants to merge 3 commits into
mainfrom
naren/skillspect-53-git-template-provenance
Open

rng1995 wants to merge 3 commits into
mainfrom
naren/skillspect-53-git-template-provenance

Conversation

@rng1995

@rng1995 rng1995 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Clone Git URLs with an explicit empty template. Files from the operator’s Git template directory can otherwise enter the temporary snapshot and be reported as findings on the remote source. Credential handling, ref selection, ingestion limits, and local directory scans keep their existing behavior.

Validation

  • Both host template cases failed on the base and passed on the candidate. Six live HTTPS CLI scans corroborated the fixture-backed checks, with hooks disabled. Both template settings now match the clean URL clone, and the fixture tests still detect the tracked and local executables.
  • Focused validation passed with 222 tests and one skip. Independent review passed 18 tests. Lint, formatting, and diff checks passed.
  • The first full local coverage run reported 26,958 passed, 71 failed, 41 skipped, and 4 expected failures. The follow-up commit updates one transitive-clone assertion to expect the new option. Focused verification of the follow-up passed 157 tests with one skip.
  • Serial coverage reruns of the 71 failed tests gave 59 passed and 12 failed on the first candidate, and 66 passed and 5 failed on the exact base. All 51 loopback HTTP tests passed in both reruns. On the final head, 10 of the 11 non-Git failures from the serial coverage retry passed in a further serial retry without coverage. The remaining dense-directory timing failure also reproduced on the base.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
@rng1995
rng1995 marked this pull request as ready for review November 20, 2026 19:45
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two follow-ups for the Git provenance regression tests.

Comment thread tests/nodes/test_git_scan_provenance.py Resolved
Comment thread tests/nodes/test_git_scan_provenance.py Resolved
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>

@tonydzi tonydzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read _clone_git and _git_invocation in full, plus the three test files.

The --template= fix looks right to me. I checked it locally with git 2.53: with GIT_TEMPLATE_DIR set, a plain --depth 1 clone copies the template's hooks/post-checkout and info/ entries into .git. With --template= neither directory is created, and git status and git fetch still work in the resulting clone.

One uncovered case, in tests/unit/test_input_handler.py (around line 779 and lines 844-850): the test puts GIT_TEMPLATE_DIR into the ambient environment, but it only asserts that --template= is in the command. It never asserts that the variable is absent from the env that reaches git. In the untrusted path that absence comes only from the allowlist in _git_invocation, so a later edit that adds the name to the allowlist would go unnoticed. The new end-to-end test in test_git_scan_provenance.py also runs with the default allow_git_credentials=True, so it only exercises the trusted path, where env is None. That makes the isolated (MCP) path, the one this hardening matters most for, covered by the command-line assertion alone.

A one-line assert "GIT_TEMPLATE_DIR" not in env next to the existing env asserts would close it.

I did not run your test suite, only the git behaviour above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants