Changed code to resolve or acknowledge some potential security issues. eric7

Wed, 02 Nov 2022 12:07:01 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 02 Nov 2022 12:07:01 +0100
branch
eric7
changeset 9462
e65379fdbd97
parent 9461
24c0c1066090
child 9463
35385d272ea1

Changed code to resolve or acknowledge some potential security issues.

eric7.epj file | annotate | diff | comparison | revisions
src/eric7/CondaInterface/Conda.py file | annotate | diff | comparison | revisions
src/eric7/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
src/eric7/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
src/eric7/DebugClients/Python/DebugVariables.py file | annotate | diff | comparison | revisions
src/eric7/Debugger/VariablesViewer.py file | annotate | diff | comparison | revisions
src/eric7/PipInterface/Pip.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityUtils.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectInterfacesBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectOthersBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectProtocolsBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectResourcesBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectSourcesBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
src/eric7/Testing/TestingWidget.py file | annotate | diff | comparison | revisions
src/eric7/Tools/TRPreviewer.py file | annotate | diff | comparison | revisions
src/eric7/Tools/UIPreviewer.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py file | annotate | diff | comparison | revisions
--- a/eric7.epj	Wed Nov 02 10:12:25 2022 +0100
+++ b/eric7.epj	Wed Nov 02 12:07:01 2022 +0100
@@ -72,7 +72,9 @@
         "ImportsChecker": {
           "ApplicationPackageNames": [],
           "BanRelativeImports": "",
-          "BannedModules": []
+          "BannedModules": [],
+          "SortCaseSensitive": false,
+          "SortOrder": "natural"
         },
         "IncludeMessages": "",
         "LineComplexity": 25,
--- a/src/eric7/CondaInterface/Conda.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/CondaInterface/Conda.py	Wed Nov 02 12:07:01 2022 +0100
@@ -603,7 +603,7 @@
                 Preferences.getSystem("IOEncoding"),
                 "replace",
             ).strip()
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(json.JSONDecodeError):
                 packages = json.loads(output)
                 ok = "error" not in packages
 
--- a/src/eric7/DebugClients/Python/DebugBase.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/DebugClients/Python/DebugBase.py	Wed Nov 02 12:07:01 2022 +0100
@@ -167,7 +167,7 @@
             cf = cf.f_back
             frmnr -= 1
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(ImportError, AttributeError):
             if "__pypy__" in sys.builtin_module_names:
                 import __pypy__
 
--- a/src/eric7/DebugClients/Python/DebugClientBase.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/DebugClients/Python/DebugClientBase.py	Wed Nov 02 12:07:01 2022 +0100
@@ -257,7 +257,7 @@
 
         @param terminate flag indicating to terminate (boolean)
         """
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             self.set_quit()
 
         self.debugging = False
--- a/src/eric7/DebugClients/Python/DebugVariables.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/DebugClients/Python/DebugVariables.py	Wed Nov 02 12:07:01 2022 +0100
@@ -52,7 +52,7 @@
         """
         d = []
         for name in dir(var):
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(AttributeError):
                 attribute = getattr(var, name)
                 d.append((name, attribute))
 
@@ -81,7 +81,7 @@
         """
         d = []
         for name in dir(var):
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(AttributeError):
                 attribute = getattr(var, name)
                 d.append((name, attribute))
 
@@ -661,9 +661,9 @@
         """
         d = []
         attributes = ()
-        # Gently handle exception which could occure as special
-        # cases, e.g. already deleted C++ objects, str conversion..
-        with contextlib.suppress(Exception):
+        # Gently handle exception which could occur as special
+        # cases, e.g. already deleted C++ objects, str conversion...
+        with contextlib.suppress(Exception):  # secok
             qttype = type(var).__name__
 
             if qttype in ("QLabel", "QPushButton"):
--- a/src/eric7/Debugger/VariablesViewer.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Debugger/VariablesViewer.py	Wed Nov 02 12:07:01 2022 +0100
@@ -154,7 +154,7 @@
             return
 
         if VariableItem.rx_nonprintable.search(dvalue) is None:
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(Exception):  # secok
                 dvalue = ast.literal_eval(dvalue)
 
         dvalue = str(dvalue)
--- a/src/eric7/PipInterface/Pip.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/PipInterface/Pip.py	Wed Nov 02 12:07:01 2022 +0100
@@ -806,7 +806,7 @@
                 data = str(
                     reply.readAll(), Preferences.getSystem("IOEncoding"), "replace"
                 )
-                with contextlib.suppress(Exception):
+                with contextlib.suppress(json.JSONDecodeError):
                     result = json.loads(data)
 
         return result
@@ -836,7 +836,7 @@
                 dataStr = str(
                     reply.readAll(), Preferences.getSystem("IOEncoding"), "replace"
                 )
-                with contextlib.suppress(Exception):
+                with contextlib.suppress(json.JSONDecodeError, KeyError):
                     data = json.loads(dataStr)
                     result = list(data["releases"].keys())
 
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityUtils.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityUtils.py	Wed Nov 02 12:07:01 2022 +0100
@@ -156,7 +156,7 @@
     """
     prefix = ""
     if isinstance(node, ast.Attribute):
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(AttributeError):
             val = deepgetattr(node, "value.id")
             prefix = aliases[val] if val in aliases else deepgetattr(node, "value.id")
             # Id we can't get the fully qualified name for an attr, just return
--- a/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Wed Nov 02 12:07:01 2022 +0100
@@ -291,7 +291,7 @@
             error = str(detail)
         return [{"error": (fn, line, 0, "", error)}]
     except Exception as detail:
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(AttributeError):
             fn = detail.filename
             line = detail.lineno
             error = detail.msg
--- a/src/eric7/Project/ProjectFormsBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectFormsBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -396,7 +396,7 @@
         self.__pyuicDirMultiConfigAct.setEnabled(enable)
         self.__pyuicBackConfigAct.setEnabled(enable)
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
             )
@@ -504,7 +504,7 @@
         """
         itmList = self.getSelectedItems()
         for itm in itmList[:]:
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(Exception):  # secok
                 if isinstance(itm, ProjectBrowserFileItem):
                     # hook support
                     if self.hooks["open"] is not None:
--- a/src/eric7/Project/ProjectInterfacesBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectInterfacesBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -292,7 +292,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [
                     ProjectBrowserFileItem,
--- a/src/eric7/Project/ProjectOthersBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectOthersBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -170,7 +170,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             cnt = self.getSelectedItemsCount(
                 [
                     ProjectBrowserFileItem,
--- a/src/eric7/Project/ProjectProtocolsBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectProtocolsBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -298,7 +298,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [
                     ProjectBrowserFileItem,
--- a/src/eric7/Project/ProjectResourcesBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectResourcesBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -354,7 +354,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
             )
--- a/src/eric7/Project/ProjectSourcesBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectSourcesBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -667,7 +667,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [
                     ProjectBrowserFileItem,
--- a/src/eric7/Project/ProjectTranslationsBrowser.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Project/ProjectTranslationsBrowser.py	Wed Nov 02 12:07:01 2022 +0100
@@ -534,7 +534,7 @@
         if not self.project.isOpen():
             return
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(Exception):  # secok
             categories = self.getSelectedItemsCountCategorized(
                 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
             )
--- a/src/eric7/Testing/TestingWidget.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Testing/TestingWidget.py	Wed Nov 02 12:07:01 2022 +0100
@@ -1198,7 +1198,7 @@
         event.accept()
 
         for editor in self.__editors:
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(RuntimeError):
                 editor.close()
 
 
--- a/src/eric7/Tools/TRPreviewer.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Tools/TRPreviewer.py	Wed Nov 02 12:07:01 2022 +0100
@@ -761,7 +761,9 @@
             del self.__widget
             self.__widget = None
 
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(
+            ImportError, NotImplementedError, SyntaxError, TypeError
+        ):
             self.__widget = uic.loadUi(self.__uiFileName)
 
         if not self.__widget:
--- a/src/eric7/Tools/UIPreviewer.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/Tools/UIPreviewer.py	Wed Nov 02 12:07:01 2022 +0100
@@ -366,7 +366,9 @@
             self.mainWidget = None
 
         # load the file
-        with contextlib.suppress(Exception):
+        with contextlib.suppress(
+            ImportError, NotImplementedError, SyntaxError, TypeError
+        ):
             self.mainWidget = uic.loadUi(fn)
 
         if self.mainWidget:
--- a/src/eric7/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py	Wed Nov 02 10:12:25 2022 +0100
+++ b/src/eric7/WebBrowser/SafeBrowsing/SafeBrowsingUrl.py	Wed Nov 02 12:07:01 2022 +0100
@@ -110,10 +110,10 @@
         host = host.strip(".")
         host = re.sub(r"\.+", ".", host).lower()
         if host.isdigit():
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(OSError):
                 host = socket.inet_ntoa(struct.pack("!I", int(host)))
         if host.startswith("0x") and "." not in host:
-            with contextlib.suppress(Exception):
+            with contextlib.suppress(OSError):
                 host = socket.inet_ntoa(struct.pack("!I", int(host, 16)))
         quotedPath = quote(path)
         quotedHost = quote(host)

eric ide

mercurial