always use defusedxml.ElementTree, never xml.etree.ElementTree

defusedxml is now available and installed everywhere, including the
buildserver VM and the buildserver host.

This fixes bandit's error because it didn't understand the try: block
* https://gitlab.com/eighthave/fdroidserver/-/jobs/3965835264
* https://bandit.readthedocs.io/en/1.7.5/blacklists/blacklist_calls.html#b313-b320-xml
This commit is contained in:
Hans-Christoph Steiner 2023-03-20 14:20:48 +01:00
parent 4295d254f9
commit e903952029

View file

@ -51,11 +51,7 @@ import tempfile
import json import json
from pathlib import Path from pathlib import Path
# TODO change to only import defusedxml once its installed everywhere import defusedxml.ElementTree as XMLElementTree
try:
import defusedxml.ElementTree as XMLElementTree
except ImportError:
import xml.etree.ElementTree as XMLElementTree # nosec this is a fallback only
from base64 import urlsafe_b64encode from base64 import urlsafe_b64encode
from binascii import hexlify from binascii import hexlify