Skip to content

Commit cde9577

Browse files
chore: add secret leak scan
1 parent a29788d commit cde9577

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/secret-scan.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Secret Scan
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
security-events: write
13+
14+
jobs:
15+
gitleaks:
16+
name: Gitleaks Scan
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Go (for potential custom builds)
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: '1.22'
28+
29+
- name: Download gitleaks
30+
run: |
31+
curl -sSL https://github.com/gitleaks/gitleaks/releases/latest/download/gitleaks_$(uname -s)_$(uname -m).tar.gz -o gitleaks.tar.gz
32+
tar -xzf gitleaks.tar.gz gitleaks
33+
sudo mv gitleaks /usr/local/bin/
34+
gitleaks version
35+
36+
- name: Run gitleaks
37+
id: gitleaks
38+
run: |
39+
set -e
40+
gitleaks detect --config=.gitleaks.toml --report-format sarif --report-path gitleaks.sarif || echo "Gitleaks detected potential leaks (recorded in SARIF)"
41+
42+
- name: Upload SARIF to code scanning
43+
uses: github/codeql-action/upload-sarif@v3
44+
with:
45+
sarif_file: gitleaks.sarif

.gitleaks.toml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
title = "mendix-native gitleaks config"
2+
# Base config uses gitleaks defaults; we extend with allowlists and a few custom regexes
3+
4+
[allowlist]
5+
description = "Global allowlist"
6+
files = [
7+
"yarn.lock",
8+
"package-lock.json",
9+
"pnpm-lock.yaml",
10+
"gradlew",
11+
"gradlew.bat",
12+
"example/ios/Pods/",
13+
"example/android/"
14+
]
15+
regexes = [
16+
# Common false positives
17+
'''(?i)localhost(:[0-9]{2,5})?''',
18+
'''(?i)internal-slot''',
19+
'''(?i)eastasianwidth'''
20+
]
21+
22+
[[rules]]
23+
id = "generic-api-key"
24+
description = "Generic API key format"
25+
regex = '''(?i)(api|access|auth)[_-]?key["'\s:=]+[A-Za-z0-9_\-]{16,}'''
26+
tags = ["api", "key", "generic"]
27+
28+
[[rules]]
29+
id = "bearer-token-inline"
30+
description = "Potential hard-coded bearer token"
31+
regex = '''Bearer\s+[A-Za-z0-9\-_.]{20,}'''
32+
tags = ["auth", "token"]
33+
34+
[[rules]]
35+
id = "jwt"
36+
description = "JSON Web Token"
37+
regex = '''eyJ[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}'''
38+
tags = ["jwt", "token"]
39+
40+
[[rules]]
41+
id = "aws-access-key"
42+
description = "AWS Access Key ID"
43+
regex = '''AKIA[0-9A-Z]{16}'''
44+
tags = ["aws", "key"]
45+
46+
[[rules]]
47+
id = "github-token"
48+
description = "GitHub Personal Access Token"
49+
regex = '''ghp_[A-Za-z0-9]{36,}'''
50+
tags = ["github", "token"]
51+
52+
[[rules]]
53+
id = "slack-token"
54+
description = "Slack token"
55+
regex = '''xox[baprs]-[A-Za-z0-9\-]{10,}'''
56+
tags = ["slack", "token"]
57+
58+
[[rules]]
59+
id = "stripe-secret-key"
60+
description = "Stripe live secret key"
61+
regex = '''sk_live_[0-9a-zA-Z]{10,}'''
62+
tags = ["stripe", "secret"]
63+
64+
[[rules]]
65+
id = "private-key-block"
66+
description = "Private key block"
67+
regex = '''-----BEGIN (EC|RSA|DSA|OPENSSH|PRIVATE) KEY-----'''
68+
tags = ["crypto", "private-key"]
69+
70+
[whitelist] # backward compatibility for older gitleaks versions
71+
description = "Legacy whitelist alias"

0 commit comments

Comments
 (0)