-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect_xss.py
28 lines (23 loc) · 848 Bytes
/
detect_xss.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
import sys
import pprint
sys.path.append('spoon-master/test/block')
sys.path.append('dijkstra')
from block_parser import get_sink_blocks, get_source_blocks
from path_finder import find_all_paths
if len(sys.argv) < 2:
sys.exit("Usage: python detect_xss.py path/to/file.cfg")
cfg_file = sys.argv[1]
sources = map(lambda x: int(x.rstrip(' loop')), get_source_blocks(cfg_file))
sinks = map(lambda x: int(x.rstrip(' loop')), get_sink_blocks(cfg_file))
paths = find_all_paths(cfg_file, sources, sinks)
pp = pprint.PrettyPrinter(indent=4)
for source in sources:
for sink in sinks:
if source == sink:
print "Path(s) found in file %s" % cfg_file
pp.pprint((source, sink, {source: sink}))
if len(paths) > 0:
print sources
print sinks
print "Path(s) found in file %s" % (cfg_file)
pp.pprint(paths)