mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Skip S608 for expressionless f-strings (#17999)
This commit is contained in:
parent
cd1d906ffa
commit
b765dc48e9
3 changed files with 14 additions and 1 deletions
|
@ -166,3 +166,6 @@ query60 = f"""
|
|||
foo
|
||||
FROM ({user_input}) raw
|
||||
"""
|
||||
|
||||
# https://github.com/astral-sh/ruff/issues/17967
|
||||
query61 = f"SELECT * FROM table" # skip expressionless f-strings
|
||||
|
|
|
@ -100,7 +100,15 @@ pub(crate) fn hardcoded_sql_expression(checker: &Checker, expr: &Expr) {
|
|||
}
|
||||
|
||||
// f"select * from table where val = {val}"
|
||||
Expr::FString(f_string) => concatenated_f_string(f_string, checker.locator()),
|
||||
Expr::FString(f_string)
|
||||
if f_string
|
||||
.value
|
||||
.f_strings()
|
||||
.any(|fs| fs.elements.iter().any(ast::FStringElement::is_expression)) =>
|
||||
{
|
||||
concatenated_f_string(f_string, checker.locator())
|
||||
}
|
||||
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
|
|
@ -601,4 +601,6 @@ S608.py:164:11: S608 Possible SQL injection vector through string-based query co
|
|||
167 | | FROM ({user_input}) raw
|
||||
168 | | """
|
||||
| |___^ S608
|
||||
169 |
|
||||
170 | # https://github.com/astral-sh/ruff/issues/17967
|
||||
|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue