Skip to content

Commit

Permalink
yarn build in workflow. search whole repo in script
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiechayes committed Sep 28, 2023
1 parent c127ed6 commit f65a7ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/guard-api-key-leak.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Guard API Key Leak
on: [push, pull_request]
on: push

jobs:
detect-key-leak:
Expand All @@ -9,6 +9,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v3

- name: yarn build
run: yarn build
working-directory: ./generator/konfig-dash

- name: Detect API key leaks
run: ./guard-api-key-leak.sh
working-directory: generator/konfig-dash/bash_scripts
working-directory: ./generator/konfig-dash/bash_scripts
8 changes: 6 additions & 2 deletions generator/konfig-dash/bash-scripts/guard-api-key-leak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
keyFile="../api/src/lib/api-keys.ts"
apiKeys=($(grep -oE '[A-Za-z0-9]{32}:' "$keyFile" | sed 's/://'))

searchFolder="../packages"
searchFolder="../../.." # entire repo
foundKey=false

for apiKey in "${apiKeys[@]}"; do
files=$(grep -rl "$apiKey" "$searchFolder")
files=$(grep -rl "$apiKey" "$searchFolder" \
--exclude=../../../generator/konfig-dash/.redwood/prebuild/api/src/lib/api-keys.js \
--exclude=../../../generator/konfig-dash/api/dist/lib/api-keys.js.map \
--exclude=../../../generator/konfig-dash/api/dist/lib/api-keys.js \
--exclude=../../../generator/konfig-dash/api/src/lib/api-keys.ts)
if [ -n "$files" ]; then
foundKey=true
echo "ERROR: Security risk detected. API key leaked in the following file(s):"
Expand Down

0 comments on commit f65a7ac

Please sign in to comment.