-
Notifications
You must be signed in to change notification settings - Fork 2
/
seexport_graph
executable file
·79 lines (61 loc) · 3.06 KB
/
seexport_graph
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# (C) Copyright 2016 Vit Mojzis, [email protected]
#
# This program is distributed under the terms of the GNU General Public License
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import sys
import sepolicyanalysis.config_loading as config
import sepolicyanalysis.visualization as vis
import sepolicyanalysis.policy_data_collection as data
import sepolicyanalysis.userquery as query
import sepolicyanalysis.domain_grouping as grouping
parser = argparse.ArgumentParser(description='SELinux policy graph export tool.')
parser.add_argument("package", help="Policy concerning this package will be exported")
parser.add_argument("policy", help="Path to the SELinux policy to be used.", nargs="?")
search = parser.add_argument_group("Rule search (similar to sesearch)")
search.add_argument("-c", "--class", dest="tclass",
help="Comma separated list of object classes")
search.add_argument("-p", "--perms", metavar="PERMS",
help="Comma separated list of permissions.")
search.add_argument("-a", "--attr", metavar="ATTR",
help="Comma separated list of attributes.")
search.add_argument("-b", "--bool", dest="boolean", metavar="BOOL",
help="Comma separated list of Booleans in the conditional expression.")
search.add_argument("-ea", action="store_true", dest="expand_attributes",
help="Expand rules ending in attribute (to all types that have given attribute).")
filtering = parser.add_argument_group("Filtering")
filtering.add_argument("-fb", "--filter_bools", nargs="?", dest="filter_bools", const="",
help="Filter rules based on current boolean setting \
(or boolean config file or comma separated list of [boolean]:[on/off]).")
filtering.add_argument("-fa", "--filter_attrs", dest="filter_attrs", metavar="ATTR",
help="Filter out rules allowed for specified attributes. \
ATTR - Comma separated list of attributes.")
args = parser.parse_args()
args.export = True
# split list attributes
for arg in ["perms", "attr", "boolean", "tclass", "filter_attrs"]:
value = getattr(args, arg)
if value:
setattr(args, arg, value.split(","))
if args.filter_bools != None:
args.filter_bools = config.parse_bool_config(args.filter_bools)
# For compatibility with userquery module
args.source = args.package
args.main_domain = args.source
data.policy_init(args.policy)
q = query.UserQuery(args)
q.apply_query()