-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateProcessReport
executable file
·41 lines (36 loc) · 1.16 KB
/
generateProcessReport
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
#!/usr/bin/python3
import sys
import os
import re
def rawReport(FILE, CMD):
status = os.system(CMD + " 2> " + FILE)
return status
def processReport(raw_file, track_file):
prev_rc_pair = -1
finding = ""
regex = re.compile(r'\d+.\d+')
with open(raw_file) as raw_fh:
for line in raw_fh:
obj = regex.search(line)
if obj != None and obj.group() != prev_rc_pair:
if len(finding) > 0:
print(finding+"\n\n")
prev_rc_pair = obj.group()
finding = line
elif len(finding) > 0:
finding += line
def main():
TOOL = sys.argv[1]
PATH = sys.argv[2]
RAW_FILE = PATH + TOOL + "RawReport"
TRACK_FILE = PATH + TOOL + "TrackFindings"
CMD = input("Enter the command for tool " + TOOL + ": ")
print("[PROCESS] Generating raw report...")
if rawReport(RAW_FILE, CMD) != 0:
print("[ERROR] Not a valid command!\n Exit with status code 1")
exit(1)
print("[COMPLETE] Raw report generated")
print("[PROCESS] Processing report..")
processReport(RAW_FILE, TRACK_FILE)
if __name__ == "__main__" :
main()