You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve handling nosec for multi-line strings (#915)
This commit improves handling nosecs
in multi-line strings, like:
1. nosec_not_working = f"""
2. SELECT * FROM {table}
3. """ # nosec
Before this change, bandit was checking if there is
a nosec in line 1. Now, it searches for nosec in all
lines of the expression.
In python 3.7, linerange for a multiline expression is sqeezed to
first line. Thus, if nosec is set in the second or further line
then it is not taken into account by bandit.
This commit also moves detecting nosec without test number
to test phase from "pre-visit" phase.
It may increase the time of performing checks but avoids
counting the same nosec mark multiple times.
"pre-visit" phase is run separately for each part of multi-line
string split by FormattedValue items. Thus for the above example,
it would be run twice, the first time for "\n SELECT * FROM "
and the second time for "\n" making the nosec being counted twice.
Resolves: #880
0 commit comments