From 5af8b8d3f78a8b7be7820a3e8a9310dc47c5db48 Mon Sep 17 00:00:00 2001 From: anand k Date: Tue, 27 Feb 2024 17:56:38 +0530 Subject: [PATCH] included defusedxml package for parsestring & cleaned upnp schema --- src/helper_startup.py | 2 +- src/proofofwork.py | 2 +- src/upnp.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/helper_startup.py b/src/helper_startup.py index d9002440..52e1bf7a 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -220,7 +220,7 @@ def updateConfig(): addressInKeysFile, 'payloadlengthextrabytes', str(int(previousSmallMessageDifficulty * 1000))) except (ValueError, TypeError, configparser.NoSectionError, - configparser.NoSectionError): + configparser.NoOptionError): continue config.set('bitmessagesettings', 'maxdownloadrate', '0') config.set('bitmessagesettings', 'maxuploadrate', '0') diff --git a/src/proofofwork.py b/src/proofofwork.py index 110baf22..e560cc78 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -272,7 +272,7 @@ def buildCPoW(): try: if "bsd" in sys.platform: # BSD make - call(["make", "-C", os.path.join(paths.codePath(), "bitmsghash"), + call(["make", "-C", os.path.join(paths.codePath(), "bitmsghash"), '-f', 'Makefile.bsd']) # nosec:B607, B603 else: # GNU make diff --git a/src/upnp.py b/src/upnp.py index aed83d8f..659c7de2 100644 --- a/src/upnp.py +++ b/src/upnp.py @@ -1,16 +1,18 @@ -# pylint: disable=too-many-statements,too-many-branches,protected-access,no-self-use +# pylint: disable=too-many-statements,too-many-branches,protected-access,no-self-use """ Complete UPnP port forwarding implementation in separate thread. Reference: http://mattscodecave.com/posts/using-python-and-upnp-to-forward-a-port """ import httplib +import re import socket import time import urllib2 from random import randint from urlparse import urlparse -from xml.dom.minidom import Document, parseString +from xml.dom.minidom import Document # nosec:B408 +from defusedxml.minidom import parseString import queues import state @@ -119,7 +121,7 @@ class Router: # pylint: disable=old-style-class if service.childNodes[0].data.find('WANIPConnection') > 0 or \ service.childNodes[0].data.find('WANPPPConnection') > 0: self.path = service.parentNode.getElementsByTagName('controlURL')[0].childNodes[0].data - self.upnp_schema = service.childNodes[0].data.split(':')[-2] + self.upnp_schema = re.sub(r'[^A-Za-z0-9:-]', '', service.childNodes[0].data.split(':')[-2]) def AddPortMapping( self,