Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bandit/core/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, testset, debug, nosec_lines, metrics):
self.debug = debug
self.nosec_lines = nosec_lines
self.metrics = metrics
self.skipped_pairs = set()

def run_tests(self, raw_context, checktype):
"""Runs all tests for a certain type of check, for example
Expand Down Expand Up @@ -91,6 +92,11 @@ def run_tests(self, raw_context, checktype):
f"skipped, nosec for test {result.test_id}"
)
self.metrics.note_skipped_test()
if result.linerange:
for ln in result.linerange:
self.skipped_pairs.add(
(result.test_id, ln)
)
continue

self.results.append(result)
Expand All @@ -109,6 +115,8 @@ def run_tests(self, raw_context, checktype):
if (
nosec_tests_to_skip
and test._test_id in nosec_tests_to_skip
and (test._test_id, temp_context["lineno"])
not in self.skipped_pairs
):
LOG.warning(
f"nosec encountered ({test._test_id}), but no "
Expand Down
Loading