From 5c3d5559500b18b5462b5e48d180f329d33eaa09 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Wed, 12 Mar 2025 14:48:35 -0400 Subject: [PATCH] [`flake8-bandit`] Stabilize `unsafe-markup-use` (`S704`) (#16643) Summary -- Stabilizes S704, which is also being recoded from RUF035 in 0.10. Test Plan -- Existing tests with `PreviewMode` removed from the settings. There was one issue closed on 2024-12-20 calling the rule noisy and asking for a config option, but the option was added and then there were no more issues or PRs. --- crates/ruff_linter/src/codes.rs | 2 +- crates/ruff_linter/src/rules/flake8_bandit/mod.rs | 4 +--- ...ff_linter__rules__flake8_bandit__tests__S704_S704.py.snap} | 0 3 files changed, 2 insertions(+), 4 deletions(-) rename crates/ruff_linter/src/rules/flake8_bandit/snapshots/{ruff_linter__rules__flake8_bandit__tests__preview__S704_S704.py.snap => ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap} (100%) diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index d86f9b281b..b0234dc1a1 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -690,7 +690,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Bandit, "612") => (RuleGroup::Stable, rules::flake8_bandit::rules::LoggingConfigInsecureListen), (Flake8Bandit, "701") => (RuleGroup::Stable, rules::flake8_bandit::rules::Jinja2AutoescapeFalse), (Flake8Bandit, "702") => (RuleGroup::Stable, rules::flake8_bandit::rules::MakoTemplates), - (Flake8Bandit, "704") => (RuleGroup::Preview, rules::flake8_bandit::rules::UnsafeMarkupUse), + (Flake8Bandit, "704") => (RuleGroup::Stable, rules::flake8_bandit::rules::UnsafeMarkupUse), // flake8-boolean-trap (Flake8BooleanTrap, "001") => (RuleGroup::Stable, rules::flake8_boolean_trap::rules::BooleanTypeHintPositionalArgument), diff --git a/crates/ruff_linter/src/rules/flake8_bandit/mod.rs b/crates/ruff_linter/src/rules/flake8_bandit/mod.rs index 8c4b55665a..3eaab135b6 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/mod.rs @@ -87,6 +87,7 @@ mod tests { #[test_case(Rule::DjangoExtra, Path::new("S610.py"))] #[test_case(Rule::DjangoRawSql, Path::new("S611.py"))] #[test_case(Rule::TarfileUnsafeMembers, Path::new("S202.py"))] + #[test_case(Rule::UnsafeMarkupUse, Path::new("S704.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( @@ -103,7 +104,6 @@ mod tests { #[test_case(Rule::SuspiciousURLOpenUsage, Path::new("S310.py"))] #[test_case(Rule::SuspiciousNonCryptographicRandomUsage, Path::new("S311.py"))] #[test_case(Rule::SuspiciousTelnetUsage, Path::new("S312.py"))] - #[test_case(Rule::UnsafeMarkupUse, Path::new("S704.py"))] fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( "preview__{}_{}", @@ -136,7 +136,6 @@ mod tests { extend_markup_names: vec!["webhelpers.html.literal".to_string()], ..Default::default() }, - preview: PreviewMode::Enabled, ..LinterSettings::for_rule(rule_code) }, )?; @@ -158,7 +157,6 @@ mod tests { allowed_markup_calls: vec!["bleach.clean".to_string()], ..Default::default() }, - preview: PreviewMode::Enabled, ..LinterSettings::for_rule(rule_code) }, )?; diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S704_S704.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap similarity index 100% rename from crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S704_S704.py.snap rename to crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap