Repository navigation
Conversation
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
rng1995
left a comment
There was a problem hiding this comment.
Two follow-ups for the Git provenance regression tests.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
tonydzi
left a comment
There was a problem hiding this comment.
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.
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