Skip to content

Commit eb522bc

Browse files
committed
Akamai credential pattern
1 parent affe3ed commit eb522bc

File tree

8 files changed

+105
-5
lines changed

8 files changed

+105
-5
lines changed

credsweeper/rules/config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@
209209
- code
210210
- doc
211211

212+
- name: Akamai Credential
213+
severity: high
214+
confidence: strong
215+
type: pattern
216+
values:
217+
- (?P<value>akab-[0-9a-z]{16}-[0-9a-z]{16})(?!\.[0-9a-z-]{1,80}\.akamaiapis\.net)
218+
filter_type: GeneralPattern
219+
required_substrings:
220+
- akab-
221+
min_line_len: 38
222+
target:
223+
- code
224+
- doc
225+
212226
- name: AWS Client ID
213227
severity: high
214228
confidence: moderate

tests/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from pathlib import Path
22

33
# total number of files in test samples
4-
SAMPLES_FILES_COUNT = 162
4+
SAMPLES_FILES_COUNT = 163
55

66
# the lowest value of ML threshold is used to display possible lowest values
77
NEGLIGIBLE_ML_THRESHOLD = 0.0001
88

99
# credentials count after scan with negligible ML threshold
10-
SAMPLES_CRED_COUNT = 504
10+
SAMPLES_CRED_COUNT = 505
1111

1212
# Number of filtered credentials with ML
1313
ML_FILTERED = 22
@@ -16,7 +16,7 @@
1616
SAMPLES_POST_CRED_COUNT = SAMPLES_CRED_COUNT - ML_FILTERED
1717

1818
# with option --doc & NEGLIGIBLE_ML_THRESHOLD
19-
SAMPLES_IN_DOC = 855
19+
SAMPLES_IN_DOC = 856
2020

2121
# archived credentials that are not found without --depth
2222
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 129

tests/data/depth_3.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@
177177
}
178178
]
179179
},
180+
{
181+
"rule": "Akamai Credential",
182+
"severity": "high",
183+
"confidence": "strong",
184+
"ml_probability": null,
185+
"line_data_list": [
186+
{
187+
"line": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
188+
"line_num": 1,
189+
"path": "./tests/samples/akamai",
190+
"info": "FILE:./tests/samples/akamai|RAW",
191+
"variable": null,
192+
"variable_start": -2,
193+
"variable_end": -2,
194+
"value": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
195+
"value_start": 0,
196+
"value_end": 38,
197+
"entropy": 4.15557
198+
}
199+
]
200+
},
180201
{
181202
"rule": "API",
182203
"severity": "medium",

tests/data/doc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@
4141
}
4242
]
4343
},
44+
{
45+
"rule": "Akamai Credential",
46+
"severity": "high",
47+
"confidence": "strong",
48+
"ml_probability": null,
49+
"line_data_list": [
50+
{
51+
"line": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
52+
"line_num": 1,
53+
"path": "./tests/samples/akamai",
54+
"info": "FILE:./tests/samples/akamai|RAW",
55+
"variable": null,
56+
"variable_start": -2,
57+
"variable_end": -2,
58+
"value": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
59+
"value_start": 0,
60+
"value_end": 38,
61+
"entropy": 4.15557
62+
}
63+
]
64+
},
4465
{
4566
"rule": "Atlassian Old PAT token",
4667
"severity": "info",

tests/data/ml_threshold.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@
4141
}
4242
]
4343
},
44+
{
45+
"rule": "Akamai Credential",
46+
"severity": "high",
47+
"confidence": "strong",
48+
"ml_probability": null,
49+
"line_data_list": [
50+
{
51+
"line": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
52+
"line_num": 1,
53+
"path": "./tests/samples/akamai",
54+
"info": "",
55+
"variable": null,
56+
"variable_start": -2,
57+
"variable_end": -2,
58+
"value": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
59+
"value_start": 0,
60+
"value_end": 38,
61+
"entropy": 4.15557
62+
}
63+
]
64+
},
4465
{
4566
"rule": "API",
4667
"severity": "medium",

tests/data/output.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@
4141
}
4242
]
4343
},
44+
{
45+
"rule": "Akamai Credential",
46+
"severity": "high",
47+
"confidence": "strong",
48+
"ml_probability": null,
49+
"line_data_list": [
50+
{
51+
"line": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
52+
"line_num": 1,
53+
"path": "./tests/samples/akamai",
54+
"info": "",
55+
"variable": null,
56+
"variable_start": -2,
57+
"variable_end": -2,
58+
"value": "akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3",
59+
"value_start": 0,
60+
"value_end": 38,
61+
"entropy": 4.15557
62+
}
63+
]
64+
},
4465
{
4566
"rule": "API",
4667
"severity": "medium",

tests/samples/akamai

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
akab-tblc7jkffv3wfxh3-h5stbzeswb3v4kj3
2+
F: akab-h5stbzeswb3v4kj3-tblc7jkffv3wfxh3.drain.akamaiapis.net

tests/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def test_multi_jobs_p(self) -> None:
426426
mocked_logger.assert_has_calls([
427427
call(f"Scan in {7} processes for {SAMPLES_FILES_COUNT - 17} providers"),
428428
call(f"Grouping {SAMPLES_CRED_COUNT + 5} candidates"),
429-
call(f"Run ML Validation for {SAMPLES_CRED_COUNT - 156} groups"),
429+
call(f"Run ML Validation for {SAMPLES_CRED_COUNT - 157} groups"),
430430
ANY, # initial ML with various arguments, cannot predict
431431
call(f"Exporting {SAMPLES_POST_CRED_COUNT} credentials"),
432432
])
@@ -440,7 +440,7 @@ def test_multi_jobs_p(self) -> None:
440440
mocked_logger.assert_has_calls([
441441
call(f"Scan in {7} processes for {SAMPLES_FILES_COUNT - 17} providers"),
442442
call(f"Grouping {SAMPLES_CRED_COUNT + 5} candidates"),
443-
call(f"Run ML Validation for {SAMPLES_CRED_COUNT - 156} groups"),
443+
call(f"Run ML Validation for {SAMPLES_CRED_COUNT - 157} groups"),
444444
# no init
445445
call(f"Exporting {SAMPLES_POST_CRED_COUNT} credentials"),
446446
])

0 commit comments

Comments
 (0)