Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line patterns #605

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading