Skip to content

Commit a7daccc

Browse files
authored
↪️ Merge pull request #195 from adrianbn/add-artifactory-patterns
New Artifactory / Slack Patterns
2 parents eadaabe + b34dda6 commit a7daccc

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

detect_secrets/plugins/artifactory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ArtifactoryDetector(RegexBasedDetector):
1111

1212
denylist = [
1313
# artifactory tokens begin with AKC
14-
re.compile(r'(?:\s|=|:|"|^)AKC\w{10,}'), # api token
15-
# artifactory encrypted passwords begin with AP6
16-
re.compile(r'(?:\s|=|:|"|^)AP6\w{10,}'), # password
14+
re.compile(r'(?:\s|=|:|"|^)AKC[a-zA-Z0-9]{10,}'), # api token
15+
# artifactory encrypted passwords begin with AP[A-Z]
16+
re.compile(r'(?:\s|=|:|"|^)AP[\dABCDEF][a-zA-Z0-9]{8,}'), # password
1717
]

detect_secrets/plugins/slack.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,13 @@ class SlackDetector(RegexBasedDetector):
1313
secret_type = 'Slack Token'
1414

1515
denylist = (
16+
# Slack Token
1617
re.compile(r'xox(?:a|b|p|o|s|r)-(?:\d+-)+[a-z0-9]+', flags=re.IGNORECASE),
18+
# Slack Webhooks
19+
re.compile(
20+
r"""
21+
https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}
22+
""",
23+
flags=re.IGNORECASE | re.VERBOSE,
24+
),
1725
)

tests/plugins/artifactory_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class TestArtifactoryDetector(object):
1111
'payload, should_flag',
1212
[
1313
('AP6xxxxxxxxxx', True),
14+
('AP2xxxxxxxxxx', True),
15+
('AP3xxxxxxxxxx', True),
16+
('AP5xxxxxxxxxx', True),
17+
('APAxxxxxxxxxx', True),
18+
('APBxxxxxxxxxx', True),
1419
('AKCxxxxxxxxxx', True),
1520
(' AP6xxxxxxxxxx', True),
1621
(' AKCxxxxxxxxxx', True),
@@ -28,7 +33,7 @@ class TestArtifactoryDetector(object):
2833
('testAP6withinsomeirrelevantstring', False),
2934
('X-JFrog-Art-Api: $API_KEY', False),
3035
('X-JFrog-Art-Api: $PASSWORD', False),
31-
('artifactory:_password=AP6xxxxxxxx', False),
36+
('artifactory:_password=AP6xxxxxx', False),
3237
('artifactory:_password=AKCxxxxxxxx', False),
3338
],
3439
)

tests/plugins/slack_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class TestSlackDetector(object):
3333
(
3434
'xoxb-34532454-e039d02840a0b9379c'
3535
),
36+
(
37+
'https://hooks.slack.com/services/Txxxxxxxx/Bxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx'
38+
),
3639
],
3740
)
3841
def test_analyze(self, file_content):

0 commit comments

Comments
 (0)