eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py

changeset 7612
ca1ce1e0fcff
child 7613
382f89c11e27
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py	Mon Jun 08 08:17:14 2020 +0200
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Package containing the various security checker modules.
+"""
+
+import collections
+
+_checkermodules = [
+    "blackListCalls",
+    "blackListImports",
+]
+
+
+def generateCheckersDict():
+    """
+    Function generate the dictionary with checkers.
+    
+    @return dictionary containing list of tuples with checker data
+    @rtype dict
+    """
+    checkersDict = collections.defaultdict(list)
+    
+    for checkerModule in _checkermodules:
+        modName = "Security.Checks.{0}".format(checkerModule)
+        try:
+            mod = __import__(modName)
+            components = modName.split('.')
+            for comp in components[1:]:
+                mod = getattr(mod, comp)
+        except ImportError:
+            continue
+        
+        if not hasattr(mod, "getChecks"):
+            continue
+        
+        modCheckersDict = mod.getChecks()
+        for checktype, check in modCheckersDict.items():
+            checkersDict[checktype].append(check)
+    
+    return checkersDict

eric ide

mercurial