66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
#!/usr/bin/env python
|
|
|
|
from argparse import ArgumentParser
|
|
from core.sysctl import Sysctl
|
|
from core.postfix import Postfix
|
|
from core.report import generateHtmlReport
|
|
from core.config import AUDIT_SYSTEM, AUDIT_APPLICATION, generateConfig, parsingConfigFile
|
|
from core.dispatcher import Dispatcher
|
|
|
|
|
|
def checkArguments():
|
|
args = ArgumentParser(description="Check Gitlab repositories")
|
|
args.add_argument('-a', '--audit', help="Kind of audit", choices=['system', 'application'])
|
|
args.add_argument('-c', '--config', help="Config file")
|
|
return args.parse_args()
|
|
|
|
|
|
def main():
|
|
args = checkArguments()
|
|
|
|
# If audit is not specified
|
|
if args.audit is None:
|
|
print("Please, you must specify the audit type")
|
|
exit(1)
|
|
|
|
# If config file is specified
|
|
configs = generateConfig()
|
|
if args.config is not None:
|
|
parsingConfigFile(args.config, configs)
|
|
|
|
# Report
|
|
report = dict()
|
|
report['system'] = dict()
|
|
|
|
# Create our dispatcher
|
|
dispatcher = Dispatcher()
|
|
|
|
print(configs)
|
|
|
|
if args.audit == "system":
|
|
for audit in AUDIT_SYSTEM:
|
|
if audit not in configs["system"]["exclude_plugins"]:
|
|
report["system"][audit] = dispatcher.runPlugin(audit, configs["system"][audit])
|
|
|
|
if args.audit == "application":
|
|
pass
|
|
|
|
print(report)
|
|
generateHtmlReport(report)
|
|
|
|
@Dispatcher.register_plugins
|
|
def sysctl(*args) -> dict:
|
|
sysctl = Sysctl(args[1])
|
|
sysctl.runAudit()
|
|
return sysctl.getReports()
|
|
|
|
@Dispatcher.register_plugins
|
|
def postfix(*args) -> dict:
|
|
arguments = args[1]
|
|
postfix = Postfix()
|
|
postfix.runAudit()
|
|
return postfix.getReports()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|