Code quality + Security related changes #2184

Merged
anand-skss merged 2 commits from code-quality1 into v0.6 2024-02-28 04:35:51 +01:00
3 changed files with 7 additions and 5 deletions
Showing only changes of commit 5af8b8d3f7 - Show all commits

View File

@ -220,7 +220,7 @@ def updateConfig():
addressInKeysFile, 'payloadlengthextrabytes', addressInKeysFile, 'payloadlengthextrabytes',
str(int(previousSmallMessageDifficulty * 1000))) str(int(previousSmallMessageDifficulty * 1000)))
except (ValueError, TypeError, configparser.NoSectionError, except (ValueError, TypeError, configparser.NoSectionError,
configparser.NoSectionError): configparser.NoOptionError):
continue continue
config.set('bitmessagesettings', 'maxdownloadrate', '0') config.set('bitmessagesettings', 'maxdownloadrate', '0')
config.set('bitmessagesettings', 'maxuploadrate', '0') config.set('bitmessagesettings', 'maxuploadrate', '0')

View File

@ -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. Complete UPnP port forwarding implementation in separate thread.
Reference: http://mattscodecave.com/posts/using-python-and-upnp-to-forward-a-port Reference: http://mattscodecave.com/posts/using-python-and-upnp-to-forward-a-port
""" """
import httplib import httplib
import re
import socket import socket
import time import time
import urllib2 import urllib2
from random import randint from random import randint
from urlparse import urlparse 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 queues
import state import state
@ -119,7 +121,7 @@ class Router: # pylint: disable=old-style-class
if service.childNodes[0].data.find('WANIPConnection') > 0 or \ if service.childNodes[0].data.find('WANIPConnection') > 0 or \
service.childNodes[0].data.find('WANPPPConnection') > 0: service.childNodes[0].data.find('WANPPPConnection') > 0:
self.path = service.parentNode.getElementsByTagName('controlURL')[0].childNodes[0].data 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( def AddPortMapping(
self, self,