bandit fixes and cleanups
This commit is contained in:
parent
979f034448
commit
158c591913
14 changed files with 36 additions and 24 deletions
|
|
@ -81,7 +81,7 @@ class Autosign:
|
|||
match gc.platform:
|
||||
case 'linux':
|
||||
self.dfl_mountpoint = f'/mnt/{self.linux_mount_subdir}'
|
||||
self.dfl_shm_dir = '/dev/shm'
|
||||
self.dfl_shm_dir = '/dev/shm' # nosec B108 # (used on offline device only)
|
||||
|
||||
# linux-only attrs:
|
||||
self.old_dfl_mountpoint = '/mnt/tx'
|
||||
|
|
@ -420,7 +420,7 @@ class Autosign:
|
|||
'_clone': self.cfg,
|
||||
'coin': 'xmr',
|
||||
'wallet_rpc_user': 'autosign',
|
||||
'wallet_rpc_password': 'autosign password',
|
||||
'wallet_rpc_password': 'autosign password', # nosec # B105 (offline device use only)
|
||||
'wallet_rpc_port': 23232 if self.cfg.test_suite_xmr_autosign else None,
|
||||
'wallet_dir': str(self.wallet_dir),
|
||||
'autosign': True,
|
||||
|
|
|
|||
|
|
@ -158,9 +158,9 @@ class Config(Lockable):
|
|||
|
||||
# general
|
||||
coin = 'BTC'
|
||||
token = ''
|
||||
token = '' # nosec B105
|
||||
outdir = ''
|
||||
passwd_file = ''
|
||||
passwd_file = '' # nosec B105
|
||||
network = 'mainnet'
|
||||
testnet = False
|
||||
regtest = False
|
||||
|
|
@ -201,7 +201,7 @@ class Config(Lockable):
|
|||
rpc_host = ''
|
||||
rpc_port = 0
|
||||
rpc_user = ''
|
||||
rpc_password = ''
|
||||
rpc_password = '' # nosec B105 # empty pw rejected, user must set, see BitcoinRPCClient
|
||||
aiohttp_rpc_queue_len = 16
|
||||
aiohttp_session = None
|
||||
cached_balances = False
|
||||
|
|
@ -243,7 +243,7 @@ class Config(Lockable):
|
|||
|
||||
# Monero:
|
||||
monero_wallet_rpc_user = 'monero'
|
||||
monero_wallet_rpc_password = ''
|
||||
monero_wallet_rpc_password = '' # nosec B105 # empty pw rejected, user must set, see MoneroWalletDaemon
|
||||
monero_daemon = ''
|
||||
xmrwallet_compat = False
|
||||
priority = 0
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def set_vt100():
|
|||
'hack to put term into VT100 mode under MSWin'
|
||||
if gc.platform == 'win32':
|
||||
from subprocess import run
|
||||
run([], shell=True) # nosec
|
||||
run([], shell=True) # nosec B602
|
||||
|
||||
def get_terminfo_colors(term=None):
|
||||
from subprocess import run, PIPE
|
||||
|
|
@ -106,13 +106,13 @@ def init_color(num_colors='auto'):
|
|||
start = (
|
||||
'\033[38;5;{};1m'.format(e[0]) if type(e[0]) == int else
|
||||
'\033[38;5;{};48;5;{};1m'.format(*e[0]))
|
||||
getattr(self, c).__code__ = eval(f'(lambda s: "{start}" + s + "{reset}").__code__') # nosec
|
||||
getattr(self, c).__code__ = eval(f'(lambda s: "{start}" + s + "{reset}").__code__') # nosec B307
|
||||
case 8 | 16:
|
||||
for c, e in _colors.items():
|
||||
start = (
|
||||
'\033[{}m'.format(e[1][0]) if e[1][1] == 0 else
|
||||
'\033[{};{}m'.format(*e[1]))
|
||||
getattr(self, c).__code__ = eval(f'(lambda s: "{start}" + s + "{reset}").__code__') # nosec
|
||||
getattr(self, c).__code__ = eval(f'(lambda s: "{start}" + s + "{reset}").__code__') # nosec B307
|
||||
|
||||
set_vt100()
|
||||
|
||||
|
|
|
|||
|
|
@ -81,11 +81,7 @@ class LEDControl:
|
|||
name = 'Nano Pi M6 (Armbian)',
|
||||
control = '/sys/class/leds/user_led/brightness',
|
||||
trigger = '/sys/class/leds/user_led/trigger',
|
||||
color = 'green'),
|
||||
'dummy': binfo(
|
||||
name = 'Fake Board',
|
||||
control = '/tmp/led_status',
|
||||
trigger = '/tmp/led_trigger')}
|
||||
color = 'green')}
|
||||
|
||||
def __init__(self, *, enabled, simulate=False, debug=False):
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ if cmd in ('enable_swap', 'disable_swap', 'list_led', 'test_led'):
|
|||
if cmd == 'list_led':
|
||||
msg(
|
||||
'Boards with tested LED signaling support:\n' +
|
||||
'\n'.join(f' {v.name}' for k, v in LEDControl.boards.items() if k != 'dummy'))
|
||||
'\n'.join(f' {v.name}' for k, v in LEDControl.boards.items()))
|
||||
else:
|
||||
from .exception import NoLEDSupport
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ b32a = re.sub(r'\s', '', b32_matrix)
|
|||
cashaddr_addr_types = {
|
||||
'p2pkh': 0,
|
||||
'p2sh': 1,
|
||||
'token_pubkey': 2,
|
||||
'token_script': 3,
|
||||
'token_pubkey': 2, # nosec # B105
|
||||
'token_script': 3, # nosec # B105
|
||||
'unknown': 15,
|
||||
}
|
||||
addr_types_rev = {v: k for k, v in cashaddr_addr_types.items()}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def create_data_dir(cfg, data_dir):
|
|||
class MMGenRegtest(MMGenObject):
|
||||
|
||||
rpc_user = 'bobandalice'
|
||||
rpc_password = 'hodltothemoon'
|
||||
rpc_password = 'hodltothemoon' # nosec B105
|
||||
users = ('bob', 'alice', 'carol', 'miner')
|
||||
coins = ('btc', 'bch', 'ltc')
|
||||
usr_cmds = (
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ class BitcoinTwTxHistory(BitcoinTwView, TwTxHistory, BitcoinTwRPC):
|
|||
def do_json_dump(*data):
|
||||
nw = f'{self.proto.coin.lower()}-{self.proto.network}'
|
||||
for d, fn_stem in data:
|
||||
with open(f'/tmp/{fn_stem}-{nw}.json', 'w') as fh:
|
||||
with open(f'debug-{fn_stem}-{nw}.json', 'w') as fh:
|
||||
fh.write(json.dumps(d, cls=json_encoder))
|
||||
|
||||
_mmp = namedtuple('mmap_datum', ['twmmid', 'comment'])
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class CoinProtocol(MMGenObject):
|
|||
rpc_host = ''
|
||||
rpc_port = 0
|
||||
rpc_user = ''
|
||||
rpc_password = ''
|
||||
rpc_password = '' # nosec B105 # empty pw rejected, user must set, see BitcoinRPCClient
|
||||
tw_name = ''
|
||||
daemon_id = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Base(MMGenObject):
|
|||
'swap_recv_addr_mmid': None,
|
||||
'swap_recv_asset_spec': None,
|
||||
'swap_memo': None,
|
||||
'token_vault_addr': None,
|
||||
'token_vault_addr': None, # nosec # B105
|
||||
'serialized2': None,
|
||||
'coin_txid2': CoinTxID}
|
||||
file_format = 'json'
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def get_keccak(cfg=None, cached_ret=[]):
|
|||
from .contrib.keccak import keccak_256
|
||||
elif not (keccak_256 := get_hashlib_keccak()):
|
||||
load_cryptodome()
|
||||
from Crypto.Hash import keccak # nosec # pylint: disable=import-error
|
||||
from Crypto.Hash import keccak # nosec B413 # pylint: disable=import-error
|
||||
keccak_256 = lambda data: keccak.new(data=data, digest_bytes=32)
|
||||
cached_ret.append(keccak_256)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,14 @@ requires = [
|
|||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.bandit]
|
||||
exclude_dirs = ["test/overlay/tree"]
|
||||
skips = [
|
||||
"B108", # hardcoded_tmp_directory: probable insecure usage of temp file/directory
|
||||
# severity level low:
|
||||
"B101", # assert_used
|
||||
"B404", # import_subprocess (blacklist)
|
||||
"B603", # subprocess - check for execution of untrusted input
|
||||
"B607", # subprocess - starting a process with a partial executable path
|
||||
"B110", # try_except_pass: Try, Except, Pass detected
|
||||
]
|
||||
|
||||
[tool.ruff]
|
||||
|
|
|
|||
10
test/overlay/fakemods/mmgen/led.py
Normal file
10
test/overlay/fakemods/mmgen/led.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from .led_orig import *
|
||||
|
||||
class overlay_fake_LEDControl:
|
||||
boards = {
|
||||
'dummy': LEDControl.binfo(
|
||||
name = 'Dummy Testing Board',
|
||||
control = 'test/tmp/led_status',
|
||||
trigger = 'test/tmp/led_trigger')}
|
||||
|
||||
LEDControl.boards.update(overlay_fake_LEDControl.boards)
|
||||
|
|
@ -279,7 +279,7 @@ altcoin_mod_opts='--quiet'
|
|||
mmgen_tool='cmds/mmgen-tool'
|
||||
pylint='pylint'
|
||||
ruff='ruff --silent'
|
||||
bandit='bandit --silent --recursive --severity-level=medium --configfile=pyproject.toml'
|
||||
bandit='bandit --silent --recursive --severity-level=all --configfile=pyproject.toml'
|
||||
python='python3'
|
||||
rounds=10
|
||||
typescript_file='test-release.out'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue