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

Make pre-commit run Bandit hook using a single process #1029

Merged
merged 3 commits into from Jun 15, 2023

Conversation

Klavionik
Copy link
Contributor

@Klavionik Klavionik commented May 22, 2023

I would like you to consider this small change to the pre-commit manifest.

Currently pre-commit may run Bandit hook with multiple processes, which can lead to Bandit generating multiple reports from these runs. It's only a bit confusing when you run Bandit for the first time on a moderately large database and output report on the screen, but it's much worse if you're saving your report to, let's say, an HTML file. Then you would get a straight wrong report.

This is what happens, when I run the same Bandit command with pre-commit and without it on the same codebase:

(pre-commit)
Screenshot from 2023-05-23 02-23-31

(w/o pre-commit)
Screenshot from 2023-05-23 02-24-11

Each run just overwrites the report file, and in the end we're left with what happens to be the latest run result.

One can mitigate this problem by using the -r flag and setting pre-commit pass_filenames option to false, but this doesn't suit everyone (or should be at least documented).

Copy link
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericwb ericwb merged commit a3c0461 into PyCQA:main Jun 15, 2023
13 checks passed
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.

None yet

3 participants