Skip to content

Commit

Permalink
[Fix] Square brackets bypass Issue Yelp#857
Browse files Browse the repository at this point in the history
  • Loading branch information
tsigouris007 committed Nov 7, 2024
1 parent 74ce23f commit ec75572
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion detect_secrets/filters/heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@ def _get_indirect_reference_regex() -> Pattern:
# [^\v]* -> Something except line breaks
# [\]\)] -> End of indirect reference: ] or )
# )
return re.compile(r'([^\v=!:]*)\s*(:=?|[!=]{1,3})\s*([\w.-]+[\[\(][^\v]*[\]\)])')
return re.compile(
r'([^\v=!:"<%>]*)\s*(:=?|[!=]{1,3}|\|\|)\s*('
r'[\w.-]+[\[\(][^\v]*[\]\)]' # Matches ENV[...] or similar references
r'|'
r'\'[^\']*\'' # Matches single-quoted strings
r'|'
r'"[^"]*"' # Matches double-quoted strings
r')'
)


def is_lock_file(filename: str) -> bool:
Expand Down

0 comments on commit ec75572

Please sign in to comment.