Skip to content

Commit

Permalink
small fix is_prefixed_with_dollar_sign (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
omryMen authored Nov 10, 2024
1 parent 17a8f44 commit ce9c167
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion detect_secrets/filters/heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def is_prefixed_with_dollar_sign(secret: str) -> bool:
# false negatives than `is_templated_secret` (e.g. secrets that actually start with a $).
# This is best used with files that actually use this as a means of referencing variables.
# TODO: More intelligent filetype handling?
return secret[0] == '$'
if len(secret) > 0 and secret[0] == '$':
return True
return False


def is_indirect_reference(line: str) -> bool:
Expand Down
1 change: 1 addition & 0 deletions tests/filters/heuristic_filter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def test_is_templated_secret(line, result):
def test_is_prefixed_with_dollar_sign():
assert filters.heuristic.is_prefixed_with_dollar_sign('$secret')
assert not filters.heuristic.is_prefixed_with_dollar_sign('secret')
assert not filters.heuristic.is_prefixed_with_dollar_sign('')


@pytest.mark.parametrize(
Expand Down

0 comments on commit ce9c167

Please sign in to comment.