[`flake8-bandit`] Add missing single-line/dotall regex flag (`S608`) (#15654)

## Summary

Resolves #15653.

## Test Plan

`cargo nextest run` and `cargo insta test`.
This commit is contained in:
InSync 2025-01-22 11:50:22 +07:00 committed by GitHub
parent 1e053531b6
commit f54b82147e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 1 deletions

View File

@ -154,3 +154,15 @@ FROM {var}.table
# to be handled separately
# query58 = f"SELECT\
# * FROM {var}.table"
# https://github.com/astral-sh/ruff/issues/15653
query59 = f"""
SELECT *, foo
FROM ({user_input}) raw
"""
query60 = f"""
SELECT *,
foo
FROM ({user_input}) raw
"""

View File

@ -12,7 +12,16 @@ use crate::checkers::ast::Checker;
use crate::Locator;
static SQL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"(?i)\b(select\s+.*\s+from\s|delete\s+from\s|(insert|replace)\s+.*\s+values\s|update\s+.*\s+set\s)")
Regex::new(
r"(?isx)
\b
(select\s+.*\s+from\s
|delete\s+from\s
|(insert|replace)\s+.*\s+values\s
|update\s+.*\s+set\s
)
",
)
.unwrap()
});

View File

@ -576,3 +576,29 @@ S608.py:144:11: S608 Possible SQL injection vector through string-based query co
148 |
149 | query57 = f"""
|
S608.py:160:11: S608 Possible SQL injection vector through string-based query construction
|
159 | # https://github.com/astral-sh/ruff/issues/15653
160 | query59 = f"""
| ___________^
161 | | SELECT *, foo
162 | | FROM ({user_input}) raw
163 | | """
| |___^ S608
164 | query60 = f"""
165 | SELECT *,
|
S608.py:164:11: S608 Possible SQL injection vector through string-based query construction
|
162 | FROM ({user_input}) raw
163 | """
164 | query60 = f"""
| ___________^
165 | | SELECT *,
166 | | foo
167 | | FROM ({user_input}) raw
168 | | """
| |___^ S608
|