Skip to content

feat(scanner): add --show to print git show per oops commit (#2)#10

Open
ChrisJr404 wants to merge 1 commit into
trufflesecurity:mainfrom
ChrisJr404:feat/git-show-flag-2
Open

feat(scanner): add --show to print git show per oops commit (#2)#10
ChrisJr404 wants to merge 1 commit into
trufflesecurity:mainfrom
ChrisJr404:feat/git-show-flag-2

Conversation

@ChrisJr404
Copy link
Copy Markdown

@ChrisJr404 ChrisJr404 commented May 4, 2026

Closes #2@peter17 asked for an option that prints `git show ` per oops commit so they could review the content manually or pipe it to an external tool.

Adds a `--show` flag with three useful modes:

Invocation Behaviour
`--show` Print `git show ` for every force-pushed commit. Skips trufflehog.
`--show --scan` Print the diff AND run trufflehog on each commit.
`--scan` alone Unchanged.
Neither Unchanged (gather + report only).

The patch threads two kwargs (`show`, `scan`) into the existing `scan_commits` so the per-commit loop can switch behaviour without forking the clone / base-commit-identification / SHA-validation path. Each diff is preceded by a `[git show ]` header so multi-commit output stays parseable when piped, and `--no-color` is set so the output is grep-friendly.

A bad single `git show` (e.g. orphaned ref) is wrapped in the existing `RunCmdError` handler so it doesn't abort the rest of the run.

Test plan

  • Syntax check passes (`python3 -c 'import ast; ast.parse(open(...).read())'`)
  • argparse `--show` flag wires up correctly
  • `scan_commits` signature picks up the new kwargs
  • No-color output is grep-friendly
  • (For maintainer) — exercise against a real org with known oops commits to confirm the rendered output reads well in a terminal

Note

Low Risk
Low risk: adds an optional CLI output mode and threads flags through scan_commits without changing the existing scan behavior unless the new flag is used.

Overview
Adds a new --show mode that prints git show --no-color <commit> output for each force-pushed commit, prefixed with a [git show <sha>] header for easier multi-commit parsing.

Updates scan_commits to accept show/scan toggles so --show can run alone (skipping trufflehog) or alongside --scan (print diff then scan), and adjusts main() to invoke scanning when either flag is set while handling git show failures per-commit without aborting the run.

Reviewed by Cursor Bugbot for commit 15ebf0d. Bugbot is set up for automated code reviews on this repo. Configure here.

…ecurity#2)

Implements the request from trufflesecurity#2: let users review the content of each
force-pushed "oops commit" directly, or pipe it to an external tool,
without needing to enable the full trufflehog scan path.

Behaviour:

  --show           print `git show <commit>` for every force-pushed
                   commit. Skips the trufflehog scan entirely unless
                   --scan is also supplied.
  --show --scan    print the diff AND run trufflehog. Useful when a
                   reviewer wants both the raw patch and the secret
                   findings side-by-side.
  --scan (alone)   unchanged from current behaviour.
  (neither)        unchanged — gather + report only.

`scan_commits` now takes `show: bool` and `scan: bool` kwargs so the
per-commit loop can switch behaviour without forking the whole repo
clone path. The clone, base-commit identification, and SHA validation
are all reused.

`git show` runs with `--no-color` so the output stays grep-friendly
when piped, and is wrapped in the existing `RunCmdError` handler so a
single bad commit doesn't abort the rest of the run. Each diff is
preceded by a `[git show <sha>]` header so multi-commit output is
parseable.

Verified: syntax check passes, argparse wiring for the new flag is
correct, scan_commits signature picks up the new kwargs.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 4, 2026

CLA assistant check
All committers have signed the CLA.

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.

Suggestion: git show

2 participants