Skip to content

Conversation

@GAdityaVarma
Copy link
Collaborator

@GAdityaVarma GAdityaVarma commented Jan 7, 2026

Summary

Introduces a centralized TruffleHog secret scanning workflow that automatically scans all pull requests for exposed secrets (API keys, passwords, tokens, etc.) across the organization.

This implementation:

  • Scans PR commits for leaked secrets (API keys, passwords, tokens, etc.)
  • Classifies findings as verified (confirmed active) or unverified (potential match)
  • Posts PR comments with detailed findings when secrets are detected
  • Sets commit status to pass/fail based on scan results

Features

  • Scans only modified files in PRs (fast and efficient)
  • Works with PRs from forks (public and private)
  • Configurable exclusion patterns using regex
  • Supports org-level defaults with repo-level overrides
  • No workflow file needed in individual repos (uses org rulesets)

How It Works

  1. PR is created or updated
  2. Workflow determines PR type (fork vs same-repo)
  3. Fetches PR commits and applies exclusion patterns
  4. Runs TruffleHog scan on the diff between base and head
  5. If secrets found: posts PR comment and fails the check
  6. If no secrets: sets status to success (no comment posted)

Configuration

  • Set TRUFFLEHOG_EXCLUDES variable at org or repo level for custom exclusions
  • Default exclusions include: node_modules, vendor, lock files, minified files

Tested here:
https://github.com/marklogic/copyrighttest/pull/79
https://github.com/marklogic/copyrighttest/pull/78
https://github.com/marklogic/copyrighttest/pull/77

Introduces a centralized GitHub Actions workflow for scanning pull requests for secrets using TruffleHog. Includes a detailed README with setup instructions, exclusion pattern configuration, override options, and troubleshooting guidance.
The workflow now posts PR comments with secret scan findings, sets commit status to pass/fail, and provides clearer merge blocking. Documentation was updated and renamed to trufflehog_readme.md to reflect new features, including secret classification and improved fork PR support.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a centralized TruffleHog secret scanning workflow that automatically validates pull requests across the organization by detecting exposed secrets such as API keys, passwords, and tokens. The workflow runs on all PRs, posts detailed findings as comments when secrets are detected, and sets commit statuses to block merges when necessary.

Key Changes:

  • Implements GitHub Actions workflow with dual triggers (pull_request and pull_request_target) to handle both same-repo and fork PRs
  • Configurable exclusion patterns via TRUFFLEHOG_EXCLUDES variable with org-level defaults and repo-level overrides
  • Automated PR commenting with remediation steps and commit status updates based on scan results

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
trufflehog_readme.md Comprehensive documentation covering setup, configuration, exclusion patterns, workflow triggers, and troubleshooting
.github/workflows/trufflehog-scan.yml GitHub Actions workflow implementing secret scanning with TruffleHog, exclusion handling, result processing, and PR status updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GAdityaVarma GAdityaVarma requested review from Pragathi-28 and brijeshp56 and removed request for Copilot January 7, 2026 13:33
echo "${{ vars.TRUFFLEHOG_EXCLUDES }}" | tr ',' '\n' | sed '/^$/d' > .trufflehog-ignore
else
echo "Using default exclusions from central workflow"
cat << 'EOF' > .trufflehog-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it better to include the defaults always?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Updated the logic to make exclusions additive instead of replacement.

echo "description=No secrets detected in PR changes" >> $GITHUB_OUTPUT
fi
- name: Post PR comment on findings
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need a comment? Can't we just rely on annotations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why PR Comments are better for security findings:

  • Immediate visibility - Developers see the alert without extra navigation
  • Actionable - The comment includes remediation steps right there
  • Email notification - PR comment triggers email, ensuring developer sees it
  • Historical record - Comment stays in PR history for auditing
  • Team visibility - Reviewers also see the security issue immediately
  • Mobile-friendly - Easy to check on phone

uses: actions/github-script@v7
with:
script: |
const commentMarker = '<!-- TRUFFLEHOG-SCAN-COMMENT -->';
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're planning to add comment then we need to add the following to commit so the user know if the scan ran on the latest changes/commit.

  1. Commit ID/SHA.
  2. Workflow Link/Number to get to the correct logs.

4. **Push the fix** to this branch
### Finding Details
Check the [workflow run logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for:
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like workflow link is already added, please ignore my previous comment and just add the commit ID to the comment.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🚨 Secret Scanning Alert

TruffleHog detected potential secrets in this pull request.

What to do:

  1. Remove the exposed secret from your code
  2. Rotate the credential immediately - assume it's compromised
  3. Push the fix to this branch
  4. The scan will re-run automatically

Finding Details

Check the workflow run logs for:

  • File paths containing secrets
  • Line numbers
  • Secret types (API key, password, token, etc.)
  • Verification status (verified = confirmed active)

Workflow Logs

View detailed scan logs


This scan only checks files modified in this PR. Secrets are classified as verified (confirmed active) or unverified (potential match).

Adds a workflow step to update the PR comment when previously detected secrets are resolved, marking the PR as clear. Updates documentation to clarify that exclusion patterns are additive, describes the new comment update behavior, and improves the remediation and PR comment sections for clarity.
@GAdityaVarma GAdityaVarma reopened this Jan 9, 2026
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.

3 participants