Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38f7628

Browse files
authoredMay 13, 2022
Merge branch 'Bitmessage:v0.6' into test_refactor_sqlthread
2 parents a13a37d + 991e470 commit 38f7628

27 files changed

+263
-137
lines changed
 

‎.buildbot/android/Dockerfile

Lines changed: 102 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,117 @@
1+
12
# A container for buildbot
23
FROM ubuntu:bionic AS android
34
# FROM ubuntu:20.04 AS buildbot-bionic
45

5-
RUN apt -y update -qq
6-
RUN apt -y install wget
7-
8-
RUN wget -nc "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
9-
RUN wget -nc "https://dl.google.com/android/repository/android-ndk-r23b-linux.zip"
10-
RUN wget -nc "http://archive.apache.org/dist/ant/binaries/apache-ant-1.10.12-bin.tar.gz"
11-
12-
# SYSTEM DEPENDENCIES
13-
14-
RUN apt -y install --no-install-recommends python3-pip \
15-
pip3 python3 virtualenv python3-setuptools \
16-
python3-wheel git unzip sudo patch bzip2 lzma
17-
RUN apt -y autoremove
18-
19-
# BUILD DEPENDENCIES
6+
ENV ANDROID_HOME="/opt/android"
207

21-
RUN dpkg --add-architecture i386
22-
RUN apt -y update -qq
23-
RUN apt -y install -qq --no-install-recommends build-essential \
24-
ccache git python3 python3-dev libncurses5:i386 libstdc++6:i386 \
25-
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 \
26-
libidn11:i386 zip zlib1g-dev zlib1g:i386
27-
RUN apt -y autoremove
28-
RUN apt -y clean
8+
RUN apt -y update -qq \
9+
&& apt -y install -qq --no-install-recommends curl unzip ca-certificates \
10+
&& apt -y autoremove
2911

30-
# RECIPES DEPENDENCIES
3112

32-
RUN dpkg --add-architecture i386
33-
RUN apt -y update -qq
34-
RUN apt -y install -qq --no-install-recommends libffi-dev autoconf \
35-
automake cmake gettext libltdl-dev libtool pkg-config
36-
RUN apt -y autoremove
37-
RUN apt -y clean
38-
39-
# INSTALL ANDROID PACKAGES
40-
41-
RUN pip3 install buildozer==1.2.0
42-
RUN pip3 install --upgrade cython==0.29.15
43-
44-
# INSTALL NDK
13+
ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk"
14+
ENV ANDROID_NDK_VERSION="22b"
15+
ENV ANDROID_NDK_HOME_V="${ANDROID_NDK_HOME}-r${ANDROID_NDK_VERSION}"
4516

4617
# get the latest version from https://developer.android.com/ndk/downloads/index.html
47-
RUN mkdir --parents "/opt/android/android-ndk-r23b"
48-
RUN unzip -q "android-ndk-r23b-linux.zip" -d "/opt/android"
49-
RUN ln -sfn "/opt/android/android-ndk-r23b" "/opt/android/android-ndk"
50-
RUN rm -rf "android-ndk-r23b-linux.zip"
51-
52-
# INSTALL APACHE-ANT
18+
ENV ANDROID_NDK_ARCHIVE="android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip"
19+
ENV ANDROID_NDK_DL_URL="https://dl.google.com/android/repository/${ANDROID_NDK_ARCHIVE}"
5320

54-
RUN tar -xf "apache-ant-1.10.12-bin.tar.gz" -C "/opt/android"
55-
RUN ln -sfn "/opt/android/apache-ant-1.10.12" "/opt/android/apache-ant"
56-
RUN rm -rf "apache-ant-1.10.12-bin.tar.gz"
21+
# download and install Android NDK
22+
RUN curl "${ANDROID_NDK_DL_URL}" \
23+
--output "${ANDROID_NDK_ARCHIVE}" \
24+
&& mkdir --parents "${ANDROID_NDK_HOME_V}" \
25+
&& unzip -q "${ANDROID_NDK_ARCHIVE}" -d "${ANDROID_HOME}" \
26+
&& ln -sfn "${ANDROID_NDK_HOME_V}" "${ANDROID_NDK_HOME}" \
27+
&& rm -rf "${ANDROID_NDK_ARCHIVE}"
5728

58-
# INSTALL SDK
29+
ENV ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
5930

6031
# get the latest version from https://developer.android.com/studio/index.html
61-
RUN mkdir --parents "/opt/android/android-sdk"
62-
RUN unzip -q "sdk-tools-linux-4333796.zip" -d "/opt/android/android-sdk"
63-
RUN rm -rf "sdk-tools-linux-4333796.zip"
64-
# update Android SDK, install Android API, Build Tools...
65-
RUN mkdir --parents "/opt/android/android-sdk/.android/"
32+
ENV ANDROID_SDK_TOOLS_VERSION="8092744"
33+
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="30.0.3"
34+
ENV ANDROID_SDK_TOOLS_ARCHIVE="commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip"
35+
ENV ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
36+
ENV ANDROID_SDK_MANAGER="${ANDROID_SDK_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_HOME}"
37+
38+
# download and install Android SDK
39+
RUN curl "${ANDROID_SDK_TOOLS_DL_URL}" \
40+
--output "${ANDROID_SDK_TOOLS_ARCHIVE}" \
41+
&& mkdir --parents "${ANDROID_SDK_HOME}" \
42+
&& unzip -q "${ANDROID_SDK_TOOLS_ARCHIVE}" -d "${ANDROID_SDK_HOME}" \
43+
&& mv "${ANDROID_SDK_HOME}/cmdline-tools" "${ANDROID_SDK_HOME}/tools" \
44+
&& rm -rf "${ANDROID_SDK_TOOLS_ARCHIVE}"
45+
46+
# update Android SDK, install Android API, Build Tools...
47+
RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \
48+
&& echo '### User Sources for Android SDK Manager' \
49+
> "${ANDROID_SDK_HOME}/.android/repositories.cfg"
50+
6651
# accept Android licenses (JDK necessary!)
67-
RUN apt -y update -qq
68-
RUN apt -y install -qq --no-install-recommends openjdk-11-jdk
69-
RUN apt -y autoremove
70-
RUN yes | "/opt/android/android-sdk/tools/bin/sdkmanager" "build-tools;29.0.2" > /dev/null
52+
RUN apt -y update -qq \
53+
&& apt -y install -qq --no-install-recommends \
54+
openjdk-11-jdk-headless \
55+
&& apt -y autoremove
56+
RUN yes | ${ANDROID_SDK_MANAGER} --licenses > /dev/null
57+
7158
# download platforms, API, build tools
72-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "platforms;android-24" > /dev/null
73-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "platforms;android-28" > /dev/null
74-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "build-tools;29.0.2" > /dev/null
75-
RUN "/opt/android/android-sdk/tools/bin/sdkmanager" "extras;android;m2repository" > /dev/null
76-
RUN find /opt/android/android-sdk -type f -perm /0111 -print0|xargs -0 chmod a+x
77-
RUN chown -R buildbot.buildbot /opt/android/android-sdk
78-
RUN chmod +x "/opt/android/android-sdk/tools/bin/avdmanager"
59+
RUN ${ANDROID_SDK_MANAGER} "platforms;android-30" > /dev/null && \
60+
${ANDROID_SDK_MANAGER} "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" > /dev/null && \
61+
${ANDROID_SDK_MANAGER} "extras;android;m2repository" > /dev/null && \
62+
chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
63+
64+
# download ANT
65+
ENV APACHE_ANT_VERSION="1.9.4"
66+
ENV APACHE_ANT_ARCHIVE="apache-ant-${APACHE_ANT_VERSION}-bin.tar.gz"
67+
ENV APACHE_ANT_DL_URL="https://archive.apache.org/dist/ant/binaries/${APACHE_ANT_ARCHIVE}"
68+
ENV APACHE_ANT_HOME="${ANDROID_HOME}/apache-ant"
69+
ENV APACHE_ANT_HOME_V="${APACHE_ANT_HOME}-${APACHE_ANT_VERSION}"
70+
71+
RUN curl "${APACHE_ANT_DL_URL}" \
72+
--output "${APACHE_ANT_ARCHIVE}" \
73+
&& tar -xf "${APACHE_ANT_ARCHIVE}" -C "${ANDROID_HOME}" \
74+
&& ln -sfn "${APACHE_ANT_HOME_V}" "${APACHE_ANT_HOME}" \
75+
&& rm -rf "${APACHE_ANT_ARCHIVE}"
76+
77+
# install system/build dependencies
78+
RUN apt -y update -qq \
79+
&& apt -y install -qq --no-install-recommends \
80+
python3 \
81+
python3-dev \
82+
python3-pip \
83+
python3-setuptools \
84+
python3-venv \
85+
wget \
86+
lbzip2 \
87+
bzip2 \
88+
lzma \
89+
patch \
90+
sudo \
91+
software-properties-common \
92+
git \
93+
zip \
94+
unzip \
95+
build-essential \
96+
ccache \
97+
autoconf \
98+
libtool \
99+
pkg-config \
100+
zlib1g-dev \
101+
libncurses5-dev \
102+
libncursesw5-dev \
103+
libtinfo5 \
104+
cmake \
105+
libffi-dev \
106+
libssl-dev \
107+
automake \
108+
gettext \
109+
libltdl-dev \
110+
libidn11 \
111+
&& apt -y autoremove \
112+
&& apt -y clean
113+
114+
# INSTALL ANDROID PACKAGES
115+
116+
RUN pip3 install buildozer==1.2.0
117+
RUN pip3 install --upgrade cython==0.29.15

‎.buildbot/kivy/Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
FROM ubuntu:bionic AS kivy
33
# FROM ubuntu:20.04 AS buildbot-bionic
44

5+
ENV DEBIAN_FRONTEND=noninteractive
6+
57
RUN apt-get update
68

79
RUN apt-get -y install sudo
810

911
RUN apt-get install -yq python-setuptools \
1012
python-setuptools libssl-dev libpq-dev python-prctl python-dev \
11-
python-dev python-virtualenv python-pip virtualenv \
12-
libssl-dev \
13-
python-dev \
13+
python-virtualenv python-pip virtualenv \
14+
libjpeg-dev zlib1g-dev python3-dev \
1415
python3-virtualenv \
1516
python3-pip \
16-
wget
17+
wget \
18+
build-essential libcap-dev libmtdev-dev xvfb xclip git python3-opencv
19+
20+
RUN ln -sf /usr/bin/python3 /usr/bin/python
21+
22+
RUN pip3 install Cython Pillow pyzbar telenium
1723

18-
RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh
24+
RUN pip3 install --upgrade setuptools pip
1925

20-
RUN chmod a+rx "/usr/local/bin/travis2bash.sh"
26+
RUN pip3 install -e git+https://github.com/kivymd/KivyMD#egg=kivymd

‎.buildbot/kivy/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
python setup.py install --user

‎.buildbot/kivy/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
travis2bash.sh .travis-kivy.yml
3+
xvfb-run python tests-kivy.py

‎.buildbot/tox/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:bionic AS tox
2+
3+
RUN apt-get update
4+
5+
# Common apt packages
6+
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
7+
software-properties-common build-essential libcap-dev libssl-dev \
8+
python-all-dev python-setuptools wget xvfb language-pack-en \
9+
libffi-dev python3-dev python3-pip python3.8 python3.8-dev python3.8-venv \
10+
python-msgpack python-pip python-qt4 python-six qtbase5-dev qt5-default \
11+
tor
12+
13+
RUN python3.8 -m pip install setuptools wheel
14+
RUN python3.8 -m pip install --upgrade pip tox virtualenv
15+
16+
ENV LANG en_US.UTF-8
17+
ENV LANGUAGE en_US:en
18+
ENV LC_ALL en_US.UTF-8

‎.buildbot/tox/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
tox -e lint-basic # || exit 1
4+
tox

‎Dockerfile

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A container for PyBitmessage daemon
22

3-
FROM ubuntu:xenial
3+
FROM ubuntu:bionic
44

55
RUN apt-get update
66

@@ -9,35 +9,29 @@ RUN apt-get install -yq --no-install-suggests --no-install-recommends \
99
build-essential libcap-dev libssl-dev \
1010
python-all-dev python-msgpack python-pip python-setuptools
1111

12-
RUN pip2 install --upgrade pip
13-
1412
EXPOSE 8444 8442
1513

1614
ENV HOME /home/bitmessage
1715
ENV BITMESSAGE_HOME ${HOME}
1816

1917
WORKDIR ${HOME}
2018
ADD . ${HOME}
19+
COPY packages/docker/launcher.sh /usr/bin/
2120

22-
# Install tests dependencies
23-
RUN pip2 install -r requirements.txt
2421
# Install
25-
RUN python2 setup.py install
22+
RUN pip2 install jsonrpclib .
23+
24+
# Cleanup
25+
RUN rm -rf /var/lib/apt/lists/*
26+
RUN rm -rf ${HOME}
2627

2728
# Create a user
28-
RUN useradd bitmessage && chown -R bitmessage ${HOME}
29+
RUN useradd -r bitmessage && chown -R bitmessage ${HOME}
2930

3031
USER bitmessage
3132

32-
# Clean HOME
33-
RUN rm -rf ${HOME}/*
34-
3533
# Generate default config
3634
RUN pybitmessage -t
3735

38-
# Setup environment
39-
RUN APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \
40-
&& echo "\napiusername: api\napipassword: $APIPASS" \
41-
&& echo "apienabled = true\napiinterface = 0.0.0.0\napiusername = api\napipassword = $APIPASS" >> keys.dat
42-
43-
CMD ["pybitmessage", "-d"]
36+
ENTRYPOINT ["launcher.sh"]
37+
CMD ["-d"]

‎MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include COPYING
22
include README.md
33
include requirements.txt
44
recursive-include desktop *
5+
recursive-include packages/apparmor *

‎packages/docker/launcher.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Setup the environment for docker container
4+
APIUSER=${USER:-api}
5+
APIPASS=${PASSWORD:-$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)}
6+
7+
echo "\napiusername: $APIUSER\napipassword: $APIPASS"
8+
9+
sed -i -e "s|\(apiinterface = \).*|\10\.0\.0\.0|g" \
10+
-e "s|\(apivariant = \).*|\1json|g" \
11+
-e "s|\(apiusername = \).*|\1$APIUSER|g" \
12+
-e "s|\(apipassword = \).*|\1$APIPASS|g" \
13+
-e "s|apinotifypath = .*||g" ${BITMESSAGE_HOME}/keys.dat
14+
15+
# Run
16+
exec pybitmessage "$@"

‎setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ max-line-length = 119
88

99
[flake8]
1010
max-line-length = 119
11+
exclude = bitmessagecli.py,bitmessagecurses,bitmessageqt,plugins,tests,umsgpack
1112
ignore = E722,F841,W503
1213
# E722: pylint is preferred for bare-except
1314
# F841: pylint is preferred for unused-variable

‎src/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
import hashlib
6363
import httplib
6464
import json
65-
import random # nosec
65+
import random
6666
import socket
67-
import subprocess
67+
import subprocess # nosec B404
6868
import time
6969
import xmlrpclib
7070
from binascii import hexlify, unhexlify
@@ -240,7 +240,7 @@ def serve_forever(self, poll_interval=None):
240240
if attempt > 0:
241241
logger.warning(
242242
'Failed to start API listener on port %s', port)
243-
port = random.randint(32767, 65535)
243+
port = random.randint(32767, 65535) # nosec B311
244244
se = StoppableRPCServer(
245245
(config.get(
246246
'bitmessagesettings', 'apiinterface'),
@@ -266,7 +266,7 @@ def serve_forever(self, poll_interval=None):
266266
if apiNotifyPath:
267267
logger.info('Trying to call %s', apiNotifyPath)
268268
try:
269-
subprocess.call([apiNotifyPath, "startingUp"])
269+
subprocess.call([apiNotifyPath, "startingUp"]) # nosec B603
270270
except OSError:
271271
logger.warning(
272272
'Failed to call %s, removing apinotifypath setting',

‎src/bitmessagekivy/baseclass/__init__.py

Whitespace-only changes.

‎src/bitmessagekivy/baseclass/addressbook.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
StringProperty
1919
)
2020
from kivy.uix.screenmanager import Screen
21-
21+
from kivy.app import App
2222

2323
import state
2424

25-
2625
from bitmessagekivy.get_platform import platform
2726
from bitmessagekivy import kivy_helper_search
2827
from bitmessagekivy.baseclass.common import (
29-
avatarImageFirstLetter, toast,
28+
avatarImageFirstLetter, toast, empty_screen_label,
3029
ThemeClsColor, SwipeToDeleteItem
3130
)
3231
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
@@ -42,11 +41,15 @@ class AddressBook(Screen, HelperAddressBook):
4241
has_refreshed = True
4342
address_label = StringProperty()
4443
address = StringProperty()
44+
label_str = "No contact Address found yet......"
45+
no_search_res_found = "No search result found"
4546

4647
def __init__(self, *args, **kwargs):
4748
"""Getting AddressBook Details"""
4849
super(AddressBook, self).__init__(*args, **kwargs)
4950
self.addbook_popup = None
51+
self.kivy_running_app = App.get_running_app()
52+
self.kivy_state = self.kivy_running_app.kivy_state_obj
5053
Clock.schedule_once(self.init_ui, 0)
5154

5255
def init_ui(self, dt=0):
@@ -56,10 +59,10 @@ def init_ui(self, dt=0):
5659

5760
def loadAddresslist(self, account, where="", what=""):
5861
"""Clock Schdule for method AddressBook"""
59-
if state.searching_text:
62+
if self.kivy_state.searching_text:
6063
self.ids.scroll_y.scroll_y = 1.0
6164
where = ['label', 'address']
62-
what = state.searching_text
65+
what = self.kivy_state.searching_text
6366
xAddress = ''
6467
self.ids.tag_label.text = ''
6568
self.queryreturn = kivy_helper_search.search_sql(
@@ -71,7 +74,7 @@ def loadAddresslist(self, account, where="", what=""):
7174
self.set_mdList(0, 20)
7275
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
7376
else:
74-
self.ids.ml.add_widget(self.default_label_when_empty())
77+
self.ids.ml.add_widget(empty_screen_label(self.label_str, self.no_search_res_found))
7578

7679
def set_mdList(self, start_index, end_index):
7780
"""Creating the mdList"""

‎src/bitmessagekivy/baseclass/addressbook_widgets.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,11 @@
66

77
from kivymd.uix.button import MDRaisedButton
88
from kivymd.uix.dialog import MDDialog
9-
from kivymd.uix.label import MDLabel
109

1110
import state
1211

13-
no_address_found = "No contact found yet......"
14-
empty_search_label = "No contact found!"
1512

16-
17-
# pylint: disable=no-init, old-style-class
18-
class DefaultLabelMixin:
19-
"""Common label on blank screen"""
20-
21-
@staticmethod
22-
def default_label_when_empty():
23-
"""This function returns default message while no address is there."""
24-
content = MDLabel(
25-
font_style='Caption',
26-
theme_text_color='Primary',
27-
# FIXME: searching_text supposed to be inside kivy_sate.py, typo and need to create a PR for kivy_state.py
28-
text=empty_search_label if state.searching_text else no_address_found,
29-
halign='center', size_hint_y=None, valign='top')
30-
return content
31-
32-
33-
class HelperAddressBook(DefaultLabelMixin):
13+
class HelperAddressBook(object):
3414
"""Widget used in Addressbook are here"""
3515

3616
@staticmethod

‎src/bitmessagekivy/kivy_state.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# pylint: disable=too-many-instance-attributes, too-few-public-methods
2+
3+
"""
4+
Kivy State variables are assigned here, they are separated from state.py
5+
=================================
6+
"""
7+
8+
9+
class KivyStateVariables(object):
10+
"""This Class hold all the kivy state variables"""
11+
12+
def __init__(self):
13+
self.association = ''
14+
self.navinstance = None
15+
self.mail_id = 0
16+
self.my_address_obj = None
17+
self.detail_page_type = None
18+
self.ackdata = None
19+
self.status = None
20+
self.screen_density = None
21+
self.msg_counter_objs = None
22+
self.check_sent_acc = None
23+
self.sent_count = 0
24+
self.inbox_count = 0
25+
self.trash_count = 0
26+
self.draft_count = 0
27+
self.all_count = 0
28+
self.searching_text = ''
29+
self.search_screen = ''
30+
self.send_draft_mail = None
31+
self.is_allmail = False
32+
self.in_composer = False
33+
self.available_credit = 0
34+
self.in_sent_method = False
35+
self.in_search_mode = False
36+
self.image_dir = None

‎src/bitmessagekivy/mpybit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
from kivy.app import App
77
from kivy.uix.label import Label
88

9+
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
10+
911

1012
class NavigateApp(App):
1113
"""Navigation Layout of class"""
1214

15+
def __init__(self):
16+
super(NavigateApp, self).__init__()
17+
self.kivy_state_obj = KivyStateVariables()
18+
1319
def build(self):
1420
"""Method builds the widget"""
1521
# pylint: disable=no-self-use

‎src/class_objectProcessor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import hashlib
88
import logging
99
import random
10-
import subprocess # nosec
10+
import subprocess # nosec B404
1111
import threading
1212
import time
1313
from binascii import hexlify
@@ -458,7 +458,7 @@ def processmsg(self, data):
458458

459459
for key, cryptorObject in sorted(
460460
shared.myECCryptorObjects.items(),
461-
key=lambda x: random.random()):
461+
key=lambda x: random.random()): # nosec B311
462462
try:
463463
# continue decryption attempts to avoid timing attacks
464464
if initialDecryptionSuccessful:
@@ -680,7 +680,8 @@ def processmsg(self, data):
680680
apiNotifyPath = config.safeGet(
681681
'bitmessagesettings', 'apinotifypath')
682682
if apiNotifyPath:
683-
subprocess.call([apiNotifyPath, "newMessage"])
683+
subprocess.call( # nosec B603
684+
[apiNotifyPath, "newMessage"])
684685

685686
# Let us now check and see whether our receiving address is
686687
# behaving as a mailing list
@@ -776,7 +777,7 @@ def processbroadcast(self, data):
776777
initialDecryptionSuccessful = False
777778
for key, cryptorObject in sorted(
778779
shared.MyECSubscriptionCryptorObjects.items(),
779-
key=lambda x: random.random()):
780+
key=lambda x: random.random()): # nosec B311
780781
try:
781782
# continue decryption attempts to avoid timing attacks
782783
if initialDecryptionSuccessful:
@@ -964,7 +965,7 @@ def processbroadcast(self, data):
964965
apiNotifyPath = config.safeGet(
965966
'bitmessagesettings', 'apinotifypath')
966967
if apiNotifyPath:
967-
subprocess.call([apiNotifyPath, "newBroadcast"])
968+
subprocess.call([apiNotifyPath, "newBroadcast"]) # nosec B603
968969

969970
# Display timing data
970971
logger.info(

‎src/depends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919
import logging # noqa:E402
20-
import subprocess
20+
import subprocess # nosec B404
2121

2222
from importlib import import_module
2323

‎src/helper_sent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ def insert(msgid=None, toAddress='[Broadcast subscribers]', fromAddress=None, su
4646
return ackdata
4747
else:
4848
return None
49+
50+
51+
def delete(ack_data):
52+
"""Perform Delete query"""
53+
sqlExecute("DELETE FROM sent WHERE ackdata = ?", ack_data)

‎src/network/connectionchooser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
# pylint: disable=too-many-branches
55
import logging
6-
import random # nosec
6+
import random
77

88
import knownnodes
99
import protocol
@@ -17,7 +17,7 @@
1717
def getDiscoveredPeer():
1818
"""Get a peer from the local peer discovery list"""
1919
try:
20-
peer = random.choice(state.discoveredPeers.keys())
20+
peer = random.choice(state.discoveredPeers.keys()) # nosec B311
2121
except (IndexError, KeyError):
2222
raise ValueError
2323
try:
@@ -40,11 +40,12 @@ def chooseConnection(stream):
4040
except queue.Empty:
4141
pass
4242
# with a probability of 0.5, connect to a discovered peer
43-
if random.choice((False, True)) and not haveOnion:
43+
if random.choice((False, True)) and not haveOnion: # nosec B311
4444
# discovered peers are already filtered by allowed streams
4545
return getDiscoveredPeer()
4646
for _ in range(50):
47-
peer = random.choice(knownnodes.knownNodes[stream].keys())
47+
peer = random.choice( # nosec B311
48+
knownnodes.knownNodes[stream].keys())
4849
try:
4950
peer_info = knownnodes.knownNodes[stream][peer]
5051
if peer_info.get('self'):
@@ -70,7 +71,7 @@ def chooseConnection(stream):
7071
if rating > 1:
7172
rating = 1
7273
try:
73-
if 0.05 / (1.0 - rating) > random.random():
74+
if 0.05 / (1.0 - rating) > random.random(): # nosec B311
7475
return peer
7576
except ZeroDivisionError:
7677
return peer

‎src/network/dandelion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def pickStem(self, parent=None):
140140
"""
141141
try:
142142
# pick a random from available stems
143-
stem = choice(range(len(self.stem)))
143+
stem = choice(range(len(self.stem))) # nosec B311
144144
if self.stem[stem] == parent:
145145
# one stem available and it's the parent
146146
if len(self.stem) == 1:

‎src/network/knownnodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import json
88
import logging
99
import os
10-
import pickle
10+
import pickle # nosec B403
1111
import threading
1212
import time
1313
try:

‎src/network/tcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def __init__(self, host='127.0.0.1', port=8444):
398398
try:
399399
if attempt > 0:
400400
logger.warning('Failed to bind on port %s', port)
401-
port = random.randint(32767, 65535)
401+
port = random.randint(32767, 65535) # nosec B311
402402
self.bind((host, port))
403403
except socket.error as e:
404404
if e.errno in (asyncore.EADDRINUSE, asyncore.WSAEADDRINUSE):

‎src/plugins/proxyconfig_stem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""
1414
import logging
1515
import os
16-
import random # noseq
16+
import random
1717
import sys
1818
import tempfile
1919

@@ -79,7 +79,7 @@ def connect_plugin(config):
7979
port = config.safeGetInt('bitmessagesettings', 'socksport', 9050)
8080
for attempt in range(50):
8181
if attempt > 0:
82-
port = random.randint(32767, 65535)
82+
port = random.randint(32767, 65535) # nosec B311
8383
tor_config['SocksPort'] = str(port)
8484
if tor_config.get('DataDirectory'):
8585
control_port = port + 1

‎src/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
OBJECT_ADDR = 0x61646472
5757

5858
eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack(
59-
'>Q', random.randrange(1, 18446744073709551615))
59+
'>Q', random.randrange(1, 18446744073709551615)) # nosec B311
6060

6161
# Compiled struct for packing/unpacking headers
6262
# New code should use CreatePacket instead of Header.pack

‎src/upnp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def createPortMapping(self, router):
328328
elif i == 1 and self.extPort:
329329
extPort = self.extPort # try external port from last time next
330330
else:
331-
extPort = randint(32767, 65535)
331+
extPort = randint(32767, 65535) # nosec B311
332332
logger.debug(
333333
"Attempt %i, requesting UPnP mapping for %s:%i on external port %i",
334334
i,

‎tox.ini

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@ skip_missing_interpreters = true
55
[testenv]
66
setenv =
77
BITMESSAGE_HOME = {envtmpdir}
8+
HOME = {envtmpdir}
89
PYTHONWARNINGS = default
910
deps = -rrequirements.txt
1011
commands =
1112
python checkdeps.py
1213
coverage run -a src/bitmessagemain.py -t
1314
coverage run -a -m tests
1415

16+
[testenv:lint-basic]
17+
deps =
18+
bandit
19+
flake8
20+
commands =
21+
bandit -r --exit-zero -s B105,B301,B411,B413,B608 \
22+
-x checkdeps.*,bitmessagecurses,bitmessageqt,tests pybitmessage
23+
flake8 pybitmessage --count --select=E9,F63,F7,F82 \
24+
--show-source --statistics
25+
26+
[testenv:py27]
27+
sitepackages = true
28+
1529
[testenv:py27-doc]
1630
deps =
1731
.[docs]
@@ -35,11 +49,9 @@ commands =
3549
[coverage:run]
3650
source = src
3751
omit =
38-
*/lib*
3952
tests.py
4053
*/tests/*
4154
src/version.py
42-
*/__init__.py
4355
src/fallback/umsgpack/*
4456

4557
[coverage:report]

0 commit comments

Comments
 (0)
Please sign in to comment.