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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
import gtk
import os
class PermsPanel:
"""Display all permissions found in the Manifest."""
def __init__(self):
tree = gtk.TreeView()
languages = gtk.TreeViewColumn()
languages.set_title("Programming languages")
cell = gtk.CellRendererText()
languages.pack_start(cell, True)
languages.add_attribute(cell, "text", 0)
treestore = gtk.TreeStore(str)
it = treestore.append(None, ["Scripting languages"])
treestore.append(it, ["Python"])
treestore.append(it, ["PHP"])
treestore.append(it, ["Perl"])
treestore.append(it, ["Ruby"])
it = treestore.append(None, ["Compiling languages"])
treestore.append(it, ["C#"])
treestore.append(it, ["C++"])
treestore.append(it, ["C"])
treestore.append(it, ["Java"])
tree.append_column(languages)
tree.set_model(treestore)
tree.show()
self._view = tree
self._perms = { }
self._load_all_definitions()
def get_widget(self):
return self._view
def _load_all_definitions(self):
"""Load the database in memory."""
with open(os.path.dirname(__file__) + '/androperms.db', 'r') as f:
for line in f.readlines():
perm = line.strip("\n").split("\t")
for p in perm[1].split(" "):
if not p.startswith("android.permission."):
continue
if p not in self._perms:
self._perms[p] = []
self._perms[p].append(perm[0])
def filter_permissions(self, used):
"""Forget all permissions which are not used."""
keep = {}
for p in self._perms:
if p in used:
keep[p] = self._perms[p]
self._perms = keep
# for p in self._perms:
# print p
# for v in self._perms[p]:
# print " - ", v
|