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

[WIP] use bandit.yml as default config file (resolves #318) #458

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rooterkyberian
Copy link

See #318 for reasons for this change.

@@ -23,6 +24,7 @@
from bandit.core import utils


BASE_CONFIG = 'bandit.yml'
Copy link

Choose a reason for hiding this comment

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

This is in disagreement with README file, where name .bandit.yml is used.

Copy link
Member

Choose a reason for hiding this comment

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

OK, there are two configuration files. One, .bandit is to put command line options. The other, the bandit.yml via -c is for more extensive options.

However this patch is making it even more confusing.

Copy link
Author

Choose a reason for hiding this comment

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

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.

So this patch will make things even more confusing for users of Bandit. .bandit is intended for command line options so that a user doesn't have to type each time.

The other config via -c is for more extensive options, like customizing the test plugins is a bandit.yml file.

Please don't name them the same, this will make it less obvious the difference between the two.

@@ -291,7 +290,7 @@ def main():
"{relpath:20.20s}: {line:03}: {test_id:^8}: DEFECT: {msg:>20}"

See python documentation for more information about formatting style:
https://docs.python.org/3.4/library/string.html
https://docs.python.org/3/library/string.html
Copy link
Member

Choose a reason for hiding this comment

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

This is an unrelated change. Please put in a separate PR.

Copy link
Author

Choose a reason for hiding this comment

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

I just wanted to make my PR green :P

@@ -295,26 +295,28 @@ An optional config file may be supplied and may include:

Per Project Command Line Args
-----------------------------
Projects may include a `.bandit` file that specifies command line arguments
Projects may include a `.bandit.yml` file that specifies command line arguments
Copy link
Member

Choose a reason for hiding this comment

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

You have .bandit.yml now

Copy link
Author

Choose a reason for hiding this comment

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

my bad, I will make sure that every file mentions the same config filename

@@ -23,6 +24,7 @@
from bandit.core import utils


BASE_CONFIG = 'bandit.yml'
Copy link
Member

Choose a reason for hiding this comment

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

OK, there are two configuration files. One, .bandit is to put command line options. The other, the bandit.yml via -c is for more extensive options.

However this patch is making it even more confusing.

@@ -102,8 +102,7 @@ def test_bandit_baseline(self):
'benign_two.py'],
'expected_return': 0}]

baseline_command = ['bandit-baseline', '-c', 'bandit.yaml', '-r', '.',
'-p', 'test']
baseline_command = ['bandit-baseline', '-r', '.', '-p', 'test']
Copy link
Member

Choose a reason for hiding this comment

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

Why is this changed?

Copy link
Author

Choose a reason for hiding this comment

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

baseline tests should test the basic features - or at least that was my guess, so for for YAML that would be default filename
there are other tests for custom named YAML config files

@@ -83,7 +83,7 @@ def test_bandit_baseline(self):
git_repo.index.commit('Initial commit')
os.chdir(repo_directory)

with open('bandit.yaml', 'wt') as fd:
with open('bandit.yml', 'wt') as fd:
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being changed?

Copy link
Author

Choose a reason for hiding this comment

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

because thats the new default filename and it seems fitting that we should test "default" YAML filename as part of baseline tests
other tests already test of custom provided filename

I will likely change the default filename to .bandit.yml or bandit.yaml (in that add a test case with custom filename) because neither PyCQA or openstack is using bandit.yml - I just took that name from one of the comments from #318 discussion.

@rooterkyberian
Copy link
Author

Thank you for the review.

To clear up any .bandit vs YAML config file confusion I will make sure that all .bandit options are being supported by YAML config as well - please see my reasoning (&comment) here: #318 (comment)

I'm still not sure which default filename should be used for YAML, but that is a simple change to make, so it can be done at any time - the combining the two files and simplifing documentation is much more important.

I do not plan on proposing here elimination of INI (or any currently existing command line options), just to make sure users which want to use bandit using a default config file without typing any arguments in the command line can do so, just as it is the case with about any other PyCQA tool.

@rooterkyberian rooterkyberian changed the title use bandit.yml as default config file (resolves #318) [WIP] use bandit.yml as default config file (resolves #318) Mar 1, 2019
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.

3 participants