Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure no API key is inside our repos #174

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MY_API_KEY=super-secret-api-key
MY_SUPER_SECRET_PASSWORD=this-is-my-password
Empty file.
58 changes: 58 additions & 0 deletions .github/workflows/workflow-detect-secret-leaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Detect secrets leaks

Check warning on line 1 in .github/workflows/workflow-detect-secret-leaks.yml

View workflow job for this annotation

GitHub Actions / yaml-lint-check

1:1 [document-start] missing document start "---"

on:
workflow_call:
push:
branches:
- '**'

jobs:
detect-secret-leaks:
runs-on: gh-runner
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3

# https://github.com/hashicorp/vault-action?tab=readme-ov-file#multiple-secrets
# https://github.com/hashicorp/vault-action?tab=readme-ov-file#example-usage
- name: Authenticate with Vault using GitHub OIDC and retrieve secrets
uses: hashicorp/[email protected]
with:
url: https://vault.vault.svc.cluster.local:8200
method: github
tlsSkipVerify: true
githubToken: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/test * | VAULTACTIONKEY_;

- name: Install git-secrets
run: |
sudo apt-get update
sudo apt-get install -y git build-essential
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets
sudo make install

- name: Add API keys to git-secrets
run: |
set +H
set -f
for var in $(compgen -e VAULTACTIONKEY_); do
value="${!var}"
if [ -n "$value" ]; then
git secrets --add --literal "$value" || echo "git secrets failed for variable $var" >&2
else
echo "Skipping empty variable $var"
fi
done

- name: Scan repository for secrets
run: |
git secrets --scan -r

- name: Remove git-secrets patterns
run: |
git config --remove-section git-secrets || true
Loading