Skip to content

Commit

Permalink
Command line patterns (#605)
Browse files Browse the repository at this point in the history
* CMD arguments patterns

* CMD passwor,token,salt

* BM ci Upd
  • Loading branch information
babenek authored Sep 9, 2024
1 parent cc1c27f commit 2534b92
Show file tree
Hide file tree
Showing 9 changed files with 1,161 additions and 49 deletions.
95 changes: 51 additions & 44 deletions .ci/benchmark.txt

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,62 @@
- code
- doc

- name: CMD ConvertTo-SecureString
severity: high
confidence: moderate
type: pattern
values:
- (^|\W|\\[tnr])(?P<variable>ConvertTo-SecureString(\s\s*-(String|AsPlainText|Force))*)\s\s*(?P<value_leftquote>(\\?[\"']){1,3})?(?P<value>(?(value_leftquote)[^\"'\\]|[^\s\"'\\]){4,800})(?(value_leftquote)(?P<value_rightquote>(\\?[\"']){1,3}))
filter_type: GeneralKeyword
use_ml: true
required_substrings:
- convertto-securestring
min_line_len: 27
target:
- code

- name: CMD Password
severity: high
confidence: moderate
type: pattern
values:
- (^|\W|\\[tnr])(?P<variable>-[A-Za-z_-]*(?i:pass(in|out|word|phrase)))\s\s*(?!-)(?P<value_leftquote>(\\?[\"']){1,3})?(pass:)?(?!file:|env:|fd:)(?P<value>(?(value_leftquote)[^\"'\\]|[^\s\"'\\]){4,80})(?(value_leftquote)(?P<value_rightquote>(\\?[\"']){1,3}))
filter_type: GeneralKeyword
use_ml: true
required_substrings:
- pass
min_line_len: 12
target:
- code

- name: CMD Token
severity: high
confidence: moderate
type: pattern
values:
- (^|\W|\\[tnr])(?P<variable>-[A-Za-z_-]*(?i:token))\s\s*(?!-)(?P<value_leftquote>(\\?[\"']){1,3})?(?P<value>(?(value_leftquote)[^\"'\\]|[^\s\"'\\]){4,4000})(?(value_leftquote)(?P<value_rightquote>(\\?[\"']){1,3}))
filter_type: GeneralKeyword
use_ml: true
required_substrings:
- token
min_line_len: 12
target:
- code

- name: CMD Secret
severity: high
confidence: moderate
type: pattern
values:
- (^|\W|\\[tnr])(?P<variable>-[A-Za-z_-]*(?i:secret)[A-Za-z_-]*)\s\s*(?!-)(?P<value_leftquote>(\\?[\"']){1,3})?(pass:)?(?!file:|env:|fd:)(?P<value>(?(value_leftquote)[^\"'\\]|[^\s\"'\\]){4,4000})(?(value_leftquote)(?P<value_rightquote>(\\?[\"']){1,3}))
filter_type: GeneralKeyword
use_ml: true
required_substrings:
- secret
min_line_len: 12
target:
- code

- name: URL Credentials
severity: high
confidence: moderate
Expand Down
10 changes: 5 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from pathlib import Path

# total number of files in test samples
SAMPLES_FILES_COUNT: int = 130
SAMPLES_FILES_COUNT: int = 132

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

# credentials count after scan
SAMPLES_CRED_COUNT: int = 364
SAMPLES_CRED_LINE_COUNT: int = 381
SAMPLES_CRED_COUNT: int = 378
SAMPLES_CRED_LINE_COUNT: int = 395

# credentials count after post-processing
SAMPLES_POST_CRED_COUNT: int = 336
SAMPLES_POST_CRED_COUNT: int = 347

# with option --doc
SAMPLES_IN_DOC = 417
SAMPLES_IN_DOC = 419

# archived credentials that are not found without --depth
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 23
Expand Down
Loading

0 comments on commit 2534b92

Please sign in to comment.