Skip to content

Commit

Permalink
handle non iac secrets FP
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Amelchenko committed Aug 23, 2023
1 parent 5a31bd5 commit 7254364
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion checkov/secrets/plugins/detector_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}


def remove_fp_secrets_in_keys(detected_secrets: set[PotentialSecret], line: str) -> None:
def remove_fp_secrets_in_keys(detected_secrets: set[PotentialSecret], line: str, is_code_file: bool = False) -> None:
formatted_line = line.replace('"', '').replace("'", '')
secrets_to_remove = set()
for detected_secret in detected_secrets:
Expand All @@ -184,6 +184,11 @@ def remove_fp_secrets_in_keys(detected_secrets: set[PotentialSecret], line: str)
# found a function name at the end of the line
if detected_secret.secret_value and formatted_line and FUNCTION_CALL_AFTER_KEYWORD_REGEX.search(formatted_line):
secrets_to_remove.add(detected_secret)
# secret value is substring of keywork
if is_code_file and FOLLOWED_BY_EQUAL_VALUE_KEYWORD_REGEX.search(formatted_line):
key, value = line.split("=", 1)
if detected_secret.secret_value in key and detected_secret.secret_value in value:
secrets_to_remove.add(detected_secret)
detected_secrets -= secrets_to_remove


Expand Down
5 changes: 4 additions & 1 deletion checkov/secrets/plugins/entropy_keyword_combinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,17 @@ def analyze_line(
# return a possible secret, otherwise check with next parser
return potential_secrets
else:
return detect_secret(
detected_secrets = detect_secret(
# If we found a keyword (i.e. db_pass = ), lower the threshold to the iac threshold
scanners=self.high_entropy_scanners if not keyword_on_key else self.entropy_scanners_non_iac_with_keyword,
filename=filename,
line=line,
line_number=line_number,
kwargs=kwargs
)
if detected_secrets:
remove_fp_secrets_in_keys(detected_secrets, line, True)
return detected_secrets

return set()

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ def a():

mock_url = mock_bc_integration.bc_api_url + "/api/v1/vulnerabilities/scan-results/2e97f5afea42664309f492a1e2083b43479c2936"

PASSWORD = "PASSWORD"
STATUS_ERROR_PASSWORD_FETCH = "ERROR_PASSWORD_FETCH"

return "Properties/LogPublishingOptions/AUDIT_LOGS/Enabled"

metadata_options['HttpTokens'] == "required"
Expand Down

0 comments on commit 7254364

Please sign in to comment.