Skip to content

Commit

Permalink
better info logs
Browse files Browse the repository at this point in the history
With this change, debug logs are going to be a *lot* more verbose, by
logging every time a line is scanned. In doing so, users are able to see
the line and filename that causes their scan to fail.

As a consequence, previous debug logs will be upgraded to "info" logs.
  • Loading branch information
Aaron Loo committed Apr 5, 2021
1 parent 1d31d52 commit 5ffc17d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion detect_secrets/core/plugins/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def from_file(filename: str) -> Iterable[Type[Plugin]]:
for plugin_class in get_plugins_from_file(filename):
secret_type = plugin_class.secret_type # type: ignore
if secret_type in get_mapping_from_secret_type_to_class():
log.debug(f'Duplicate plugin detected: {plugin_class.__name__}. Skipping...')
log.info(f'Duplicate plugin detected: {plugin_class.__name__}. Skipping...')

get_mapping_from_secret_type_to_class()[secret_type] = plugin_class
output.append(plugin_class)
Expand Down
3 changes: 2 additions & 1 deletion detect_secrets/core/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def _process_line_based_plugins(
# NOTE: We iterate through lines *then* plugins, because we want to quit early if any of the
# filters return True.
for line_number, line in lines:
log.debug(f'Processing {filename}:{line_number}')
line = line.rstrip()
code_snippet = get_code_snippet(
lines=line_content,
Expand Down Expand Up @@ -379,7 +380,7 @@ def _is_filtered_out(required_filter_parameters: Iterable[str], **kwargs: Any) -
else:
debug_msg = f'Skipping secret due to `{filter_fn.path}`.'

log.debug(debug_msg)
log.info(debug_msg)
return True
except TypeError:
# Skipping non-compatible filters
Expand Down
2 changes: 1 addition & 1 deletion tests/core/secrets_collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_filename_filters_are_invoked_first(mock_log):

assert (
'Skipping "test_data" due to `detect_secrets.filters.common.is_invalid_file`'
in mock_log.debug_messages
in mock_log.info_messages
)

@staticmethod
Expand Down

0 comments on commit 5ffc17d

Please sign in to comment.