Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: plugins reuse excludes CLI arg #147

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

bigpick
Copy link
Member

@bigpick bigpick commented Jan 30, 2024

Info

Addresses #132.

Allows the ability to pass a CLI flag (--plugins-reuse-excludes) that forces the plugins to not run with a default config.

Once passed in, sets plugins_reuse_excludes to true in the .secrets.baseline, which takes precedence/persists even if the CLI argument is not passed. In order to remove the setting, deleting + regeneration of the baseline without the flag is required.

Testing

setup:

mkdir issue132 && echo 'secret: mysecret' > issue132/test.txt
  1. Default scan, picks up secret:
PYTHONPATH=`pwd` python detect_secrets/main.py scan --update .secrets.baseline --all-files issue132

PYTHONPATH=`pwd` python detect_secrets/main.py audit .secrets.baseline

# shows (1) Secret Type: Secret Keyword

rm .secrets.baseline
  1. Scan with flag and no baseline, picks up secret:
PYTHONPATH=`pwd` python detect_secrets/main.py scan --update .secrets.baseline --all-files issue132  --plugins-reuse-excludes

PYTHONPATH=`pwd` python detect_secrets/main.py audit .secrets.baseline

# shows (1) Secret Type: Secret Keyword

rm .secrets.baseline
  1. Scan with ignore, doesn't pick up secret:
PYTHONPATH=`pwd` python detect_secrets/main.py scan --update .secrets.baseline --exclude-lines "secret" --all-files issue132

PYTHONPATH=`pwd` python detect_secrets/main.py audit .secrets.baseline
# Nothing to audit! 

rm .secrets.baseline
  1. Scan with ignore + flag, followed up by scan without flag, still doesn't pick up secret:
PYTHONPATH=`pwd` python detect_secrets/main.py scan --update .secrets.baseline --exclude-lines "secret" --plugins-reuse-excludes --all-files issue132

PYTHONPATH=`pwd` python detect_secrets/main.py audit .secrets.baseline
Nothing to audit!

PYTHONPATH=`pwd` python detect_secrets/main.py scan --update .secrets.baseline --all-files issue132

PYTHONPATH=`pwd` python detect_secrets/main.py audit .secrets.baseline
Nothing to audit!

jq '.plugins_reuse_excludes' .secrets.baseline
true

@bigpick
Copy link
Member Author

bigpick commented Jan 30, 2024

(updating tests, oops)

Signed-off-by: George Pickering <[email protected]>
@cguest97
Copy link
Member

Thanks for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants