Skip to content

Commit 5bd318e

Browse files
committed
IMPROVEMENT: use defusedxml because it is safer
1 parent 69740b8 commit 5bd318e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

MethodicConfigurator/annotate_params.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
from sys import exc_info as sys_exc_info
3131
from sys import exit as sys_exit
3232
from typing import Any, Dict, List, Optional, Tuple
33-
import xml.etree.ElementTree as ET
33+
34+
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
35+
3436
import argparse
3537
import logging
3638

39+
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation
40+
41+
3742
# URL of the XML file
3843
BASE_URL = "https://autotest.ardupilot.org/Parameters/"
3944

@@ -341,7 +346,7 @@ def get_xml_data(base_url: str, directory: str, filename: str) -> ET.Element:
341346
raise SystemExit("permission denied to write online XML documentation to file") from e
342347

343348
# Parse the XML data
344-
root = ET.fromstring(xml_data)
349+
root = DET.fromstring(xml_data)
345350

346351
# Load parameter default values if the 00_default.param file exists
347352
try:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
author_email='[email protected]',
8585
packages=find_packages(),
8686
install_requires=[
87+
'defusedxml',
8788
'matplotlib',
8889
'numpy',
8990
'platformdirs',

0 commit comments

Comments
 (0)