Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Add pass_filenames: false to hook #8

Merged
merged 1 commit into from
Apr 20, 2021
Merged

Add pass_filenames: false to hook #8

merged 1 commit into from
Apr 20, 2021

Conversation

dolfinus
Copy link
Contributor

@dolfinus dolfinus commented Apr 20, 2021

Hello.

I found an issue of using this pre-commit hook.
Then I run pre-commit run -v command, I see this output:

[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
58 [0.. 50.. ]
Run started:2021-04-20 12:19:50.232723

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 5896
        Total lines skipped (#nosec): 18

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 389.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 392.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
59 [0.. 50.. ]
Run started:2021-04-20 12:19:50.234352

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 5920
        Total lines skipped (#nosec): 19

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 390.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 393.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
60 [0.. 50.. ]
Run started:2021-04-20 12:19:50.334931

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 6219
        Total lines skipped (#nosec): 18

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 394.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 397.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
58 [0.. 50.. ]
Run started:2021-04-20 12:19:50.258180

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 6139
        Total lines skipped (#nosec): 19

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 388.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 391.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
60 [0.. 50.. ]
Run started:2021-04-20 12:19:50.422002

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 7075
        Total lines skipped (#nosec): 23

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 390.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 393.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
59 [0.. 50.. ]
Run started:2021-04-20 12:19:50.204391

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 5835
        Total lines skipped (#nosec): 18

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 391.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 394.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
59 [0.. 50.. [node_visitor]     INFO    Unable to find qualified name for module: setup.py
]
Run started:2021-04-20 12:19:50.259984

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 6126
        Total lines skipped (#nosec): 18

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 389.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 392.0
Files skipped (0):
[main]  INFO    profile include tests: None
[main]  INFO    profile exclude tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.9.3
59 [0.. 50.. ]
Run started:2021-04-20 12:19:50.253625

Test results:
        No issues identified.

Code scanned:
        Total lines of code: 5945
        Total lines skipped (#nosec): 29

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 391.0
                Medium: 6.0
                High: 0.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 3.0
                Medium: 0.0
                High: 394.0
Files skipped (0):

This is default behavior of pre-commit hook. It expects that each check will be performed against each file that was changed. This allows to skip check if no files related to this check were changed in the commit.

Bandit is mostly used for batch run, that's why default options are --recursive .. But pre-commit calls for each file which has been changed with appending each file name to args list. That's why there are 8 bandit reports in my output - 8 files were changed.
And because of files: '' in .pre-commit-hook.yml, it is run not on every .py file in the repo but all the files ignoring the extension.

But there is an option which disable this behavior - pass_filenames: false. Let's add it into the hook.

@Lucas-C Lucas-C merged commit e92cb23 into Lucas-C:master Apr 20, 2021
@Lucas-C
Copy link
Owner

Lucas-C commented Apr 20, 2021

Thanks for this nice contribution!

@Lucas-C
Copy link
Owner

Lucas-C commented Apr 20, 2021

This has been released with a new tag: https://github.com/Lucas-C/pre-commit-hooks-bandit/releases/tag/v1.0.5

@dolfinus dolfinus deleted the pass_filenames branch April 20, 2021 15:58
@dolfinus
Copy link
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants