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
12 changes: 7 additions & 5 deletions bandit/core/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ def run_tests(self, raw_context, checktype):
val = constants.RANKING_VALUES[result.confidence]
scores["CONFIDENCE"][con] += val
else:
nosec_tests_to_skip = self._get_nosecs_from_contexts(
temp_context
# Only warn about unused nosec if the comment is on this
# specific line, not on a different line of the same
# multiline statement (see #1352)
line_nosec = self.nosec_lines.get(
temp_context["lineno"], None
)
if (
nosec_tests_to_skip
and test._test_id in nosec_tests_to_skip
if line_nosec is not None and (
not line_nosec or test._test_id in line_nosec
):
LOG.warning(
f"nosec encountered ({test._test_id}), but no "
Expand Down