mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[flake8-bandit
] Move unsafe-markup-use
from RUF035
to S704
(#15957)
## Summary `RUF035` has been backported into bandit as `S704` in this [PR](https://github.com/PyCQA/bandit/pull/1225) This moves the rule and its corresponding setting to the `flake8-bandit` category ## Test Plan `cargo nextest run` --------- Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
798fa47c2e
commit
c0b1413ecd
26 changed files with 436 additions and 261 deletions
|
@ -2,17 +2,17 @@ import flask
|
|||
from markupsafe import Markup, escape
|
||||
|
||||
content = "<script>alert('Hello, world!')</script>"
|
||||
Markup(f"unsafe {content}") # RUF035
|
||||
flask.Markup("unsafe {}".format(content)) # RUF035
|
||||
Markup(f"unsafe {content}") # S704
|
||||
flask.Markup("unsafe {}".format(content)) # S704
|
||||
Markup("safe {}").format(content)
|
||||
flask.Markup(b"safe {}", encoding='utf-8').format(content)
|
||||
escape(content)
|
||||
Markup(content) # RUF035
|
||||
flask.Markup("unsafe %s" % content) # RUF035
|
||||
Markup(content) # S704
|
||||
flask.Markup("unsafe %s" % content) # S704
|
||||
Markup(object="safe")
|
||||
Markup(object="unsafe {}".format(content)) # Not currently detected
|
||||
|
||||
# NOTE: We may be able to get rid of these false positives with red-knot
|
||||
# if it includes comprehensive constant expression detection/evaluation.
|
||||
Markup("*" * 8) # RUF035 (false positive)
|
||||
flask.Markup("hello {}".format("world")) # RUF035 (false positive)
|
||||
Markup("*" * 8) # S704 (false positive)
|
||||
flask.Markup("hello {}".format("world")) # S704 (false positive)
|
|
@ -2,5 +2,5 @@ from markupsafe import Markup
|
|||
from webhelpers.html import literal
|
||||
|
||||
content = "<script>alert('Hello, world!')</script>"
|
||||
Markup(f"unsafe {content}") # RUF035
|
||||
literal(f"unsafe {content}") # RUF035
|
||||
Markup(f"unsafe {content}") # S704
|
||||
literal(f"unsafe {content}") # S704
|
|
@ -4,4 +4,4 @@ from webhelpers.html import literal
|
|||
# additional markup names to be skipped if we don't import either
|
||||
# markupsafe or flask first.
|
||||
content = "<script>alert('Hello, world!')</script>"
|
||||
literal(f"unsafe {content}") # RUF035
|
||||
literal(f"unsafe {content}") # S704
|
|
@ -6,4 +6,4 @@ Markup(clean(content))
|
|||
|
||||
# indirect assignments are currently not supported
|
||||
cleaned = clean(content)
|
||||
Markup(cleaned) # RUF035
|
||||
Markup(cleaned) # S704
|
Loading…
Add table
Add a link
Reference in a new issue