|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Package containing the various security checker modules. |
|
8 """ |
|
9 |
|
10 import collections |
|
11 |
|
12 _checkermodules = [ |
|
13 "blackListCalls", |
|
14 "blackListImports", |
|
15 ] |
|
16 |
|
17 |
|
18 def generateCheckersDict(): |
|
19 """ |
|
20 Function generate the dictionary with checkers. |
|
21 |
|
22 @return dictionary containing list of tuples with checker data |
|
23 @rtype dict |
|
24 """ |
|
25 checkersDict = collections.defaultdict(list) |
|
26 |
|
27 for checkerModule in _checkermodules: |
|
28 modName = "Security.Checks.{0}".format(checkerModule) |
|
29 try: |
|
30 mod = __import__(modName) |
|
31 components = modName.split('.') |
|
32 for comp in components[1:]: |
|
33 mod = getattr(mod, comp) |
|
34 except ImportError: |
|
35 continue |
|
36 |
|
37 if not hasattr(mod, "getChecks"): |
|
38 continue |
|
39 |
|
40 modCheckersDict = mod.getChecks() |
|
41 for checktype, check in modCheckersDict.items(): |
|
42 checkersDict[checktype].append(check) |
|
43 |
|
44 return checkersDict |