Commit ecd53cc
committed
Fix nosec for nested dicts
Before this commit nosec was searched from the begnning
of the expression's context, which may be broader than
the exact piece of code that a developer wants to skip.
This caused, that for the below example:
1. example = {
2. 'S3_CONFIG_PARAMS': dict( # nosec B106
3. ...
4. ),
5. 'LOCALFS_BASEDIR': '/var/tmp/herp', # nosec B108
6. }
for line 5, nosec from line 2 was returned. Thus `nosec B108` was ignored.
This commit changes the algorithm that search for nosec for an expression
and nosec from the exact line of the expression is preferred.
Resolves: PyCQA#10031 parent 02d73e9 commit ecd53cc
2 files changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
377 | | - | |
| 376 | + | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments