use defusedxml to avoid DoS attacks while loading XML

This commit is contained in:
Hans-Christoph Steiner 2018-08-29 17:27:04 +02:00
parent cc94ebca30
commit 4d13a904f3
4 changed files with 10 additions and 4 deletions

View file

@ -28,6 +28,7 @@
import collections
import defusedxml.minidom
import git
import glob
import os
@ -36,7 +37,6 @@ import logging
import requests
import shutil
import tempfile
import xml.dom.minidom
import zipfile
from argparse import ArgumentParser
@ -94,7 +94,7 @@ For more info on this idea:
continue
dest = os.path.join(cpdir, f)
if f.endswith('.xml'):
doc = xml.dom.minidom.parse(repof)
doc = defusedxml.minidom.parse(repof)
output = doc.toprettyxml(encoding='utf-8')
with open(dest, 'wb') as f:
f.write(output)