Skip to content

Commit

Permalink
remove B320 (xml_bad_etree) and B410 (import_lxml)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbrown committed Dec 19, 2024
1 parent 8e3c928 commit 38d68e6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 71 deletions.
28 changes: 0 additions & 28 deletions bandit/blacklists/calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,6 @@
| B319 | xml_bad_pulldom | - xml.dom.pulldom.parse | Medium |
| | | - xml.dom.pulldom.parseString | |
+------+---------------------+------------------------------------+-----------+
| B320 | xml_bad_etree | - lxml.etree.parse | Medium |
| | | - lxml.etree.fromstring | |
| | | - lxml.etree.RestrictedElement | |
| | | - lxml.etree.GlobalParserTLS | |
| | | - lxml.etree.getDefaultParser | |
| | | - lxml.etree.check_docinfo | |
+------+---------------------+------------------------------------+-----------+
B321: ftplib
------------
Expand Down Expand Up @@ -615,27 +608,6 @@ def gen_blacklist():
)
)

sets.append(
utils.build_conf_dict(
"xml_bad_etree",
"B320",
issue.Cwe.IMPROPER_INPUT_VALIDATION,
[
"lxml.etree.parse",
"lxml.etree.fromstring",
"lxml.etree.RestrictedElement",
"lxml.etree.GlobalParserTLS",
"lxml.etree.getDefaultParser",
"lxml.etree.check_docinfo",
],
(
"Using {name} to parse untrusted XML data is known to be "
"vulnerable to XML attacks. Replace {name} with its "
"defusedxml equivalent function."
),
)
)

# end of XML tests

sets.append(
Expand Down
28 changes: 0 additions & 28 deletions bandit/blacklists/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,6 @@
| B409 | import_xml_pulldom | - xml.dom.pulldom | low |
+------+---------------------+------------------------------------+-----------+
B410: import_lxml
-----------------
Using various methods to parse untrusted XML data is known to be vulnerable to
XML attacks. Replace vulnerable imports with the equivalent defusedxml package.
+------+---------------------+------------------------------------+-----------+
| ID | Name | Imports | Severity |
+======+=====================+====================================+===========+
| B410 | import_lxml | - lxml | low |
+------+---------------------+------------------------------------+-----------+
B411: import_xmlrpclib
----------------------
Expand Down Expand Up @@ -297,11 +285,6 @@ def gen_blacklist():
"defusedxml package, or make sure defusedxml.defuse_stdlib() "
"is called."
)
lxml_msg = (
"Using {name} to parse untrusted XML data is known to be "
"vulnerable to XML attacks. Replace {name} with the "
"equivalent defusedxml package."
)

sets.append(
utils.build_conf_dict(
Expand Down Expand Up @@ -358,17 +341,6 @@ def gen_blacklist():
)
)

sets.append(
utils.build_conf_dict(
"import_lxml",
"B410",
issue.Cwe.IMPROPER_INPUT_VALIDATION,
["lxml"],
lxml_msg,
"LOW",
)
)

sets.append(
utils.build_conf_dict(
"import_xmlrpclib",
Expand Down
9 changes: 0 additions & 9 deletions examples/xml_lxml.py

This file was deleted.

6 changes: 0 additions & 6 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,6 @@ def test_xml(self):
}
self.check_example("xml_expatbuilder.py", expect)

expect = {
"SEVERITY": {"UNDEFINED": 0, "LOW": 3, "MEDIUM": 1, "HIGH": 0},
"CONFIDENCE": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 0, "HIGH": 4},
}
self.check_example("xml_lxml.py", expect)

expect = {
"SEVERITY": {"UNDEFINED": 0, "LOW": 2, "MEDIUM": 2, "HIGH": 0},
"CONFIDENCE": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 0, "HIGH": 4},
Expand Down

0 comments on commit 38d68e6

Please sign in to comment.