bandit: pyproject.toml, directives, remove eval()
This commit is contained in:
parent
5c4e20cbda
commit
c203cc868c
5 changed files with 16 additions and 8 deletions
|
|
@ -62,14 +62,12 @@ class RangeParser:
|
|||
return (None, None)
|
||||
|
||||
def parse_add(self):
|
||||
m = re.match(r'\+([0-9*]+)(.*)', self.arg)
|
||||
m = re.match(r'\+([0-9]+)(.*)', self.arg)
|
||||
if m:
|
||||
res, self.arg = (m[1], m[2])
|
||||
if res.strip('*') != res:
|
||||
die(1, f"'+{res}': malformed nBlocks specifier")
|
||||
if len(res) > 30:
|
||||
die(1, f"'+{res}': overly long nBlocks specifier")
|
||||
return self.caller.check_nblocks(eval(res)) # res is only digits plus '*', so eval safe
|
||||
return self.caller.check_nblocks(int(res))
|
||||
|
||||
class BlocksInfo:
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from mmgen.util import die
|
|||
|
||||
from mmgen_node_tools.Util import do_system
|
||||
|
||||
_alsa_config_file = '/tmp/alsa-config-' + os.path.basename(sys.argv[0])
|
||||
_alsa_config_file = f'/tmp/alsa-config-{os.path.basename(sys.argv[0])}' # nosec B108 # unused code
|
||||
_dvols = {'Master': 78, 'Speaker': 78, 'Headphone': 15, 'PCM': 190}
|
||||
|
||||
def timespec2secs(ts):
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ class DataSource:
|
|||
|
||||
@classmethod
|
||||
def get_sources(cls, randomize=False):
|
||||
g = random.sample(cls.source_groups, k=len(cls.source_groups)) if randomize else cls.source_groups
|
||||
g = (
|
||||
random.sample(cls.source_groups, k=len(cls.source_groups)) # nosec B311 # non-cryptographic use
|
||||
if randomize else cls.source_groups)
|
||||
return {k: v for a in g for k, v in a.items()}
|
||||
|
||||
class base:
|
||||
|
|
@ -73,7 +75,7 @@ class DataSource:
|
|||
def fetch_delay(self):
|
||||
global last_api_host
|
||||
if not gcfg.testing and last_api_host and last_api_host != self.api_host:
|
||||
delay = 1 + random.randrange(1, 5000) / 1000
|
||||
delay = 1 + random.randrange(1, 5000) / 1000 # nosec B311 # non-cryptographic use
|
||||
msg_r(f'Waiting {delay:.3f} seconds...')
|
||||
time.sleep(delay)
|
||||
msg('')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@ requires = [
|
|||
]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.bandit]
|
||||
exclude_dirs = ["test/overlay/tree"]
|
||||
skips = [
|
||||
# severity level low:
|
||||
"B101", # assert_used
|
||||
"B404", # import_subprocess (blacklist)
|
||||
"B603", # subprocess - check for execution of untrusted input
|
||||
]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 106
|
||||
indent-width = 4
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ range_vecs = (
|
|||
(f'{tip-1}-cur', (tip-1, tip, None, None, None), (tip-1, tip, None) ),
|
||||
( '0-cur+3000', (0, tip, None, None, 3000 ), (0, tip, list(range(0,tip+1,3000))) ),
|
||||
( '+1440+144', (tip-1439, tip, None, 1440, 144 ), (tip-1439, tip, list(range(tip-1439,tip+1,144))) ),
|
||||
( '+144*10+12*12', (tip-1439, tip, None, 1440, 144 ), (tip-1439, tip, list(range(tip-1439,tip+1,144))) ),
|
||||
)
|
||||
|
||||
full_set = ['aa','bbb','ccc_P2','ddddd','eeeeee','ffffffff','gg']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue