From f98a1d446e4dd988113ca84e4330ce34b2f4c215 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 12 Jun 2022 22:06:57 +0200 Subject: [PATCH 01/10] install.sh: sudo apt-get install python3-pip --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 2d243de..3ef2ae9 100644 --- a/install.sh +++ b/install.sh @@ -45,7 +45,7 @@ if [ $choice == 1 ] || [ $choice == 2 ]; then echo -e ${BLUE}"[✔] Loading ... " if [ $choice == 1 ]; then sudo apt-get update && apt-get upgrade - sudo apt-get install python-pip + sudo apt-get install python3-pip elif [ $choice == 2 ]; then # added arch linux support because of feature request #231 sudo pacman -Suy sudo pacman -S python-pip From 82bf66e17e4c686e11c5d820feda6cd0a838d712 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 12 Jun 2022 23:01:25 +0200 Subject: [PATCH 02/10] GitHub Action to lint Python code --- .../ISSUE_TEMPLATE/workflows/lint_python.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/workflows/lint_python.yml diff --git a/.github/ISSUE_TEMPLATE/workflows/lint_python.yml b/.github/ISSUE_TEMPLATE/workflows/lint_python.yml new file mode 100644 index 0000000..ab837b8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/workflows/lint_python.yml @@ -0,0 +1,24 @@ +name: lint_python +on: [pull_request, push] +jobs: + lint_python: + runs-on: ubuntu-latest + steps: + - 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 + flake8-comprehensions isort mypy pytest pyupgrade safety + - 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 flake8 --ignore=B001,E124,E128,E225,E251,E302,E722,F841,R502,R503,W291,W293 + --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 + - run: mkdir --parents --verbose .mypy_cache + - run: mypy --ignore-missing-imports --install-types --non-interactive . || true + - run: pytest . || true + - run: pytest --doctest-modules . || true + - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true + - run: safety check From 967aa13e14151415f3e290fcd8ce900e1ce3645d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 12 Jun 2022 23:04:42 +0200 Subject: [PATCH 03/10] Rename .github/ISSUE_TEMPLATE/workflows/lint_python.yml to .github/workflows/lint_python.yml --- .github/{ISSUE_TEMPLATE => }/workflows/lint_python.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ISSUE_TEMPLATE => }/workflows/lint_python.yml (100%) diff --git a/.github/ISSUE_TEMPLATE/workflows/lint_python.yml b/.github/workflows/lint_python.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/workflows/lint_python.yml rename to .github/workflows/lint_python.yml From a3c152ed0725027ed80d88f69012e3732649e45c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 12 Jun 2022 23:05:32 +0200 Subject: [PATCH 04/10] 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 ab837b8..d07cee2 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 flake8 --ignore=B001,E124,E128,E225,E251,E302,E722,F841,R502,R503,W291,W293 + - run: flake8 --ignore=B001,E124,E128,E225,E251,E302,E722,F841,R502,R503,W291,W293 --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 b4276e1b9917e31bd7a3d59f4f0a77684e55a56b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 12 Jun 2022 23:06:37 +0200 Subject: [PATCH 05/10] 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 d07cee2..541d898 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 + - run: flake8 --ignore=B001,E124,E128,E225,E251,E302,E722,F841,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 6db6a615edf084d248b7d266fda4321980cd0ca5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 13 Jun 2022 12:56:48 +0200 Subject: [PATCH 06/10] 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 07/10] 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 08/10] 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 09/10] 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 10/10] 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