forked from securing/DumpsterDiver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFiltering.py
53 lines (36 loc) · 1.01 KB
/
Filtering.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
#!/usr/bin/python
import json
import sys
import re
# Opening JSON file
f = open(sys.argv[1])
# File for Filtering
filteredFiles = set()
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data:
filteredFiles.add(i['File'])
# Closing file
f.close()
# Printing Lines with Quotes
for file in filteredFiles:
with open(file, 'r') as f:
lines = f.readlines()
found = False
for line in lines:
# For matching quotes
regex = re.compile(
r"(:|=)( *)(?P<quote>['\"])(?P<string>.*?)(?<!\\)(?P=quote)")
match = regex.search(line)
if match:
# For not including imports in dart language
regex2 = re.compile(r"import '.+'")
match2 = regex2.search(line)
if not match2:
if not found:
found = True
print("File : ", file)
print("\t", line)