Skip to content

Commit 96d3d73

Browse files
committed
ci(security): enforce gitleaks in github actions
1 parent 8984999 commit 96d3d73

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/gitleaks.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Gitleaks
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
scan:
10+
name: gitleaks
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Run gitleaks scan
20+
uses: gitleaks/gitleaks-action@v2
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
GITLEAKS_CONFIG: .gitleaks.toml
24+
GITLEAKS_ENABLE_COMMENTS: "false"

.gitleaks.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
title = "Shared monitor repos gitleaks config"
2+
3+
[extend]
4+
useDefault = true
5+
6+
[[rules]]
7+
id = "monitor-secret-assignment"
8+
description = "Detects monitor project secret assignments with lower entropy tolerance"
9+
path = '''(?i)(?:^|/)(?:\.env(?:\.[^/]+)?|[^/]+\.(?:py|env|ini|cfg|conf|toml|ya?ml|json|sh))$'''
10+
regex = '''(?i)\b(?:steam_api_key|github_token|lastfm_api_key|lastfm_api_secret|riot_api_key|psn_npsso|ms_app_client_secret|sp_app_client_secret|sp_user_client_secret|sp_client_secret|sp_dc_cookie|refresh_token|session_password|smtp_password|sp_sha256)\b(?:[ \t\w.-]{0,20})[\s'"]{0,3}(?:=|:{1,3}=|:|=>|\?=)[\s=]{0,3}[\x60'"]([^\x60'"\s#]{8,256})[\x60'"](?:[\x60'"\s;]|\\[nr]|$)'''
11+
secretGroup = 1
12+
entropy = 3.1
13+
keywords = [
14+
"steam_api_key",
15+
"github_token",
16+
"lastfm_api_key",
17+
"lastfm_api_secret",
18+
"riot_api_key",
19+
"psn_npsso",
20+
"ms_app_client_secret",
21+
"sp_app_client_secret",
22+
"sp_user_client_secret",
23+
"sp_client_secret",
24+
"sp_dc_cookie",
25+
"refresh_token",
26+
"session_password",
27+
"smtp_password",
28+
"sp_sha256",
29+
]
30+
31+
[[rules.allowlists]]
32+
description = "Skip placeholders and variable references"
33+
regexTarget = "secret"
34+
regexes = [
35+
'''(?i)^your_[a-z0-9_]+$''',
36+
'''(?i)^example(?:_[a-z0-9_]+)?$''',
37+
'''(?i)^dummy(?:_[a-z0-9_]+)?$''',
38+
'''(?i)^changeme(?:_[a-z0-9_]+)?$''',
39+
'''(?i)^replace(?:_[a-z0-9_]+)?$''',
40+
'''(?i)^[a-z_][a-z0-9_]*(?:\.[a-z_][a-z0-9_]*)+$''',
41+
'''(?i)^[a-z_][a-z0-9_]*\([^\)]{0,80}\)$''',
42+
'''(?i)^<[^>]{1,64}>$''',
43+
'''(?i)^\$\{?[A-Z0-9_]{2,64}\}?$''',
44+
'''(?i)^\$\{?[a-z_][a-z0-9_]{1,63}\}?$''',
45+
'''(?i)^x{8,}$''',
46+
'''^_+$''',
47+
]

0 commit comments

Comments
 (0)