Skip to content

Commit

Permalink
ValueAllowlistCheck with asterisk improves
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Oct 25, 2023
1 parent c838cec commit 5e2df31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion credsweeper/filters/value_allowlist_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ValueAllowlistCheck(Filter):
"""Check that patterns from the list is not present in the candidate value."""

ALLOWED = [
r"ENC\(.*\)", r"ENC\[.*\]", r"\$\{.*\}", r"#\{.*\}", r"\{\{.+\}\}", r"([.a-z0-9]|->)+\(.*\)", r"\*\*\*\*\*"
r"ENC\(.*\)", r"ENC\[.*\]", r"\$\{.*\}", r"#\{.*\}", r"\{\{.+\}\}", r"([.a-z0-9]|->)+\(.*\)",
r"\S{0,5}\*{5,}"
]
ALLOWED_PATTERN = re.compile( #
Util.get_regex_combine_or(ALLOWED), #
Expand Down
4 changes: 1 addition & 3 deletions tests/filters/test_value_allowlist_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def test_value_allowlist_check_p(self, file_path: pytest.fixture, success_line:
line_data = get_line_data(file_path, line=success_line, pattern=LINE_VALUE_PATTERN)
assert ValueAllowlistCheck().run(line_data, DUMMY_ANALYSIS_TARGET) is False

@pytest.mark.parametrize("line", [
"ENC(Crackle123)",
])
@pytest.mark.parametrize("line", ["test*****", "ENC(Crackle123)"])
def test_value_allowlist_check_n(self, file_path: pytest.fixture, line: str) -> None:
line_data = get_line_data(file_path, line=line, pattern=LINE_VALUE_PATTERN)
assert ValueAllowlistCheck().run(line_data, DUMMY_ANALYSIS_TARGET) is True
Expand Down

0 comments on commit 5e2df31

Please sign in to comment.