Merge branch '1230' into v0.6

This commit is contained in:
Peter Šurda 2018-05-03 23:14:56 +02:00
commit 4ea6f0208c
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
7 changed files with 15 additions and 8 deletions

4
bandit.yml Normal file
View File

@ -0,0 +1,4 @@
# Codacy uses Bandit.
# Asserts are accepted throughout the project.
skips: ['B101']

View File

@ -1,6 +1,6 @@
import socket import socket
import defaultKnownNodes import defaultKnownNodes
import pickle import pickle # nosec
import time import time
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
@ -24,7 +24,7 @@ def knownNodes():
try: try:
with open(state.appdata + 'knownnodes.dat', 'rb') as pickleFile: with open(state.appdata + 'knownnodes.dat', 'rb') as pickleFile:
with knownnodes.knownNodesLock: with knownnodes.knownNodesLock:
knownnodes.knownNodes = pickle.load(pickleFile) knownnodes.knownNodes = pickle.load(pickleFile) # nosec
# the old format was {Peer:lastseen, ...} # the old format was {Peer:lastseen, ...}
# the new format is {Peer:{"lastseen":i, "rating":f}} # the new format is {Peer:{"lastseen":i, "rating":f}}
for stream in knownnodes.knownNodes.keys(): for stream in knownnodes.knownNodes.keys():

View File

@ -140,7 +140,6 @@ class MsgDecode(object):
self.body = body self.body = body
if __name__ == '__main__': if __name__ == '__main__':
import random
messageData = { messageData = {
"subject": ''.join(helper_random.randomchoice(string.ascii_lowercase + string.digits) for _ in range(40)), "subject": ''.join(helper_random.randomchoice(string.ascii_lowercase + string.digits) for _ in range(40)),
"body": ''.join(helper_random.randomchoice(string.ascii_lowercase + string.digits) for _ in range(10000)) "body": ''.join(helper_random.randomchoice(string.ascii_lowercase + string.digits) for _ in range(10000))

View File

@ -1,3 +1,5 @@
"""Convenience functions for random operations. Not suitable for security / cryptography operations."""
import os import os
import random import random
from pyelliptic.openssl import OpenSSL from pyelliptic.openssl import OpenSSL
@ -48,9 +50,9 @@ def randomrandrange(x, y=None):
but doesnt actually build a range object. but doesnt actually build a range object.
""" """
if isinstance(y, NoneType): if isinstance(y, NoneType):
return random.randrange(x) return random.randrange(x) # nosec
else: else:
return random.randrange(x, y) return random.randrange(x, y) # nosec
def randomchoice(population): def randomchoice(population):
@ -60,4 +62,4 @@ def randomchoice(population):
sequence seq. If seq is empty, raises sequence seq. If seq is empty, raises
IndexError. IndexError.
""" """
return random.choice(population) return random.choice(population) # nosec

View File

@ -5,7 +5,7 @@ from helper_sql import *
try: try:
from PyQt4 import QtGui from PyQt4 import QtGui
haveQt = True haveQt = True
except Exception: except ImportError:
haveQt = False haveQt = False
def search_translate (context, text): def search_translate (context, text):

View File

@ -91,6 +91,7 @@ class SqlBulkExecute:
def execute(sqlStatement, *args): def execute(sqlStatement, *args):
"""Used for statements that do not return results.""" """Used for statements that do not return results."""
sqlSubmitQueue.put(sqlStatement) sqlSubmitQueue.put(sqlStatement)
if args == (): if args == ():
sqlSubmitQueue.put('') sqlSubmitQueue.put('')
else: else:

View File

@ -113,7 +113,8 @@ def loadConfig():
BMConfigParser().set('bitmessagesettings', 'maxuploadrate', '0') BMConfigParser().set('bitmessagesettings', 'maxuploadrate', '0')
BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', '8') BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', '8')
BMConfigParser().set('bitmessagesettings', 'ttl', '367200') BMConfigParser().set('bitmessagesettings', 'ttl', '367200')
#start:UI setting to stop trying to send messages after X days/months
#start:UI setting to stop trying to send messages after X days/months
BMConfigParser().set( BMConfigParser().set(
'bitmessagesettings', 'stopresendingafterxdays', '') 'bitmessagesettings', 'stopresendingafterxdays', '')
BMConfigParser().set( BMConfigParser().set(