Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
nlgripto committed Nov 18, 2024
1 parent c689d36 commit 160eaa0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/dontstealmesecrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint secrets:inherit usage

on:
pull_request:
paths:
- '.github/workflows/**'

jobs:
check-secrets-inherit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check for secrets:inherit in PR workflows
run: |
found_issue=false
for file in .github/workflows/*.{yml,yaml}; do
if [ -f "$file" ] && [ "$(basename "$file")" != "lint-secrets.yml" ]; then
if grep -l "on:.*pull_request" "$file" >/dev/null; then
line_num=$(grep -n "secrets:\s*inherit" "$file" | cut -d: -f1)
if [ ! -z "$line_num" ]; then
echo "::error file=$file,line=$line_num::Security risk: 'secrets: inherit' used in pull request workflow. This could allow secret exfiltration by malicious PRs."
found_issue=true
fi
fi
fi
done
if [ "$found_issue" = true ]; then
exit 1
fi

0 comments on commit 160eaa0

Please sign in to comment.