From 6db6a615edf084d248b7d266fda4321980cd0ca5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 12:56:48 +0200 Subject: [PATCH 1/5] Do not use bare `except:` Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer `except Exception:`. If you're sure what you're doing, be explicit and write `except BaseException:`. --- core.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/core.py b/core.py index e37b50e..06ddc15 100644 --- a/core.py +++ b/core.py @@ -11,21 +11,18 @@ from typing import Tuple def clear_screen(): - if system() == "Linux": - os.system("clear") - if system() == "Windows": - os.system("cls") + os.system("cls" if system() == "Windows" else "clear") def validate_input(ip, val_range): + val_range = val_range or [] try: ip = int(ip) if ip in val_range: return ip - else: - return None - except: - return None + except Exception: + pass + return None class HackingTool(object): @@ -46,8 +43,7 @@ class HackingTool(object): def __init__(self, options = None, installable: bool = True, runnable: bool = True): - if options is None: - options = [] + options = options or [] if isinstance(options, list): self.OPTIONS = [] if installable: @@ -176,7 +172,7 @@ class HackingToolsCollection(object): except (TypeError, ValueError): print("Please enter a valid option") input("\n\nPress ENTER to continue:") - except Exception as e: + except Exception: print_exc() input("\n\nPress ENTER to continue:") return self.show_options(parent = parent) From 20d8dd7e1c8d9f3000b82da864cc75943165df19 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 12:57:55 +0200 Subject: [PATCH 2/5] Add more flake8 tests --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 541d898..4099078 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -12,7 +12,7 @@ jobs: - run: bandit --recursive --skip B404,B603,B605,B607 . - run: black --check . || true - run: codespell --ignore-words-list="WAN" || true # --skip="*.css,*.js,*.lock" - - run: flake8 --ignore=B001,E124,E128,E225,E251,E302,E722,F841,R502,R503,W291,W293,W605 + - run: flake8 --ignore=E124,E128,E225,E251,E302,R502,R503,W291,W293,W605 --max-complexity=11 --max-line-length=265 --show-source --statistics . - run: isort --check-only --profile black . || true - run: pip install -r requirements.txt || pip install --editable . || pip install . || true From 2283ee3d911ff578d788076182f2386c333570a7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 12:59:39 +0200 Subject: [PATCH 3/5] Update core.py --- core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.py b/core.py index 06ddc15..7916305 100644 --- a/core.py +++ b/core.py @@ -43,7 +43,7 @@ class HackingTool(object): def __init__(self, options = None, installable: bool = True, runnable: bool = True): - options = options or [] + options = options or [] if isinstance(options, list): self.OPTIONS = [] if installable: From 161825411e99c556fa67940d2bef74776d3fcdc9 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 13:02:58 +0200 Subject: [PATCH 4/5] Update core.py --- core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.py b/core.py index 7916305..3a82f1c 100644 --- a/core.py +++ b/core.py @@ -21,7 +21,7 @@ def validate_input(ip, val_range): if ip in val_range: return ip except Exception: - pass + return None return None From cf6b20680bc7357aa8b48b8e00a3d8add2db9703 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 13:09:24 +0200 Subject: [PATCH 5/5] Update lint_python.yml --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 4099078..6557c0e 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - run: pip install --upgrade pip wheel - - run: pip install bandit black codespell flake8 flake8-2020 flake8-bugbear + - run: pip install bandit black codespell flake8 flake8-bugbear flake8-return flake8-comprehensions isort mypy pytest pyupgrade safety - run: bandit --recursive --skip B404,B603,B605,B607 . - run: black --check . || true