Skip to content

Commit

Permalink
Azure Storage Account Key (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek authored Jan 8, 2025
1 parent 4a2e958 commit 405fb06
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 3 deletions.
17 changes: 17 additions & 0 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,23 @@
- code
- doc

- name: Azure Storage Account Key
severity: high
confidence: moderate
type: pattern
values:
- (?:(?<![0-9A-Za-z_/+-])|\\[0abfnrtv]|(%|\\x)[0-9A-Fa-f]{2}|\\[0-7]{3}|\\[Uu]([0-9A-Fa-f]{4}){1,2}|\x1B\[[0-9;]{0,80}m)(?P<value>[0-9A-Za-z]{52}JQQJ9[9DH][0-9A-Za-z]{26}([0-9A-Za-z=]{4})?)(?![0-9A-Za-z_/+-])
min_line_len: 80
filter_type:
- ValuePatternCheck(17)
required_substrings:
- JQQJ99
- JQQJ9D
- JQQJ9H
target:
- code
- doc

- name: Bitbucket App Password
severity: high
confidence: strong
Expand Down
4 changes: 2 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
NEGLIGIBLE_ML_THRESHOLD = 0.0001

# credentials count after scan with negligible ML threshold
SAMPLES_CRED_COUNT = 429
SAMPLES_CRED_COUNT = 430
SAMPLES_CRED_LINE_COUNT = SAMPLES_CRED_COUNT + 19

# Number of filtered credentials with ML
Expand All @@ -17,7 +17,7 @@
SAMPLES_POST_CRED_COUNT = SAMPLES_CRED_COUNT - ML_FILTERED

# with option --doc
SAMPLES_IN_DOC = 675
SAMPLES_IN_DOC = 676

# archived credentials that are not found without --depth
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 35
Expand Down
26 changes: 26 additions & 0 deletions tests/data/depth_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Azure Storage Account Key",
"severity": "high",
"confidence": "moderate",
"line_data_list": [
{
"line": "t 189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"line_num": 5,
"path": "./tests/samples/azure_access_token",
"info": "./tests/samples/azure_access_token|RAW",
"value": "189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"value_start": 2,
"value_end": 90,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.224827040068046,
"valid": false
}
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
Expand Down
26 changes: 26 additions & 0 deletions tests/data/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Azure Storage Account Key",
"severity": "high",
"confidence": "moderate",
"line_data_list": [
{
"line": "t 189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"line_num": 5,
"path": "./tests/samples/azure_access_token",
"info": "./tests/samples/azure_access_token|RAW",
"value": "189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"value_start": 2,
"value_end": 90,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.224827040068046,
"valid": false
}
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
Expand Down
26 changes: 26 additions & 0 deletions tests/data/ml_threshold.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Azure Storage Account Key",
"severity": "high",
"confidence": "moderate",
"line_data_list": [
{
"line": "t 189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"line_num": 5,
"path": "./tests/samples/azure_access_token",
"info": "",
"value": "189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"value_start": 2,
"value_end": 90,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.224827040068046,
"valid": false
}
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
Expand Down
26 changes: 26 additions & 0 deletions tests/data/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Azure Storage Account Key",
"severity": "high",
"confidence": "moderate",
"line_data_list": [
{
"line": "t 189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"line_num": 5,
"path": "./tests/samples/azure_access_token",
"info": "",
"value": "189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==",
"value_start": 2,
"value_end": 90,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.224827040068046,
"valid": false
}
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
Expand Down
6 changes: 5 additions & 1 deletion tests/samples/azure_access_token
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVRN3N5SEpsWSIsImtpZCI6Imk2bEdrM0ZaenhS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tMjIyWDVyclYzeERxZktRIiwidGlkIjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IiwidXRpIjoiZnFpQnFYTFBqMGVRYTgyUy1JWUZBQSIsInZlciI6IjIuMCJ9.pj4N-w_3Us9DrBLfpCt
^^^ examples from https://learn.microsoft.com/en-us/entra/identity-platform/access-tokens
^^^ examples from https://learn.microsoft.com/en-us/entra/identity-platform/access-tokens

t 189shdhgr893rgdg74sdsdfkksdhtg87dyfwegjddshjhsgjsgdhJQQJ99ALACAAAAAAAAAAAAASAZDO1e4drs==

f ooooooooooooooooooooooooooooooooooooooooooooooooooooJQQJ99AEAAAAAAAAAAAAAAAAAZFURg67

0 comments on commit 405fb06

Please sign in to comment.