-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Add default ini file + enable recursive option in ini #503
base: main
Are you sure you want to change the base?
Conversation
de54e38
to
ccb9da0
Compare
ccb9da0
to
5c9a2f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change results in an warning message every time for the typical case where bandit is run with no .bandit
file, yet does provide a target.
[utils] WARNING Unable to parse config file .bandit or missing [bandit] section
I'd rather not see warning messages when the arguments given to the CLI are correct and complete.
@Babarberousse Can you rebase your PR to make it ready for merging? Also, you may address @ericwb's concern and remove the chatty warning. We may still have that, but maybe show it only with |
bandit/cli/main.py
Outdated
@@ -246,7 +246,7 @@ def main(): | |||
'(only JSON-formatted files are accepted)' | |||
) | |||
parser.add_argument( | |||
'--ini', dest='ini_path', action='store', default=None, | |||
'--ini', dest='ini_path', action='store', default='.bandit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This limits the default to just a single possibility.
Other popular tools, such as flake8, behave, etc., allow the configuration to be discovered from various popular configuration files (to save the project home directory from being polluted with numerous configuration files).
I tend to place all configuration into a tox.ini
file, for example. This makes sense as Tox is my main driver and single point of entry for running all tests and checks on Python projects.
4bf77d6
to
e61f86c
Compare
bandit/cli/main.py
Outdated
|
||
:return: the filename as a string or `None` if no ini file found | ||
""" | ||
for filename in [".bandit", "setup.cfg", "tox.ini"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are awesome! 🥇
@ericwb This seems fixed now. |
I think there are still a few problems, although not related to this pull request. The recursive parameter is set to Also, there's a bit of redundancy between my I'll try to look at these issues this week-end and try to make it a bit cleaner. |
b2f927d
to
8256521
Compare
I went a bit further than what my initial PR was supposed to be and:
|
8256521
to
a82aa79
Compare
0b45f74
to
1fd34cc
Compare
@Babarberousse could you rebase this PR and try to get it merged? 🎸 🚀 This still seems like a desperately needed UX improvement to me. |
I don't have much time at the moment but I'll try to get it done in the next few weeks. |
6c8d418
to
a07bb75
Compare
Fixed bool params not working in ini file
a07bb75
to
4374cb8
Compare
I kept recursivity as false as a default and kept the |
See: #467
I think making
recursive
a default would make sense. However it could break some ci pipelines so maybe in a future PR.Also, I made
.bandit
the default ini file, which means users who do not specify an ini file and don't have a.bandit
file will now get a warning. Not sure we should keep it.