bandit icon indicating copy to clipboard operation
bandit copied to clipboard

B405 complains about any xml.etree.ElementTree import, not just parse-related ones

Open vanschelven opened this issue 3 years ago • 2 comments

B405 complains about any xml.etree.ElementTree import, not just parse-related ones

Importing like so

from defusedxml.ElementTree import Element

gives a bandit error (B405).

This error talks about parsing (which is indeed unsafe); but the imported thing is not related to parsing. At the same time, the suggested remedy (defusedxml) exclusively provides alternatives for parsing-related functions, in particular for parse, iterparse, fromstring, and XMLParser. In other words, the suggested solution of doing the following fails:

# Will fail!
from defusedxml.ElementTree import Element

vanschelven avatar Apr 15 '21 11:04 vanschelven