Skip to content

Commit

Permalink
Pass in context to analyze function so verify functions that use cont…
Browse files Browse the repository at this point in the history
…ext dont get a None context
  • Loading branch information
jpdakran committed Sep 22, 2022
1 parent e61b9f9 commit 57cc319
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions detect_secrets/audit/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from ..transformers import get_transformed_file
from ..types import NamedIO
from ..util.inject import call_function_with_arguments
from detect_secrets.util.code_snippet import get_code_snippet


def get_baseline_from_file(filename: str) -> SecretsCollection:
Expand Down Expand Up @@ -91,6 +92,7 @@ def get_raw_secrets_from_file(
line_numbers = list(range(len(lines_to_scan)))

for line_number, line in zip(line_numbers, lines_to_scan):
context = get_code_snippet(lines=lines_to_scan, line_number=line_number)
identified_secrets = call_function_with_arguments(
plugin.analyze_line,
filename=secret.filename,
Expand All @@ -100,6 +102,7 @@ def get_raw_secrets_from_file(
# We enable eager search, because we *know* there's a secret here -- the baseline
# flagged it after all.
enable_eager_search=bool(secret.line_number),
context=context,
)

for identified_secret in (identified_secrets or []):
Expand Down

0 comments on commit 57cc319

Please sign in to comment.