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

Add several ini options for .bandit file #508

Merged
merged 5 commits into from
Sep 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 69 additions & 9 deletions bandit/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,82 @@ def main():
ini_options = _get_options_from_ini(args.ini_path, args.targets)
if ini_options:
# prefer command line, then ini file
args.excluded_paths = _log_option_source(args.excluded_paths,
ini_options.get('exclude'),
'excluded paths')
args.excluded_paths = _log_option_source(
args.excluded_paths,
ini_options.get('exclude'),
'excluded paths')

args.skips = _log_option_source(args.skips, ini_options.get('skips'),
'skipped tests')
args.skips = _log_option_source(
args.skips,
ini_options.get('skips'),
'skipped tests')

args.tests = _log_option_source(
args.tests,
ini_options.get('tests'),
'selected tests')

args.tests = _log_option_source(args.tests, ini_options.get('tests'),
'selected tests')
ini_targets = ini_options.get('targets')
if ini_targets:
ini_targets = ini_targets.split(',')
args.targets = _log_option_source(args.targets, ini_targets,
'selected targets')

args.targets = _log_option_source(
args.targets,
ini_targets,
'selected targets')

# TODO(tmcpeak): any other useful options to pass from .bandit?

args.recursive = _log_option_source(
args.recursive,
ini_options.get('recursive'),
'recursive scan')

args.agg_type = _log_option_source(
args.agg_type,
ini_options.get('aggregate'),
'aggregate output type')

args.context_lines = _log_option_source(
args.context_lines,
ini_options.get('number'),
'max code lines output for issue')

args.profile = _log_option_source(
args.profile,
ini_options.get('profile'),
'profile')

args.severity = _log_option_source(
args.severity,
ini_options.get('level'),
'severity level')

args.confidence = _log_option_source(
args.confidence,
ini_options.get('confidence'),
'confidence level')

args.output_format = _log_option_source(
args.output_format,
ini_options.get('format'),
'output format')
Copy link
Member

Choose a reason for hiding this comment

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

If the format parameter is allowed, we need to also support --msg-template in case someone chooses custom as the format.


args.output_file = _log_option_source(
args.output_file,
ini_options.get('output'),
'output file')

args.debug = _log_option_source(
args.debug,
ini_options.get('debug'),
'debug mode')

Copy link
Member

Choose a reason for hiding this comment

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

How about --verbose?

args.quiet = _log_option_source(
args.quiet,
ini_options.get('quiet'),
'silent mode')

Copy link
Member

Choose a reason for hiding this comment

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

What about --ignore-nosec and --baseline ?

if not args.targets:
LOG.error("No targets found in CLI or ini files, exiting.")
sys.exit(2)
Expand Down