Skip to content

Commit

Permalink
fix(secrets): handle regex error in custom secrets gracefully (#5355)
Browse files Browse the repository at this point in the history
handle regex error in custom secrets gracefully
  • Loading branch information
gruebel committed Jul 18, 2023
1 parent 3911187 commit 0915127
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions checkov/secrets/plugins/custom_regex_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ def __init__(self) -> None:
detectors = load_detectors()

for detector in detectors:
if detector.get("isMultiline"):
self.multiline_deny_list.add(re.compile('{}'.format(detector["Regex"])))
self.multiline_regex_to_metadata[detector["Regex"]] = detector
continue
self.denylist.add(re.compile('{}'.format(detector["Regex"])))
self.regex_to_metadata[detector["Regex"]] = detector
try:
if detector.get("isMultiline"):
self.multiline_deny_list.add(re.compile('{}'.format(detector["Regex"])))
self.multiline_regex_to_metadata[detector["Regex"]] = detector
continue
self.denylist.add(re.compile('{}'.format(detector["Regex"])))
self.regex_to_metadata[detector["Regex"]] = detector
except Exception:
logging.error(
f"Failed to load detector {detector.get('Name')} with regex {detector.get('Regex')}",
exc_info=True,
)

@property
def multiline_regex_supported_file_types(self) -> Set[str]:
Expand Down

0 comments on commit 0915127

Please sign in to comment.