Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/actions/detect-secrets/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Detect Secrets Action
description: |
Scan the repository for secrets using the following tools:
1. Gitleaks: https://github.com/gitleaks/gitleaks
2. TruffleHog: https://github.com/trufflesecurity/trufflehog
3. detect-secrets: https://github.com/Yelp/detect-secrets
4. git-secrets: https://github.com/awslabs/git-secrets
5. Talisman: https://github.com/thoughtworks/talisman
6. credential-digger: https://github.com/SAP/credential-digger
7. kingfisher: https://github.com/mongodb/kingfisher

inputs:
github-token:
description: GitHub token for authentication
required: true
default: ${{ github.token }}
gitleaks-license:
description: Gitleaks license key for enterprise features
required: true
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The 'gitleaks-license' input is marked as required but has a default value of empty string. An input cannot be both required and have an empty default. Either set 'required: false' if the license is optional, or remove the default value if it's truly required.

Suggested change
required: true
required: false

Copilot uses AI. Check for mistakes.
default: ""

runs:
using: "composite"
steps:
- uses: actions/checkout@v6.0.1
with:
fetch-depth: 0

- name: Prepare report directory
shell: bash
run: mkdir -p secrets_report

- name: Setup Python
uses: actions/setup-python@v6.1.0
with:
python-version: "3.12.12"

- name: Install jq
shell: bash
run: sudo apt-get update && sudo apt-get install -y jq

- name: Install detect-secrets
shell: bash
run: pip install detect-secrets

- name: Run detect-secrets
continue-on-error: true
shell: bash
run: |
detect-secrets scan --force-use-all-plugins > secrets_report/detect_secrets.json

- name: Install git-secrets
shell: bash
run: |
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets
sudo make install
cd ..

- name: Run git-secrets
continue-on-error: true
shell: bash
run: git secrets --scan -r . | tee secrets_report/git_secrets.txt

- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2.3.9
continue-on-error: true
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
GITLEAKS_LICENSE: ${{ inputs.gitleaks-license }}

- name: Install Talisman
shell: bash
run: bash -c "$(curl --silent https://raw.githubusercontent.com/thoughtworks/talisman/main/install.sh)"
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

Installing software by piping curl output directly to bash poses a security risk as it executes arbitrary code from a remote source without validation. Consider downloading the script first, reviewing it, and then executing it, or use a specific versioned release with checksum verification.

Suggested change
run: bash -c "$(curl --silent https://raw.githubusercontent.com/thoughtworks/talisman/main/install.sh)"
run: |
set -euo pipefail
curl --fail --show-error --silent --location \
-o /tmp/talisman-install.sh \
https://raw.githubusercontent.com/thoughtworks/talisman/main/install.sh
bash /tmp/talisman-install.sh

Copilot uses AI. Check for mistakes.

- name: Run Talisman
continue-on-error: true
shell: bash
run: |
talisman --scan || true
if [ -f talisman_report/talisman_reports/data/report.json ]; then
cp talisman_report/talisman_reports/data/report.json secrets_report/talisman.json
num_failures=$(jq '.failures // [] | length' secrets_report/talisman.json)
if [ "$num_failures" -gt 0 ]; then
echo "Secrets found by Talisman: $num_failures"
fi
fi

- name: Install dependencies for credential-digger
shell: bash
run: sudo apt install -y build-essential python3-dev

- name: Install credential-digger
shell: bash
run: pip install credentialdigger

- name: Download rules for credential-digger
shell: bash
run: curl -O https://raw.githubusercontent.com/SAP/credential-digger/main/ui/backend/rules.yml

- name: Add rules for credential-digger
shell: bash
run: credentialdigger add_rules --sqlite /tmp/cred.db ./rules.yml

- name: Run credential-digger
continue-on-error: true
shell: bash
run: |
credentialdigger scan . --sqlite /tmp/cred.db --models PathModel PasswordModel | tee secrets_report/credential_digger.txt
cp /tmp/cred.db secrets_report/credential_digger.db || true
[ -f rules.yml ] && cp rules.yml secrets_report/ || true

- name: Install kingfisher
shell: bash
run: curl --silent --location https://raw.githubusercontent.com/mongodb/kingfisher/main/scripts/install-kingfisher.sh | bash
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

Installing software by piping curl output directly to bash poses a security risk as it executes arbitrary code from a remote source without validation. Consider downloading the script first, reviewing it, and then executing it, or use a specific versioned release with checksum verification.

Copilot uses AI. Check for mistakes.

- name: Run kingfisher
continue-on-error: true
shell: bash
run: kingfisher scan . --exclude secrets_report/* | tee secrets_report/kingfisher.txt

- name: Install TruffleHog v3 binary
continue-on-error: true
Comment on lines +122 to +123
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The TruffleHog installation uses 'continue-on-error: true' which means if the installation fails, the workflow will continue without running TruffleHog. This silently skips the scan if installation fails. Consider moving this flag to the 'Run TruffleHog' step instead, or add explicit validation that the binary was installed successfully before attempting to run it.

Copilot uses AI. Check for mistakes.
shell: bash
run: |
set -euo pipefail
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The step uses 'set -euo pipefail' for strict error handling, but the parent step has 'continue-on-error: true' which negates the benefit of strict error handling. If installation fails, it will continue silently. This creates inconsistent error handling behavior.

Suggested change
set -euo pipefail

Copilot uses AI. Check for mistakes.
TRH_VER=3.92.4
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The TruffleHog version is hardcoded as '3.92.4' in the script. This makes it difficult to maintain and update. Consider extracting this as an input parameter with a default value, or using 'latest' from the GitHub releases API to avoid manually updating version numbers.

Copilot uses AI. Check for mistakes.
TMPDIR="$(mktemp -d)"
curl -sSL -o "$TMPDIR/trufflehog.tar.gz" "https://github.com/trufflesecurity/trufflehog/releases/download/v${TRH_VER}/trufflehog_${TRH_VER}_linux_amd64.tar.gz"
tar -xzf "$TMPDIR/trufflehog.tar.gz" -C "$TMPDIR"
install "$TMPDIR/trufflehog" "$RUNNER_TEMP/trufflehog"
chmod +x "$RUNNER_TEMP/trufflehog"
Comment on lines +131 to +132
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The TruffleHog binary is installed to a temporary directory using '$RUNNER_TEMP' but is not added to the PATH. If the subsequent 'Run TruffleHog' step fails to execute, it will be difficult to debug whether the issue is a missing binary or an actual scan failure. Consider adding the binary to a well-known location or validating its presence before the scan step.

Copilot uses AI. Check for mistakes.

- name: Run TruffleHog (filesystem JSON)
continue-on-error: true
shell: bash
env:
TRUFFLEHOG_NO_UPDATE: "1"
run: |
"$RUNNER_TEMP/trufflehog" filesystem . --json --only-verified 2>&1 | tee secrets_report/trufflehog.json

- name: Upload combined results artifact
uses: actions/upload-artifact@v6.0.0
with:
name: secrets-scan-results
path: secrets_report
23 changes: 23 additions & 0 deletions .github/workflows/detect-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Secrets Scan Workflow
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
id-token: write
pull-requests: write

jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.1
- uses: ./.github/actions/detect-secrets
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
gitleaks-license: ${{ secrets.GITLEAKS_LICENSE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
Loading