CI: direct gitleaks full-scan (robust to force-push); IP check skips docs/tests
This commit is contained in:
parent
df50b5a805
commit
5f98e38845
25
.github/workflows/security-scan.yml
vendored
25
.github/workflows/security-scan.yml
vendored
@ -1,9 +1,9 @@
|
|||||||
name: security-scan
|
name: security-scan
|
||||||
|
|
||||||
# Max-heuristic push safeguard (server-side). gitleaks = entropy + 150+ curated
|
# Max-heuristic, reliable push safeguard. Direct gitleaks FULL scan (entropy +
|
||||||
# secret rules over full history; plus key/.env/weight-file and private-IP checks.
|
# 150+ rules, respects .gitleaks.toml) — no partial/range scan, so force-pushes
|
||||||
# Any hit fails the check and blocks the merge. .gitleaks.toml allowlists confirmed
|
# and history rewrites don't break it. Plus key/.env/weight-file and private-IP
|
||||||
# false-positives (test fixtures, doc placeholders) per repo.
|
# checks (the IP check skips docs/tests/examples to avoid flagging sample IPs).
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -19,21 +19,22 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: gitleaks (entropy + curated rules, full history)
|
- name: gitleaks full scan (entropy + curated rules)
|
||||||
uses: gitleaks/gitleaks-action@v2
|
run: |
|
||||||
env:
|
curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.24.3/gitleaks_8.24.3_linux_x64.tar.gz -o /tmp/gl.tgz
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
tar -xzf /tmp/gl.tgz -C /tmp gitleaks
|
||||||
|
/tmp/gitleaks detect --source . --no-banner --redact --exit-code 1
|
||||||
- name: key / .env / weight files
|
- name: key / .env / weight files
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
HITS=$(find . -path ./.git -prune -o -type f \( -name '*.key' -o -name '*.pem' -o -name '.env' -o -name '*.safetensors' -o -name '*.gguf' \) -print | grep -v '.env.example' || true)
|
HITS=$(find . -path ./.git -prune -o -type f \( -name '*.key' -o -name '*.pem' -o -name '.env' -o -name '*.safetensors' -o -name '*.gguf' \) -print | grep -v '.env.example' || true)
|
||||||
if [ -n "$HITS" ]; then echo "::error::key/.env/weight file committed:"; echo "$HITS"; exit 1; fi
|
if [ -n "$HITS" ]; then echo "::error::key/.env/weight file committed:"; echo "$HITS"; exit 1; fi
|
||||||
echo "OK: no key/.env/weight files."
|
echo "OK: no key/.env/weight files."
|
||||||
- name: private IPs (RFC1918)
|
- name: private IPs in code/config
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
IP='(^|[^0-9.])(10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3}|172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3})'
|
IP='(^|[^0-9.])(10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3}|172\.(1[6-9]|2[0-9]|3[01])\.[0-9]{1,3}\.[0-9]{1,3})'
|
||||||
if grep -rIEn "$IP" --include='*.py' --include='*.ts' --include='*.js' --include='*.json' --include='*.yaml' --include='*.yml' --include='*.sh' --include='*.md' --exclude-dir=.git --exclude-dir=.github . ; then
|
if grep -rIEn "$IP" --include='*.py' --include='*.ts' --include='*.js' --include='*.sh' --include='*.yaml' --include='*.yml' --exclude-dir=.git --exclude-dir=.github --exclude-dir=docs --exclude-dir=tests --exclude-dir=test --exclude-dir=__tests__ --exclude-dir=examples --exclude-dir=fixtures . ; then
|
||||||
echo "::error::private (RFC1918) IP — use the 192.0.2.0/24 doc range in examples."; exit 1
|
echo "::error::private (RFC1918) IP in code/config — use 192.0.2.0/24 in examples."; exit 1
|
||||||
fi
|
fi
|
||||||
echo "OK: no private IPs."
|
echo "OK: no private IPs in code/config."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user