forked from deep-security/amazon-inspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ds-analyze-findings.py
executable file
·65 lines (55 loc) · 1.59 KB
/
ds-analyze-findings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/env python
# Standard libraries
import argparse
import os
import urllib2
import sys
# 3rd party libraries
import boto3
import boto3.session
# project libraries
import lib.core
import lib.analyze
import lib.coverage
def parse_args(str_to_parse=None):
"""
Parse the command line args
"""
cmd = ""
if len(sys.argv) > 1:
cmd = sys.argv[1]
return cmd
class Script(lib.core.ScriptContext):
def __init__(self, command_to_run):
self.command_to_run = command_to_run
self.available_commands = {
'analyze':
{
'help': 'Analyze a set of Amazon Inspector findings',
'cmd': lib.analyze.run_script,
},
'coverage':
{
'help': 'Determine the coverage Deep Security has for Amazon Inspector findings',
'cmd': lib.coverage.run_script,
},
}
if not self.command_to_run in self.available_commands.keys():
self.print_help()
else:
# run a specific command
self.available_commands[self.command_to_run]['cmd'](sys.argv[1:])
def print_help(self):
"""
Print the command line syntax available to the user
"""
self.update_user("usage: ds-analyze-findings [COMMAND]\n For more help on a specific command, type ds-analyze-findings [COMMAND] --help\n\n Available commands:\n")
for cmd, data in self.available_commands.items():
self.update_user(" {}\n > {}".format(cmd, data['help']))
self.update_user("")
def main():
"""
Run the script from the command line
"""
context = Script(parse_args())
if __name__ == '__main__': main()