Rename scripts + Stats page
This commit is contained in:
@@ -230,11 +230,8 @@ p.trckr { font-size: 0.9em; margin-left: 0.5em; }
|
|||||||
width: 40%;
|
width: 40%;
|
||||||
margin-left: 1%;
|
margin-left: 1%;
|
||||||
}
|
}
|
||||||
#dom-top10 {
|
#dom-top10 { text-align: right; }
|
||||||
margin: 0 auto;
|
#dom-top10 p { margin: 0.4em; }
|
||||||
width: max-content;
|
.div-center { margin: 0 auto; width: max-content; max-width: 100%; }
|
||||||
max-width: 100%;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
.loadbar { display: inline-block; }
|
.loadbar { display: inline-block; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ Given A → B, B depends on A
|
|||||||
digraph G {
|
digraph G {
|
||||||
"." -> html_root
|
"." -> html_root
|
||||||
"." -> bundle_download
|
"." -> bundle_download
|
||||||
bundle_download -> index_bundle_names
|
bundle_download -> index_app_names
|
||||||
index_bundle_names -> html_bundle
|
index_app_names -> html_bundle
|
||||||
index_bundle_names -> html_index
|
index_app_names -> html_index_apps
|
||||||
index_bundle_names -> html_reverse_domains
|
index_app_names -> html_index_domains
|
||||||
"." -> bundle_combine
|
"." -> bundle_combine
|
||||||
bundle_combine -> index_reverse_domains
|
bundle_combine -> index_domains
|
||||||
index_reverse_domains -> html_reverse_domains
|
index_domains -> html_index_domains
|
||||||
bundle_combine -> html_bundle
|
bundle_combine -> html_bundle
|
||||||
"." -> tracker_download
|
"." -> tracker_download
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import common_lib as mylib
|
import common_lib as mylib
|
||||||
import index_bundle_names
|
import index_app_names
|
||||||
|
|
||||||
|
|
||||||
def seconds_to_time(seconds):
|
def seconds_to_time(seconds):
|
||||||
@@ -81,7 +81,7 @@ def gen_dom_tags(sorted_arr, isSub, onlyTrackers=False):
|
|||||||
|
|
||||||
|
|
||||||
def gen_html(bundle_id, obj):
|
def gen_html(bundle_id, obj):
|
||||||
name = index_bundle_names.get_name(bundle_id)
|
name = index_app_names.get_name(bundle_id)
|
||||||
obj['tracker'] = list(filter(lambda x: x[2], obj['subdom']))
|
obj['tracker'] = list(filter(lambda x: x[2], obj['subdom']))
|
||||||
return mylib.template_with_base(f'''
|
return mylib.template_with_base(f'''
|
||||||
<h2 class="title">{name}</h2>
|
<h2 class="title">{name}</h2>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import common_lib as mylib
|
import common_lib as mylib
|
||||||
import index_bundle_names
|
import index_app_names
|
||||||
|
|
||||||
|
|
||||||
def gen_obj(bundle_id):
|
def gen_obj(bundle_id):
|
||||||
@@ -11,7 +11,7 @@ def gen_obj(bundle_id):
|
|||||||
icon = '/static/app-template.svg'
|
icon = '/static/app-template.svg'
|
||||||
return {
|
return {
|
||||||
'id': bundle_id,
|
'id': bundle_id,
|
||||||
'name': index_bundle_names.get_name(bundle_id),
|
'name': index_app_names.get_name(bundle_id),
|
||||||
'img': icon
|
'img': icon
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import common_lib as mylib
|
import common_lib as mylib
|
||||||
import index_bundle_names
|
import index_app_names
|
||||||
import index_reverse_domains
|
import index_domains
|
||||||
|
|
||||||
|
|
||||||
def a_app(bundle_id):
|
def a_app(bundle_id):
|
||||||
return '<a href="/app/{}/">{}</a>'.format(
|
return '<a href="/app/{}/">{}</a>'.format(
|
||||||
bundle_id, index_bundle_names.get_name(bundle_id))
|
bundle_id, index_app_names.get_name(bundle_id))
|
||||||
|
|
||||||
|
|
||||||
def a_dom(domain, key):
|
def a_dom(domain, key):
|
||||||
@@ -61,13 +61,15 @@ def gen_html_top_10(subset, fname, total, title):
|
|||||||
|
|
||||||
with open(fname, 'w') as fp:
|
with open(fname, 'w') as fp:
|
||||||
txt = f'''
|
txt = f'''
|
||||||
<div id="dom-top10" class="found-in">
|
<div class="div-center">
|
||||||
<h2>{ title }</h2>'''
|
<h2 class="center">{ title }</h2>
|
||||||
|
<div id="dom-top10" class="found-in">'''
|
||||||
for dom, ids in subset:
|
for dom, ids in subset:
|
||||||
dom_str = div_dom(dom, len(ids), 'domain')
|
dom_str = div_dom(dom, len(ids), 'domain')
|
||||||
pct_bar = div_loadbar(round(len(ids) / total * 100))
|
pct_bar = div_loadbar(round(len(ids) / total * 100))
|
||||||
txt += f'\n<p>{dom_str} {pct_bar}</p>'
|
txt += f'\n<p>{dom_str} {pct_bar}</p>'
|
||||||
fp.write(mylib.template_with_base(txt + '''
|
fp.write(mylib.template_with_base(txt + '''
|
||||||
|
</div>
|
||||||
<p class="mg_top">Get full list
|
<p class="mg_top">Get full list
|
||||||
sorted by <a class="snd" href="by_count.html">Occurrence frequency</a>
|
sorted by <a class="snd" href="by_count.html">Occurrence frequency</a>
|
||||||
or in <a class="snd" href="by_name.html">Alphabetical order</a>.</p>
|
or in <a class="snd" href="by_name.html">Alphabetical order</a>.</p>
|
||||||
@@ -96,7 +98,7 @@ def gen_html_trinity(json, idx_dir, app_count, title):
|
|||||||
|
|
||||||
def gen_html_lookup(html_dir, json, key, title):
|
def gen_html_lookup(html_dir, json, key, title):
|
||||||
mylib.mkdir(html_dir)
|
mylib.mkdir(html_dir)
|
||||||
names = [[x, index_bundle_names.get_name(x)] for x in json['bundle']]
|
names = [[x, index_app_names.get_name(x)] for x in json['bundle']]
|
||||||
mylib.json_write(mylib.path_add(html_dir, 'apps.json'), names)
|
mylib.json_write(mylib.path_add(html_dir, 'apps.json'), names)
|
||||||
mylib.json_write(mylib.path_add(html_dir, 'doms.json'), json[key])
|
mylib.json_write(mylib.path_add(html_dir, 'doms.json'), json[key])
|
||||||
with open(mylib.path_add(html_dir, 'index.html'), 'w') as fp:
|
with open(mylib.path_add(html_dir, 'index.html'), 'w') as fp:
|
||||||
@@ -112,37 +114,58 @@ def gen_html_lookup(html_dir, json, key, title):
|
|||||||
''', title=title))
|
''', title=title))
|
||||||
|
|
||||||
|
|
||||||
|
def gen_html_stats(c_apps, c_domains):
|
||||||
|
title = 'Statistics'
|
||||||
|
mylib.mkdir(mylib.path_out('stats'))
|
||||||
|
with open(mylib.path_out('stats', 'index.html'), 'w') as fp:
|
||||||
|
fp.write(mylib.template_with_base('''
|
||||||
|
<h2>{}</h2>
|
||||||
|
<p>
|
||||||
|
The AppCheck database currently contains <b>{} apps</b> with a total of <b>{} unique domains</b>.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>List of <a href="/index/domains/all/">Requested Domains</a></li>
|
||||||
|
<li>List of <a href="/index/domains/tracker/">Trackers</a></li>
|
||||||
|
<li>List of <a href="/apps/page/1/">Apps</a></li>
|
||||||
|
</ul>'''.format(title, c_apps, c_domains), title=title))
|
||||||
|
|
||||||
|
|
||||||
def process():
|
def process():
|
||||||
# bundle_combine assures domain name is [a-zA-Z0-9.-]
|
# bundle_combine assures domain name is [a-zA-Z0-9.-]
|
||||||
print('generating reverse-domain-index ...')
|
print('generating domain-index ...')
|
||||||
|
|
||||||
# Data export
|
# Data export
|
||||||
all_dom_dir = mylib.path_out('index', 'domains', 'all')
|
all_dom_dir = mylib.path_out('index', 'domains', 'all')
|
||||||
trkr_dir = mylib.path_out('index', 'domains', 'tracker')
|
trkr_dir = mylib.path_out('index', 'domains', 'tracker')
|
||||||
mylib.mkdir(all_dom_dir)
|
mylib.mkdir(all_dom_dir)
|
||||||
mylib.mkdir(trkr_dir)
|
mylib.mkdir(trkr_dir)
|
||||||
mylib.symlink(index_reverse_domains.fname_all(),
|
mylib.symlink(index_domains.fname_all(),
|
||||||
mylib.path_out_app(all_dom_dir, 'data.json'))
|
mylib.path_out_app(all_dom_dir, 'data.json'))
|
||||||
mylib.symlink(index_reverse_domains.fname_tracker(),
|
mylib.symlink(index_domains.fname_tracker(),
|
||||||
mylib.path_out_app(trkr_dir, 'data.json'))
|
mylib.path_out_app(trkr_dir, 'data.json'))
|
||||||
|
|
||||||
# Load
|
json = index_domains.load()
|
||||||
json = index_reverse_domains.load()
|
app_count = index_domains.number_of_apps(json)
|
||||||
app_count = index_reverse_domains.number_of_apps(json)
|
dom_count = len(json['subdom'])
|
||||||
# Lookup
|
|
||||||
|
print(' Lookup')
|
||||||
gen_html_lookup(mylib.path_out('domain'), json, 'pardom',
|
gen_html_lookup(mylib.path_out('domain'), json, 'pardom',
|
||||||
title='Domain Lookup')
|
title='Domain Lookup')
|
||||||
gen_html_lookup(mylib.path_out('subdomain'), json, 'subdom',
|
gen_html_lookup(mylib.path_out('subdomain'), json, 'subdom',
|
||||||
title='Subdomain Lookup')
|
title='Subdomain Lookup')
|
||||||
# All domains
|
|
||||||
index_reverse_domains.enrich_with_bundle_ids(json)
|
print(' All Domains')
|
||||||
|
index_domains.enrich_with_bundle_ids(json)
|
||||||
gen_html_trinity(json, all_dom_dir, app_count,
|
gen_html_trinity(json, all_dom_dir, app_count,
|
||||||
title='Requested Domains')
|
title='Requested Domains')
|
||||||
# Tacker only
|
|
||||||
json = index_reverse_domains.load(tracker=True)
|
print(' Trackers Only')
|
||||||
index_reverse_domains.enrich_with_bundle_ids(json)
|
json = index_domains.load(tracker=True)
|
||||||
|
index_domains.enrich_with_bundle_ids(json)
|
||||||
gen_html_trinity(json, trkr_dir, app_count,
|
gen_html_trinity(json, trkr_dir, app_count,
|
||||||
title='Tracker')
|
title='Tracker')
|
||||||
|
# Stats
|
||||||
|
print(' Stats')
|
||||||
|
gen_html_stats(app_count, dom_count)
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
|
|
||||||
22
src/main.py
22
src/main.py
@@ -6,11 +6,11 @@ import common_lib as mylib
|
|||||||
import bundle_combine
|
import bundle_combine
|
||||||
import bundle_download
|
import bundle_download
|
||||||
import html_root
|
import html_root
|
||||||
import html_index
|
import html_index_apps
|
||||||
import html_bundle
|
import html_bundle
|
||||||
import html_reverse_domains
|
import html_index_domains
|
||||||
import index_bundle_names
|
import index_app_names
|
||||||
import index_reverse_domains
|
import index_domains
|
||||||
import tracker_download
|
import tracker_download
|
||||||
|
|
||||||
|
|
||||||
@@ -28,21 +28,21 @@ def print_usage_and_exit():
|
|||||||
|
|
||||||
|
|
||||||
def rebuild_app_index(inclRoot=False):
|
def rebuild_app_index(inclRoot=False):
|
||||||
html_index.process()
|
html_index_apps.process()
|
||||||
if inclRoot: # TODO: remove check if root contains dynamic content
|
if inclRoot: # TODO: remove check if root contains dynamic content
|
||||||
html_root.process()
|
html_root.process()
|
||||||
|
|
||||||
|
|
||||||
def rebuild_domain_index(bundle_ids, deleteOnly=False):
|
def rebuild_domain_index(bundle_ids, deleteOnly=False):
|
||||||
index_reverse_domains.process(bundle_ids, deleteOnly=deleteOnly)
|
index_domains.process(bundle_ids, deleteOnly=deleteOnly)
|
||||||
html_reverse_domains.process()
|
html_index_domains.process()
|
||||||
|
|
||||||
|
|
||||||
def rebuild_name_index(new_ids):
|
def rebuild_name_index(new_ids):
|
||||||
if index_bundle_names.missing():
|
if index_app_names.missing():
|
||||||
index_bundle_names.process(['*'])
|
index_app_names.process(['*'])
|
||||||
elif len(new_ids) > 0:
|
elif len(new_ids) > 0:
|
||||||
index_bundle_names.process(new_ids) # after bundle_download
|
index_app_names.process(new_ids) # after bundle_download
|
||||||
|
|
||||||
|
|
||||||
def del_id(bundle_ids):
|
def del_id(bundle_ids):
|
||||||
@@ -76,7 +76,7 @@ def combine_and_update(bundle_ids, where=None):
|
|||||||
# 4. was any json updated? if so, make html and update reverse index
|
# 4. was any json updated? if so, make html and update reverse index
|
||||||
if len(affected) > 0:
|
if len(affected) > 0:
|
||||||
rebuild_domain_index(affected) # after bundle_combine
|
rebuild_domain_index(affected) # after bundle_combine
|
||||||
html_bundle.process(affected) # after index_bundle_names
|
html_bundle.process(affected) # after index_app_names
|
||||||
else:
|
else:
|
||||||
print('no bundle affected by tracker, not generating bundle html')
|
print('no bundle affected by tracker, not generating bundle html')
|
||||||
# 5. make all apps index
|
# 5. make all apps index
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 38 KiB |
@@ -3,9 +3,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=0.75" />
|
<meta name="viewport" content="width=device-width, initial-scale=0.75" />
|
||||||
<script type="text/javascript" src="/static/script.js?8"></script>
|
<script type="text/javascript" src="/static/script.js?9"></script>
|
||||||
<title>#_TITLE_#AppCheck: Privacy Monitor</title>
|
<title>#_TITLE_#AppCheck: Privacy Monitor</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/static/style.css?8">
|
<link rel="stylesheet" type="text/css" href="/static/style.css?9">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/fonts/font.css">
|
<link rel="stylesheet" type="text/css" href="/static/fonts/font.css">
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png">
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<ul id="main-nav">
|
<ul id="main-nav">
|
||||||
<li><a href="/index/page/1/">All Apps</a></li>
|
<li><a href="/index/page/1/">All Apps</a></li>
|
||||||
<li><a href="/index/domains/all/">Domains</a></li>
|
<li><a href="/stats/">Stats</a></li>
|
||||||
<li><a href="/help/">Help needed</a></li>
|
<li><a href="/help/">Help needed</a></li>
|
||||||
<li><a class="no-ul" href="https://github.com/relikd/appcheck" target="_blank"><img src="/static/github.svg" alt="GitHub"></a></li>
|
<li><a class="no-ul" href="https://github.com/relikd/appcheck" target="_blank"><img src="/static/github.svg" alt="GitHub"></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user