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

View File

@ -140,7 +140,6 @@ class MsgDecode(object):
self.body = body
if __name__ == '__main__':
import random
messageData = {
"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))

View File

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

View File

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

View File

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

View File

@ -113,7 +113,8 @@ def loadConfig():
BMConfigParser().set('bitmessagesettings', 'maxuploadrate', '0')
BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', '8')
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(
'bitmessagesettings', 'stopresendingafterxdays', '')
BMConfigParser().set(