Skip to content

Commit 1326d55

Browse files
committed
[flake8-bandit] Deprecate suspicious-xmle-tree-usage (S320) (#16680)
## Summary Deprecate `S320` because defusedxml has deprecated there `lxml` module and `lxml` has been hardened since. flake8-bandit has removed their implementation as well (PyCQA/bandit#1212). Addresses #13707 ## Test Plan I verified that selecting `S320` prints a warning and fails if the preview mode is enabled.
1 parent c19cd58 commit 1326d55

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

crates/ruff_linter/src/codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
649649
(Flake8Bandit, "317") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousXMLSaxUsage),
650650
(Flake8Bandit, "318") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousXMLMiniDOMUsage),
651651
(Flake8Bandit, "319") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousXMLPullDOMUsage),
652-
(Flake8Bandit, "320") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousXMLETreeUsage),
652+
(Flake8Bandit, "320") => (RuleGroup::Deprecated, rules::flake8_bandit::rules::SuspiciousXMLETreeUsage),
653653
(Flake8Bandit, "321") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousFTPLibUsage),
654654
(Flake8Bandit, "323") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousUnverifiedContextUsage),
655655
(Flake8Bandit, "324") => (RuleGroup::Stable, rules::flake8_bandit::rules::HashlibInsecureHashFunction),

crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs

+8
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,13 @@ impl Violation for SuspiciousXMLPullDOMUsage {
779779
}
780780
}
781781

782+
/// ## Deprecation
783+
///
784+
/// This rule was deprecated as the `lxml` library has been modified to address
785+
/// known vulnerabilities and unsafe defaults. As such, the `defusedxml`
786+
/// library is no longer necessary, `defusedxml` has [deprecated] its `lxml`
787+
/// module.
788+
///
782789
/// ## What it does
783790
/// Checks for uses of insecure XML parsers.
784791
///
@@ -802,6 +809,7 @@ impl Violation for SuspiciousXMLPullDOMUsage {
802809
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
803810
///
804811
/// [preview]: https://docs.astral.sh/ruff/preview/
812+
/// [deprecated]: https://pypi.org/project/defusedxml/0.8.0rc2/#defusedxml-lxml
805813
#[derive(ViolationMetadata)]
806814
pub(crate) struct SuspiciousXMLETreeUsage;
807815

crates/ruff_linter/src/rules/flake8_builtins/rules/stdlib_module_shadowing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::settings::LinterSettings;
2626
/// By default, the module path relative to the project root or [`src`] directories is considered,
2727
/// so a top-level `logging.py` or `logging/__init__.py` will clash with the builtin `logging`
2828
/// module, but `utils/logging.py`, for example, will not. With the
29-
/// [`lint.flake8-builtins.builtins-strict-checking`] option set to `true`, only the last component
29+
/// [`lint.flake8-builtins.strict-checking`] option set to `true`, only the last component
3030
/// of the module name is considered, so `logging.py`, `utils/logging.py`, and
3131
/// `utils/logging/__init__.py` will all trigger the rule.
3232
///

0 commit comments

Comments
 (0)