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

Mon, 08 Jun 2020 08:17:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 08 Jun 2020 08:17:14 +0200
changeset 7612
ca1ce1e0fcff
child 7613
382f89c11e27
permissions
-rw-r--r--

Code Style Checker: started to implement checker for security related issues.

# -*- 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