-
-
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
[WIP] use bandit.yml as default config file (resolves #318) #458
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ | |
from bandit.core import utils | ||
|
||
|
||
BASE_CONFIG = 'bandit.yaml' | ||
LOG = logging.getLogger() | ||
|
||
|
||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an unrelated change. Please put in a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just wanted to make my PR green :P |
||
|
||
The following tests were discovered and loaded: | ||
----------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
# under the License. | ||
|
||
import logging | ||
import os.path | ||
|
||
import yaml | ||
|
||
|
@@ -23,6 +24,7 @@ | |
from bandit.core import utils | ||
|
||
|
||
BASE_CONFIG = 'bandit.yml' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in disagreement with README file, where name There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
|
@@ -39,6 +41,8 @@ def __init__(self, config_file=None): | |
self.config_file = config_file | ||
self._config = {} | ||
|
||
if config_file is None and os.path.exists(BASE_CONFIG): | ||
config_file = BASE_CONFIG | ||
if config_file: | ||
try: | ||
f = open(config_file, 'r') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this being changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I will likely change the default filename to |
||
fd.write(config) | ||
|
||
# create three branches, first has only benign, second adds malicious, | ||
|
@@ -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'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
for branch in branches: | ||
branch['branch'] = git_repo.create_head(branch['name']) | ||
|
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 have
.bandit.yml
nowThere 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.
my bad, I will make sure that every file mentions the same config filename