From f23199c4a39aeb49c2c5ee76919b8a3f5c2e288a Mon Sep 17 00:00:00 2001
From: Shay Nehmad <shay.nehmad@guardicore.com>
Date: Mon, 31 Aug 2020 14:40:03 +0300
Subject: [PATCH] Fixed more warnings and lowered the linter upper limit to
 double digits

---
 .travis.yml                                          |  2 +-
 .../post_breach/actions/communicate_as_new_user.py   |  2 +-
 .../system_info/windows_info_collector.py            | 12 ++++--------
 .../infection_monkey/utils/windows/hidden_files.py   |  2 +-
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 59a97f60c..8586aaf38 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -72,7 +72,7 @@ script:
 ## Display the linter issues
 - cat flake8_warnings.txt
 ## Make sure that we haven't increased the amount of warnings.
-- PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT=120
+- PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT=90
 - if [ $(tail -n 1 flake8_warnings.txt) -gt $PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT ]; then echo "Too many python linter warnings! Failing this build. Lower the amount of linter errors in this and try again. " && exit 1; fi
 
 ## Check import order
diff --git a/monkey/infection_monkey/post_breach/actions/communicate_as_new_user.py b/monkey/infection_monkey/post_breach/actions/communicate_as_new_user.py
index 83065d20d..ce85c74c1 100644
--- a/monkey/infection_monkey/post_breach/actions/communicate_as_new_user.py
+++ b/monkey/infection_monkey/post_breach/actions/communicate_as_new_user.py
@@ -44,7 +44,7 @@ class CommunicateAsNewUser(PBA):
 
     @staticmethod
     def get_random_new_user_name():
-        return USERNAME_PREFIX + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))
+        return USERNAME_PREFIX + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))  # noqa: DUO102
 
     @staticmethod
     def get_commandline_for_http_request(url, is_windows=is_windows_os()):
diff --git a/monkey/infection_monkey/system_info/windows_info_collector.py b/monkey/infection_monkey/system_info/windows_info_collector.py
index d6b3cbec8..3e7b2bfff 100644
--- a/monkey/infection_monkey/system_info/windows_info_collector.py
+++ b/monkey/infection_monkey/system_info/windows_info_collector.py
@@ -7,14 +7,10 @@ from infection_monkey.system_info.windows_cred_collector.mimikatz_cred_collector
     MimikatzCredentialCollector
 
 sys.coinit_flags = 0  # needed for proper destruction of the wmi python module
-# noinspection PyPep8
-import infection_monkey.config
-# noinspection PyPep8
-from common.utils.wmi_utils import WMIUtils
-# noinspection PyPep8
-from infection_monkey.system_info import InfoCollector
-# noinspection PyPep8
-from infection_monkey.system_info.wmi_consts import WMI_CLASSES
+import infection_monkey.config  # noqa: E402
+from common.utils.wmi_utils import WMIUtils  # noqa: E402
+from infection_monkey.system_info import InfoCollector  # noqa: E402
+from infection_monkey.system_info.wmi_consts import WMI_CLASSES  # noqa: E402
 
 LOG = logging.getLogger(__name__)
 LOG.info('started windows info collector')
diff --git a/monkey/infection_monkey/utils/windows/hidden_files.py b/monkey/infection_monkey/utils/windows/hidden_files.py
index a8f813f1b..6199fa88d 100644
--- a/monkey/infection_monkey/utils/windows/hidden_files.py
+++ b/monkey/infection_monkey/utils/windows/hidden_files.py
@@ -51,7 +51,7 @@ def get_winAPI_to_hide_files():
         fileCreation = win32file.CREATE_ALWAYS  # overwrite existing file
         fileFlags = win32file.FILE_ATTRIBUTE_HIDDEN  # make hidden
 
-        hiddenFile = win32file.CreateFile(HIDDEN_FILE_WINAPI,
+        _ = win32file.CreateFile(HIDDEN_FILE_WINAPI,
                                           fileAccess,
                                           0,  # sharing mode: 0 => can't be shared
                                           None,  # security attributes