From 82ca66b84678c610530eeb9baa5145097cf566e9 Mon Sep 17 00:00:00 2001 From: KAUTH Date: Tue, 5 Jul 2022 19:27:48 +0200 Subject: [PATCH 1/2] Fix reading the number argument from config file When passing the "number" option from the INI file we did not take into account to store its value as an integer (when that value is not None). Resolves: #922 --- bandit/cli/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index d5eb57dfd..b338508e3 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -512,7 +512,8 @@ def main(): args.context_lines = _log_option_source( parser.get_default("context_lines"), args.context_lines, - ini_options.get("number"), + (None if ini_options.get("number") is None + else int(ini_options.get("number"))), "max code lines output for issue", ) From 29e396ef159799a51b4c396a0be441b9756ba10a Mon Sep 17 00:00:00 2001 From: KAUTH Date: Fri, 8 Jul 2022 00:46:31 +0200 Subject: [PATCH 2/2] Implement a cleaner fix We use the "or" boolean operation to have a cleaner implementation of the solution. --- bandit/cli/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index b338508e3..47588859d 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -512,8 +512,7 @@ def main(): args.context_lines = _log_option_source( parser.get_default("context_lines"), args.context_lines, - (None if ini_options.get("number") is None - else int(ini_options.get("number"))), + int(ini_options.get("number") or 0) or None, "max code lines output for issue", )