-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWAP.py
35 lines (31 loc) · 1.32 KB
/
WAP.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
import os
def scan_WAP(Directory_to_wap,project_path,project_name):
output_path = Directory_to_wap + "/output_WAP"
if os.path.isdir(output_path) == False:
os.system(f"mkdir {output_path}")
if os.path.exists(f"{output_path}/{project_name}.txt") == True:
os.system(f"rm {output_path}/{project_name}.txt")
print(f"cd {Directory_to_wap}; echo | timeout 900s ./wap -a -all -out {output_path}/{project_name}.txt -p {project_path}")
os.system(f"cd {Directory_to_wap}; echo | timeout 900s ./wap -a -all -out {output_path}/{project_name}.txt -p {project_path} > temp.txt")
def process_output(Directory_to_wap,project_name):
output_path = Directory_to_wap + "/output_WAP"
lines = open(f"{output_path}/{project_name}.txt","r").read().split("\n")
alerts = set()
file = ""
cond = False
line_num = -1
for line in lines:
line = line.strip()
if "> > > > File: " in line:
file = line.split("> > > > File: ")[1].split(" < < < <")[0]
if "Vulnerable code:" in line:
cond = True
continue
if cond == True:
if line == "":
cond = False
if line_num != -1:
alerts.add((file,int(line_num)))
else:
line_num = line.split(":")[0]
return alerts