Commit 0be9383
committed
test(tools): filter spurious bandit nosec-bookkeeping warnings
bandit 1.9 emits two classes of stderr WARNING messages that come
from its internal `# nosec` bookkeeping and do not correspond to
any actual security finding:
- "nosec encountered (BXXX), but no failed test": bandit runs each
test against every AST node on a line, not just the node that
actually produces the finding. When several sub-nodes share a
line and only one of them triggers the test, bandit sees the
`# nosec BXXX` from the context of the other sub-nodes too and
warns that the nosec was never used, even though it was used by
the one sub-node that mattered.
- "Test in comment: WORD is not a test name or id, ignoring":
bandit tokenizes every word after `# nosec` and tries to match
it against its test-id catalog. Free-text rationales on the same
line trip this; the previous commit already removed them, but
the wrapper stays resilient against future regressions.
Both warnings are logged at WARNING level on stderr and do not
affect bandit's exit code. `tools/run-linter-checks` now captures
bandit's stderr and drops lines matching either pattern before
echoing the rest to the wrapper's stderr. Real security findings
still surface because bandit is invoked at `--severity-level=high
--confidence-level=high` and would exit non-zero on any actual
issue.
The wrapper now reports `All checks passed!` on a clean tree with
no stderr noise so the sweep is usable without further grep
filtering.1 parent 8b21891 commit 0be9383
1 file changed
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
39 | 80 | | |
40 | 81 | | |
41 | 82 | | |
| |||
66 | 107 | | |
67 | 108 | | |
68 | 109 | | |
69 | | - | |
| 110 | + | |
70 | 111 | | |
71 | 112 | | |
72 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
73 | 127 | | |
74 | 128 | | |
75 | 129 | | |
| |||
119 | 173 | | |
120 | 174 | | |
121 | 175 | | |
| 176 | + | |
122 | 177 | | |
123 | 178 | | |
124 | 179 | | |
| |||
0 commit comments