From be73ce7cb017f4002befa64118ffc79ae3cc6bbd Mon Sep 17 00:00:00 2001 From: Alex Kenion Date: Mon, 28 Aug 2023 14:41:19 -0400 Subject: [PATCH 1/4] Added workflow to validate code styles --- .github/workflows/validate-code-styles.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/validate-code-styles.yml diff --git a/.github/workflows/validate-code-styles.yml b/.github/workflows/validate-code-styles.yml new file mode 100644 index 00000000..7c767142 --- /dev/null +++ b/.github/workflows/validate-code-styles.yml @@ -0,0 +1,9 @@ +name: "Validate Code Styles" +on: [push] +jobs: + flake8: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - run: apt-get install flake8 + - run: flake8 From 74e82c113524bf2d2c0321e192df843e392e51b2 Mon Sep 17 00:00:00 2001 From: Alex Kenion Date: Mon, 28 Aug 2023 14:47:12 -0400 Subject: [PATCH 2/4] Adjusted flake8 install command for code style validation action --- .github/workflows/validate-code-styles.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-code-styles.yml b/.github/workflows/validate-code-styles.yml index 7c767142..e6a97f6c 100644 --- a/.github/workflows/validate-code-styles.yml +++ b/.github/workflows/validate-code-styles.yml @@ -5,5 +5,5 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - - run: apt-get install flake8 + - run: sudo apt-get install -y flake8 - run: flake8 From 6d30d5c32942b45b63696c1929cbd840b5632538 Mon Sep 17 00:00:00 2001 From: Alex Kenion Date: Tue, 29 Aug 2023 10:26:48 -0400 Subject: [PATCH 3/4] Updated flake8 check to include flake8-bugbear plugin --- .github/workflows/validate-code-styles.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-code-styles.yml b/.github/workflows/validate-code-styles.yml index e6a97f6c..60ba8d9e 100644 --- a/.github/workflows/validate-code-styles.yml +++ b/.github/workflows/validate-code-styles.yml @@ -2,8 +2,9 @@ name: "Validate Code Styles" on: [push] jobs: flake8: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - run: sudo apt-get install -y flake8 - - run: flake8 + - run: sudo apt-get install -y flake8 python3-pip + - run: pip3 install flake8-bugbear + - run: flake8 --require-plugins pycodestyle,flake8-bugbear From bca3ed3aaa54042f1bcb6dd5c011a32f7e39c862 Mon Sep 17 00:00:00 2001 From: Alex Kenion Date: Tue, 29 Aug 2023 10:32:09 -0400 Subject: [PATCH 4/4] Fixed remaining PEP-8 conformance issues --- .../cli/scan/config/config_definitions.py | 3 ++- wordfence/logging/Handlers.py | 21 ------------------- 2 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 wordfence/logging/Handlers.py diff --git a/wordfence/cli/scan/config/config_definitions.py b/wordfence/cli/scan/config/config_definitions.py index 1cd54c5c..9ca8d715 100644 --- a/wordfence/cli/scan/config/config_definitions.py +++ b/wordfence/cli/scan/config/config_definitions.py @@ -3,7 +3,8 @@ from ..reporting import ReportFormat, ReportColumn from wordfence.cli.config.defaults import INI_DEFAULT_PATH -from wordfence.util.pcre import PCRE_DEFAULT_MATCH_LIMIT, PCRE_DEFAULT_MATCH_LIMIT_RECURSION +from wordfence.util.pcre import PCRE_DEFAULT_MATCH_LIMIT, \ + PCRE_DEFAULT_MATCH_LIMIT_RECURSION KIBIBYTE = 1024 MEBIBYTE = 1024 * 1024 diff --git a/wordfence/logging/Handlers.py b/wordfence/logging/Handlers.py deleted file mode 100644 index d14c5a03..00000000 --- a/wordfence/logging/Handlers.py +++ /dev/null @@ -1,21 +0,0 @@ -from logging import Handler -import curses - -# based on log handlers in core python logging/__init__.py - - -class CursesHandler(Handler): - - def __init__(self, window, parent): - Handler.__init__(self) - self.window: curses.window = window - self.parent: curses.window = parent - - def emit(self, record): - try: - message = self.format(record) - self.window.addstr(f"{message}\n") - self.window.refresh() - #self.parent.refresh() - except Exception: - self.handleError(record)