-
Notifications
You must be signed in to change notification settings - Fork 4
/
reset_data.py
63 lines (57 loc) · 1.8 KB
/
reset_data.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
import pymysql
import configparser
import logging as log
import json
import datetime
import os
import logging
import database as db
config = configparser.ConfigParser()
config.read('config.ini')
appsentinel = config['GENERAL']['appsentinel']
locations = [
#config['DOWNLOAD']['apkDownloadDir'],
#config['DOWNLOAD']['jsonDir'],
config['DROIDSTATX']['dstatx_out_txt'],
config['DROIDSTATX']['dstatx_out_xmind'],
config['OWASP_OUTPUT']['feedbackResultsLocation'],
config['OWASP_OUTPUT']['feedback_levelsResultsLocation'],
config['OWASP_OUTPUT']['feedback_vuln_levelsResultsLocation'],
config['SCANNER']['json_results_androbugs'],
config['SCANNER']['json_results_droidstatx'],
config['DROIDSTATX']['dstatx_out_apktool'],
config['SCANNER']['json_results_super']
]
# First delete files in file system
print(os.system("pwd"))
for location in locations:
try:
if location:
print('Location: ' + location + ' ' + str(len(location)))
if len(location) > 0:
os.chdir(location)
if location == config['DROIDSTATX']['dstatx_out_apktool']:
os.system("rm -R -- */")
else:
os.system("rm *")
os.system("rm .*")
print("Deleted files in: " + location)
print("... \n")
os.chdir(appsentinel)
else:
print('Directory is alredy empty \n')
except:
print('ERROR ON DIRECTORY -> ' + location)
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
# Delete all entries in all tables
tables = [
'apk',
'apk2scan',
'apkfinalresults',
'apklevels',
'apkresults',
'apkrules',
'apkscantools',
'apkvulnerabilitylevel'
]
db.reset_database(tables)