[ruff] Add implementation for flake8-markupsafe via RUF035#14224
[ruff] Add implementation for flake8-markupsafe via RUF035#14224MichaReiser merged 11 commits intoastral-sh:mainfrom
ruff] Add implementation for flake8-markupsafe via RUF035#14224Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF035 | 51 | 51 | 0 | 0 | 0 |
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/flake8_markupsafe/MS001.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Show resolved
Hide resolved
|
Nice contribution, thanks! |
Lifts fast check out of slow path. Adds additional test cases. Mentions i18n deviation in docstring.
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/flake8_markupsafe/MS001.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
This looks good to me. Thank you. The only change I would make is that I don't think it's worth introducing a new rule group for a single rule.
I'd also like to hear @AlexWaygood's opinion on the rule itself.
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
…rkup_use.rs Co-authored-by: Micha Reiser <micha@reiser.io>
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
AlexWaygood
left a comment
There was a problem hiding this comment.
I've never used markupsafe but it makes sense to me that this would be an important security consideration. I think it's good for linters to catch this.
Long-term, we should be able to improve the accuracy of rules like this when we switch to using red-knot as a backend (the LiteralString type is explicitly designed for this use case). But I don't think that should stop us from implementing this rule now!
flake8-markupsafe] Add implementation for MS001 via RUF035
flake8-markupsafe] Add implementation for MS001 via RUF035ruff] Add implementation for flake8-markupsafe via RUF035
Closes #14124
Summary
This adds an implementation for flake8-markupsafe, minus the questionable exception for i18n and mako support, but with the ability to specify further aliases/subclasses/functionally equivalent for
markupsafe.Markup. By defaultflask.Markupis also detected as a commonly used alias.Test Plan
cargo nextest run