Commit fe9ca8b
Flag str.replace as possible sql injection (#1044)
* Flag str.replace as possible sql injection
This extends the existing implementation for detecting possible
cases of SQL injection to account for `str.replace` used in the
string construction.
Use of `str.replace` can lead to SQL injection in much the same
way as `str.format` can, and that is already considered in the
pre-existing implementation, along with other common string
constructions.
Resolves #878
* Revert cosmetic change
* Fix lint
* Reduce str.replace to LOW confidence in all cases
Since the rate of false positives may be higher for
str.replace over other string constructions like str.format,
we should reduce to LOW confidence to compensate for this.
* Update bandit/plugins/injection_sql.py
Correct version in versionchanged directive
Co-authored-by: Eric Brown <[email protected]>
* Fix typo in comment
---------
Co-authored-by: Ian Stapleton Cordasco <[email protected]>
Co-authored-by: Eric Brown <[email protected]>1 parent 5ec806d commit fe9ca8b
File tree
3 files changed
+27
-11
lines changed- bandit/plugins
- examples
- tests/functional
3 files changed
+27
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
| |||
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| 90 | + | |
80 | 91 | | |
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
111 | | - | |
| 123 | + | |
112 | 124 | | |
113 | | - | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
119 | | - | |
120 | | - | |
| 131 | + | |
| 132 | + | |
121 | 133 | | |
122 | 134 | | |
123 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
124 | 138 | | |
125 | 139 | | |
126 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
| 442 | + | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | | - | |
| 447 | + | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| |||
0 commit comments