Skip to content

Commit

Permalink
[skip actions] [uuid] 2024-07-20T14:31:49+03:00
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Jul 20, 2024
1 parent 51a96a8 commit c8423f4
Show file tree
Hide file tree
Showing 10 changed files with 3,166 additions and 11 deletions.
3,028 changes: 3,028 additions & 0 deletions cicd/benchmark.txt

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@
target:
- code

- name: UUID
severity: info
confidence: strong
type: pattern
values:
- (?<![0-9A-Za-z_+-])(?P<value>[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12})(?![=0-9A-Za-z_+-])
min_line_len: 36
required_substrings:
- "-"
required_regex: "[0-9A-Za-z_/+-]{15}"
filter_type:
- ValuePatternCheck
target:
- code
- doc

- name: AWS Client ID
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 = 131

# 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 = 429
SAMPLES_CRED_LINE_COUNT: int = 446
SAMPLES_CRED_COUNT: int = 430
SAMPLES_CRED_LINE_COUNT: int = 447

# credentials count after post-processing
SAMPLES_POST_CRED_COUNT: int = 387
SAMPLES_POST_CRED_COUNT: int = 388

# with option --doc
SAMPLES_IN_DOC = 410
SAMPLES_IN_DOC = 411

# archived credentials that are not found without --depth
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 25
Expand Down
10 changes: 5 additions & 5 deletions tests/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"sort_output": True,
"json_filename": "ml_threshold.json",
"ml_threshold": NEGLIGIBLE_ML_THRESHOLD
}, {
"__cred_count": SAMPLES_IN_DOC,
"sort_output": True,
"json_filename": "doc.json",
"doc": True
}, {
"__cred_count": SAMPLES_IN_DEEP_3,
"sort_output": True,
"json_filename": "depth_3.json",
"depth": 3
}, {
"__cred_count": SAMPLES_IN_DOC,
"sort_output": True,
"json_filename": "doc.json",
"doc": True
}]
27 changes: 27 additions & 0 deletions tests/data/depth_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -12755,6 +12755,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "UUID",
"severity": "info",
"confidence": "strong",
"line_data_list": [
{
"line": "bace4d19-fa7e-beef-cafe-9129474bcd81 # tp",
"line_num": 1,
"path": "tests/samples/uuid",
"info": "tests/samples/uuid|RAW",
"value": "bace4d19-fa7e-beef-cafe-9129474bcd81",
"value_start": 0,
"value_end": 36,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE36_CHARS",
"entropy": 3.2373263071270246,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
27 changes: 27 additions & 0 deletions tests/data/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12929,6 +12929,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "UUID",
"severity": "info",
"confidence": "strong",
"line_data_list": [
{
"line": "bace4d19-fa7e-beef-cafe-9129474bcd81 # tp",
"line_num": 1,
"path": "tests/samples/uuid",
"info": "tests/samples/uuid|RAW",
"value": "bace4d19-fa7e-beef-cafe-9129474bcd81",
"value_start": 0,
"value_end": 36,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE36_CHARS",
"entropy": 3.2373263071270246,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
27 changes: 27 additions & 0 deletions tests/data/ml_threshold.json
Original file line number Diff line number Diff line change
Expand Up @@ -11790,6 +11790,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "UUID",
"severity": "info",
"confidence": "strong",
"line_data_list": [
{
"line": "bace4d19-fa7e-beef-cafe-9129474bcd81 # tp",
"line_num": 1,
"path": "tests/samples/uuid",
"info": "",
"value": "bace4d19-fa7e-beef-cafe-9129474bcd81",
"value_start": 0,
"value_end": 36,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE36_CHARS",
"entropy": 3.2373263071270246,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
27 changes: 27 additions & 0 deletions tests/data/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -10683,6 +10683,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "UUID",
"severity": "info",
"confidence": "strong",
"line_data_list": [
{
"line": "bace4d19-fa7e-beef-cafe-9129474bcd81 # tp",
"line_num": 1,
"path": "tests/samples/uuid",
"info": "",
"value": "bace4d19-fa7e-beef-cafe-9129474bcd81",
"value_start": 0,
"value_end": 36,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE36_CHARS",
"entropy": 3.2373263071270246,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
2 changes: 2 additions & 0 deletions tests/samples/uuid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bace4d19-fa7e-beef-cafe-9129474bcd81 # tp
12345678-1234-1234-1234-1234567890ab # fp
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ def prepare(report: List[Dict[str, Any]]):
k["ml_probability"],
))

# do not use parametrised tests with unittests
# instead the config file is used
with tempfile.TemporaryDirectory() as tmp_dir:
for cfg in DATA_TEST_CFG:
Expand All @@ -749,7 +750,7 @@ def prepare(report: List[Dict[str, Any]]):
tmp_file = Path(tmp_dir) / cfg["json_filename"]
# apply the current path to keep equivalence in path
os.chdir(TESTS_PATH.parent)
content_provider: AbstractProvider = FilesProvider(["tests/samples"])
content_provider: AbstractProvider = FilesProvider([Path("tests") / "samples"])
# replace output report file to place in tmp_dir
cfg["json_filename"] = str(tmp_file)
cred_sweeper = CredSweeper(**cfg)
Expand Down

0 comments on commit c8423f4

Please sign in to comment.