adding --only-allowlisted flag to scan for inline ignores#362
Merged
domanchi merged 2 commits intopre-v1-launchfrom Dec 2, 2020
Merged
adding --only-allowlisted flag to scan for inline ignores#362domanchi merged 2 commits intopre-v1-launchfrom
domanchi merged 2 commits intopre-v1-launchfrom
Conversation
…re-v1-extract-pragmas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--only-allowlistedto extract all allowlisted secrets from a codebase. In doing so, it ports #346 to the new architecture. For example:I decided to use the baseline format to be consistent and compatible with all other functionality in this tool. This way, you'll be able to feed this baseline into the
audittool for an interactive view of the results.The main difference between this and
grep -rE '(allow|white)list secret'is that this includes all the other filters that are configured with the tool. Hence, if you pass in a baseline argument with this, it will respect all configured plugins / filters, and not output a secret if it:In doing so, it paves the way for identifying redundant pragma comments. However, this PR will not include that feature (left as an exercise for the reader -- PRs welcome!)
Technical Details
This works by essentially making
detect_secrets.filters.allowlist.is_line_allowlistedan optional plugin, but a default one at that. This means that you can disable it, but it will come with preconfigured for all new baselines (and upgraded baselines).This change allows us to use the standard scanning architecture (making it compatible with
audit), as well as keeping the configuration around in the baseline itself (for manual review).With regards to the initial scanning (to create the list of secrets), we invert the filter and only scan lines that this filter would have ignored. This way, we know that we're only focusing on the lines that matter.
Testing Done
passes.