Skip to content

Commit a5e8f63

Browse files
authored
Add test code (#82)
Added `test` key to each pattern * Added test code to generic patterns * Fixed up some of the test data for ./configs * Fixed test data and patterns more * Fixed generic data * Fixed common passwords tests and added "test" key * Test data for IBAN patterns * .NET config test data * Test data for machineKey * More database test data * Added DB test files * Added GPG test data * Test data for Bearer headers * Test data for Arc * Test data for PII * Test data for keys * Added test data for Azure Connection String * Added test data for Grafana * Added test data for all Sentry patterns * Added Okta test data * Added DataDog test data * Added test data to JWT * Add test data for hardcoded URI passwords and fixed pattern * Added test data for IPv4 and ghcr typos * Update workflow-application-token-action to v3.0.0 * Test unit tests with Actions workflow * Fixed over-matching in ssh_rsa pattern
1 parent dc8fdbd commit a5e8f63

22 files changed

+928
-127
lines changed

.github/workflows/pr-markdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- name: Get Token
1515
id: get_workflow_token
16-
uses: peter-murray/workflow-application-token-action@8e1ba3bf1619726336414f1014e37f17fbadf1db #v2.1.0
16+
uses: peter-murray/workflow-application-token-action@dc0413987a085fa17d19df9e47d4677cf81ffef3 #v3.0.0
1717
with:
1818
application_id: ${{ secrets.ADVANCED_SECURITY_APP_ID }}
1919
application_private_key: ${{ secrets.ADVANCED_SECURITY_APP_KEY }}

.github/workflows/unit-tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Unit Tests with hyperscan
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
workflow_dispatch:
10+
11+
jobs:
12+
run:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
security-events: write
17+
18+
steps:
19+
- name: Checkout custom patterns
20+
uses: actions/checkout@v4
21+
22+
- name: Checkout secret-scanning-tools
23+
uses: actions/checkout@v4
24+
with:
25+
repository: "advanced-security/secret-scanning-tools"
26+
path: "secret-scanning-tools"
27+
28+
- name: Install dependencies
29+
run: |
30+
cd "${GITHUB_WORKSPACE}"/secret-scanning-tools/secretscanning
31+
sudo apt-get -qq update
32+
sudo apt-get -qq install libpcre3-dev
33+
python3 -mpip -q install -r requirements.txt
34+
python3 -mpip -q install tqdm
35+
36+
- name: Unit Test patterns with hyperscan
37+
run: |
38+
cd "${GITHUB_WORKSPACE}"/secret-scanning-tools/secretscanning
39+
python3 ./test.py --tests "${GITHUB_WORKSPACE}" --exclude django_secret_key

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
- name: Get Token
2222
id: get_workflow_token
23-
uses: peter-murray/workflow-application-token-action@8e1ba3bf1619726336414f1014e37f17fbadf1db #v2.1.0
23+
uses: peter-murray/workflow-application-token-action@dc0413987a085fa17d19df9e47d4677cf81ffef3 #v3.0.0
2424
with:
2525
application_id: ${{ secrets.ADVANCED_SECURITY_APP_ID }}
2626
application_private_key: ${{ secrets.ADVANCED_SECURITY_APP_KEY }}

common/patterns.yml

Lines changed: 113 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ patterns:
1919
# web colours
2020
- ^\#[0-9]+$
2121
# long strings, unlikely to be a weak password
22-
- ^.{20,}
22+
- ^.{20,}
23+
test:
24+
data: some_variable="p@55w0rd123"
25+
start_offset: 15
26+
end_offset: 26
2327
comments:
2428
- ⚠️ prone to high numbers of false positives, use with caution ⚠️
2529
- very small common password shortlist from SecLists
@@ -28,79 +32,111 @@ patterns:
2832
- adds some l33tsp3@k variations
2933

3034
expected:
31-
- name: top-passwords-shortlist.txt
32-
start_offset: 13
33-
end_offset: 21
34-
- name: top-passwords-shortlist.txt
35-
start_offset: 34
36-
end_offset: 40
37-
- name: top-passwords-shortlist.txt
38-
start_offset: 49
39-
end_offset: 57
40-
- name: top-passwords-shortlist.txt
41-
start_offset: 64
42-
end_offset: 70
43-
- name: top-passwords-shortlist.txt
44-
start_offset: 80
45-
end_offset: 86
46-
- name: top-passwords-shortlist.txt
47-
start_offset: 94
48-
end_offset: 100
49-
- name: top-passwords-shortlist.txt
50-
start_offset: 106
51-
end_offset: 113
52-
- name: top-passwords-shortlist.txt
53-
start_offset: 119
54-
end_offset: 125
55-
- name: top-passwords-shortlist.txt
56-
start_offset: 131
57-
end_offset: 137
58-
- name: top-passwords-shortlist.txt
59-
start_offset: 143
60-
end_offset: 151
61-
- name: top-passwords-shortlist.txt
62-
start_offset: 161
63-
end_offset: 169
64-
- name: top-passwords-shortlist.txt
65-
start_offset: 179
66-
end_offset: 187
67-
- name: top-passwords-shortlist.txt
68-
start_offset: 197
69-
end_offset: 204
70-
- name: top-passwords-shortlist.txt
71-
start_offset: 214
72-
end_offset: 222
73-
- name: top-passwords-shortlist.txt
74-
start_offset: 232
75-
end_offset: 238
76-
- name: top-passwords-shortlist.txt
77-
start_offset: 248
78-
end_offset: 254
79-
- name: top-passwords-shortlist.txt
80-
start_offset: 264
81-
end_offset: 271
82-
- name: top-passwords-shortlist.txt
83-
start_offset: 281
84-
end_offset: 287
85-
- name: top-passwords-shortlist.txt
86-
start_offset: 297
87-
end_offset: 303
88-
- name: top-passwords-shortlist.txt
89-
start_offset: 313
90-
end_offset: 320
91-
- name: top-passwords-shortlist.txt
92-
start_offset: 330
93-
end_offset: 335
94-
- name: top-passwords-shortlist.txt
95-
start_offset: 345
96-
end_offset: 352
97-
- name: top-passwords-shortlist.txt
98-
start_offset: 362
99-
end_offset: 367
100-
- name: top-passwords-shortlist.txt
101-
start_offset: 377
102-
end_offset: 384
103-
- name: top-passwords-shortlist.txt
104-
start_offset: 394
105-
end_offset: 403
106-
35+
- name: top-passwords-shortlist.txt
36+
start_offset: 9
37+
end_offset: 17
38+
- name: top-passwords-shortlist.txt
39+
start_offset: 27
40+
end_offset: 32
41+
- name: top-passwords-shortlist.txt
42+
start_offset: 42
43+
end_offset: 51
44+
- name: top-passwords-shortlist.txt
45+
start_offset: 61
46+
end_offset: 68
47+
- name: top-passwords-shortlist.txt
48+
start_offset: 78
49+
end_offset: 83
50+
- name: top-passwords-shortlist.txt
51+
start_offset: 93
52+
end_offset: 99
53+
- name: top-passwords-shortlist.txt
54+
start_offset: 109
55+
end_offset: 116
56+
- name: top-passwords-shortlist.txt
57+
start_offset: 126
58+
end_offset: 132
59+
- name: top-passwords-shortlist.txt
60+
start_offset: 142
61+
end_offset: 145
62+
- name: top-passwords-shortlist.txt
63+
start_offset: 155
64+
end_offset: 159
65+
- name: top-passwords-shortlist.txt
66+
start_offset: 169
67+
end_offset: 175
68+
- name: top-passwords-shortlist.txt
69+
start_offset: 185
70+
end_offset: 191
71+
- name: top-passwords-shortlist.txt
72+
start_offset: 201
73+
end_offset: 208
74+
- name: top-passwords-shortlist.txt
75+
start_offset: 218
76+
end_offset: 224
77+
- name: top-passwords-shortlist.txt
78+
start_offset: 234
79+
end_offset: 241
80+
- name: top-passwords-shortlist.txt
81+
start_offset: 251
82+
end_offset: 261
83+
- name: top-passwords-shortlist.txt
84+
start_offset: 271
85+
end_offset: 277
86+
- name: top-passwords-shortlist.txt
87+
start_offset: 287
88+
end_offset: 295
89+
- name: top-passwords-shortlist.txt
90+
start_offset: 305
91+
end_offset: 313
92+
- name: top-passwords-shortlist.txt
93+
start_offset: 323
94+
end_offset: 331
95+
- name: top-passwords-shortlist.txt
96+
start_offset: 341
97+
end_offset: 347
98+
- name: top-passwords-shortlist.txt
99+
start_offset: 357
100+
end_offset: 364
101+
- name: top-passwords-shortlist.txt
102+
start_offset: 374
103+
end_offset: 380
104+
- name: top-passwords-shortlist.txt
105+
start_offset: 390
106+
end_offset: 396
107+
- name: top-passwords-shortlist.txt
108+
start_offset: 406
109+
end_offset: 413
110+
- name: top-passwords-shortlist.txt
111+
start_offset: 423
112+
end_offset: 428
113+
- name: top-passwords-shortlist.txt
114+
start_offset: 438
115+
end_offset: 445
116+
- name: top-passwords-shortlist.txt
117+
start_offset: 455
118+
end_offset: 460
119+
- name: top-passwords-shortlist.txt
120+
start_offset: 470
121+
end_offset: 477
122+
- name: top-passwords-shortlist.txt
123+
start_offset: 487
124+
end_offset: 495
125+
- name: top-passwords-shortlist.txt
126+
start_offset: 505
127+
end_offset: 511
128+
- name: top-passwords-shortlist.txt
129+
start_offset: 521
130+
end_offset: 527
131+
- name: top-passwords-shortlist.txt
132+
start_offset: 537
133+
end_offset: 543
134+
- name: top-passwords-shortlist.txt
135+
start_offset: 553
136+
end_offset: 559
137+
- name: top-passwords-shortlist.txt
138+
start_offset: 569
139+
end_offset: 573
140+
- name: top-passwords-shortlist.txt
141+
start_offset: 583
142+
end_offset: 589

common/top-passwords-shortlist.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
password=p@55w0rd
2+
password=adm!n
3+
password=t3mporary
4+
password=Am3r1cA
5+
password=indi@
6+
password=mumb4i
7+
password=1234567
8+
password=abcdef
9+
password=123
10+
password=1qaz
11+
password=qwerty
12+
password=m0nkey
13+
password=letmein
14+
password=drag0n
15+
password=0000000
16+
password=bA$k3tb4ll
17+
password=s0cc3r
18+
password=iloveyou
19+
password=tru5tn01
20+
password=Sun5h1ne
21+
password=m45ter
22+
password=w3lcome
23+
password=shad0w
24+
password=ashl3y
25+
password=f00tb@l
26+
password=j35us
27+
password=m1chAel
28+
password=n1nja
29+
password=mu5tang
30+
password=chrysler
31+
password=t0yot4
32+
password=w1nt3r
33+
password=spr1ng
34+
password=summ3r
35+
password=f@ll
36+
password=4utumn

configs/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ _version: v0.1_
2020

2121
- Supports quoted passwords
2222

23-
- Not case sensative
23+
- Case insensitive
2424

2525

2626
<details>
2727
<summary>Pattern Format</summary>
2828

2929
```regex
30-
[^\r\n\p{Cc}]+
30+
[^\r\n\x00-\x08]+
3131
```
3232

3333
</details>
@@ -36,7 +36,7 @@ _version: v0.1_
3636
<summary>Start Pattern</summary>
3737

3838
```regex
39-
(?:[^0-9A-Za-z]|\A)(?i)(?:postgres|mysql|mysql_root)_password[\t ]*[=:][\t ]*['"]
39+
(?:[^0-9A-Za-z]|\A)(?i)(?:postgres|mysql|mysql_root)_password[\t ]*[=:][\t ]*['"]?
4040
```
4141

4242
</details><details>
@@ -61,7 +61,7 @@ _version: v0.1_
6161
<summary>Pattern Format</summary>
6262

6363
```regex
64-
[^\r\n'"\p{Cc}]+
64+
[^\r\n'"\x00-\x08]+
6565
```
6666

6767
</details>
@@ -70,7 +70,7 @@ _version: v0.1_
7070
<summary>Start Pattern</summary>
7171

7272
```regex
73-
(?:spring\.datasource|jdbc)\.password[ \t]*=[ \t]*['"]?
73+
(\A|\b)(?:spring\.datasource|jdbc)\.password[ \t]*=[ \t]*['"]?
7474
```
7575

7676
</details><details>
@@ -88,11 +88,7 @@ _version: v0.1_
8888

8989
_version: v0.1_
9090

91-
**Comments / Notes:**
92-
9391

94-
- _If the secret is at the start of the file, its not picked up_
95-
9692

9793
<details>
9894
<summary>Pattern Format</summary>
@@ -107,7 +103,7 @@ _version: v0.1_
107103
<summary>Start Pattern</summary>
108104

109105
```regex
110-
\bSECRET_KEY[ \t]*=[ \t]*["']
106+
(\b|\A)SECRET_KEY[ \t]*=[ \t]*["']
111107
```
112108

113109
</details><details>
@@ -204,13 +200,13 @@ _version: v0.1_
204200
**Comments / Notes:**
205201

206202

207-
- Checks for all github action susing a version that isn't a pinned SHA-1 commit hash
203+
- Checks for all github actions using a version that isn't a pinned SHA-1 commit hash
208204

209205
- Checks for uses: org name / repo name @ string under 40 characters
210206

211-
- Not case sensative
207+
- Not case sensitive
212208

213-
- exclude all actions in actions, github and advanced-security repo
209+
- Exclude all actions in actions, github and advanced-security repo
214210

215211

216212
<details>

0 commit comments

Comments
 (0)