Skip to content

Commit

Permalink
cleaned up bandit related stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
fametrano committed Jan 5, 2023
1 parent 3e1cf42 commit 6bc79f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -97,8 +97,8 @@ repos:
hooks:
- id: bandit
name: bandit (tests)
# disable B101 (Test for use of assert) on tests folder
args: ["-s", "B101"]
# disable B101 (Test for use of assert) for the tests folder
args: ["--skip", "B101"]
exclude: btclib
- repo: https://github.com/pycqa/pylint
rev: v2.15.9
Expand Down
14 changes: 6 additions & 8 deletions btclib/script/sig_hash.py
Expand Up @@ -60,12 +60,11 @@ def assert_valid_hash_type(hash_type: int) -> None:
def legacy_script(script_pub_key: Octets) -> list[bytes]:
script_s: list[bytes] = []
current_script: list[Command] = []
for token in parse(script_pub_key)[::-1]:
# B105 required for py<38
if token == "OP_CODESEPARATOR": # nosec B105
for cmd in parse(script_pub_key)[::-1]:
if cmd == "OP_CODESEPARATOR":
script_s.append(serialize(current_script[::-1]))
else:
current_script.append(token)
current_script.append(cmd)
script_s.append(serialize(current_script[::-1]))
return script_s[::-1]

Expand All @@ -82,11 +81,10 @@ def witness_v0_script(script_pub_key: Octets) -> list[bytes]:

script_s: list[bytes] = []
current_script: list[Command] = []
for token in parse(script_pub_key)[::-1]:
# B105 required for py<38
if token == "OP_CODESEPARATOR": # nosec B105
for cmd in parse(script_pub_key)[::-1]:
if cmd == "OP_CODESEPARATOR":
script_s.append(serialize(current_script[::-1]))
current_script.append(token)
current_script.append(cmd)
script_s.append(serialize(current_script[::-1]))
return script_s[::-1]

Expand Down
2 changes: 1 addition & 1 deletion tests/ec/test_curve.py
Expand Up @@ -193,7 +193,7 @@ def test_ec_repr() -> None:
ec_repr = repr(ec)
if ec in low_card_curves.values() or ec.p_size < 24:
ec_repr = f"{ec_repr[:-1]}, False)"
ec2 = eval(ec_repr) # pylint: disable=eval-used # nosec B307
ec2 = eval(ec_repr) # pylint: disable=eval-used # nosec eval
assert str(ec) == str(ec2)


Expand Down

0 comments on commit 6bc79f2

Please sign in to comment.