|
|
c23a3a |
diff --git a/sepolgen/src/sepolgen/audit.py b/sepolgen/src/sepolgen/audit.py
|
|
|
c23a3a |
index d636091..56919be 100644
|
|
|
c23a3a |
--- a/sepolgen/src/sepolgen/audit.py
|
|
|
c23a3a |
+++ b/sepolgen/src/sepolgen/audit.py
|
|
|
c23a3a |
@@ -259,13 +259,13 @@ class AVCMessage(AuditMessage):
|
|
|
c23a3a |
raise ValueError("Error during access vector computation")
|
|
|
c23a3a |
|
|
|
c23a3a |
if self.type == audit2why.CONSTRAINT:
|
|
|
c23a3a |
- self.data = []
|
|
|
c23a3a |
+ self.data = [ self.data ]
|
|
|
c23a3a |
if self.scontext.user != self.tcontext.user:
|
|
|
c23a3a |
- self.data.append("user")
|
|
|
c23a3a |
+ self.data.append(("user (%s)" % self.scontext.user, 'user (%s)' % self.tcontext.user))
|
|
|
c23a3a |
if self.scontext.role != self.tcontext.role and self.tcontext.role != "object_r":
|
|
|
c23a3a |
- self.data.append("role")
|
|
|
c23a3a |
+ self.data.append(("role (%s)" % self.scontext.role, 'role (%s)' % self.tcontext.role))
|
|
|
c23a3a |
if self.scontext.level != self.tcontext.level:
|
|
|
c23a3a |
- self.data.append("level")
|
|
|
c23a3a |
+ self.data.append(("level (%s)" % self.scontext.level, 'level (%s)' % self.tcontext.level))
|
|
|
c23a3a |
|
|
|
c23a3a |
avcdict[(scontext, tcontext, self.tclass, access_tuple)] = (self.type, self.data)
|
|
|
c23a3a |
|
|
|
c23a3a |
diff --git a/sepolgen/src/sepolgen/policygen.py b/sepolgen/src/sepolgen/policygen.py
|
|
|
c23a3a |
index cc9f8ea..ce643e5 100644
|
|
|
c23a3a |
--- a/sepolgen/src/sepolgen/policygen.py
|
|
|
c23a3a |
+++ b/sepolgen/src/sepolgen/policygen.py
|
|
|
c23a3a |
@@ -161,21 +161,21 @@ class PolicyGenerator:
|
|
|
c23a3a |
if self.explain:
|
|
|
c23a3a |
rule.comment = str(refpolicy.Comment(explain_access(av, verbosity=self.explain)))
|
|
|
c23a3a |
if av.type == audit2why.ALLOW:
|
|
|
c23a3a |
- rule.comment += "#!!!! This avc is allowed in the current policy\n"
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! This avc is allowed in the current policy"
|
|
|
c23a3a |
if av.type == audit2why.DONTAUDIT:
|
|
|
c23a3a |
- rule.comment += "#!!!! This avc has a dontaudit rule in the current policy\n"
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! This avc has a dontaudit rule in the current policy"
|
|
|
c23a3a |
|
|
|
c23a3a |
if av.type == audit2why.BOOLEAN:
|
|
|
c23a3a |
if len(av.data) > 1:
|
|
|
c23a3a |
- rule.comment += "#!!!! This avc can be allowed using one of the these booleans:\n# %s\n" % ", ".join(map(lambda x: x[0], av.data))
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! This avc can be allowed using one of the these booleans:\n# %s" % ", ".join(map(lambda x: x[0], av.data))
|
|
|
c23a3a |
else:
|
|
|
c23a3a |
- rule.comment += "#!!!! This avc can be allowed using the boolean '%s'\n" % av.data[0][0]
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! This avc can be allowed using the boolean '%s'" % av.data[0][0]
|
|
|
c23a3a |
|
|
|
c23a3a |
if av.type == audit2why.CONSTRAINT:
|
|
|
c23a3a |
- rule.comment += "#!!!! This avc is a constraint violation. You will need to add an attribute to either the source or target type to make it work.\n"
|
|
|
c23a3a |
- rule.comment += "#Constraint rule: "
|
|
|
c23a3a |
- for reason in av.data:
|
|
|
c23a3a |
- rule.comment += "\n#\tPossible cause source context and target context '%s' differ\b" % reason
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! This avc is a constraint violation. You would need to modify the attributes of either the source or target types to allow this access.\n"
|
|
|
c23a3a |
+ rule.comment += "#Constraint rule: \n\t" + av.data[0]
|
|
|
c23a3a |
+ for reason in av.data[1:]:
|
|
|
c23a3a |
+ rule.comment += "#\tPossible cause is the source %s and target %s are different." % reason
|
|
|
c23a3a |
|
|
|
c23a3a |
try:
|
|
|
c23a3a |
if ( av.type == audit2why.TERULE and
|
|
|
c23a3a |
@@ -189,9 +189,9 @@ class PolicyGenerator:
|
|
|
c23a3a |
if i not in self.domains:
|
|
|
c23a3a |
types.append(i)
|
|
|
c23a3a |
if len(types) == 1:
|
|
|
c23a3a |
- rule.comment += "#!!!! The source type '%s' can write to a '%s' of the following type:\n# %s\n" % ( av.src_type, av.obj_class, ", ".join(types))
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! The source type '%s' can write to a '%s' of the following type:\n# %s\n" % ( av.src_type, av.obj_class, ", ".join(types))
|
|
|
c23a3a |
elif len(types) >= 1:
|
|
|
c23a3a |
- rule.comment += "#!!!! The source type '%s' can write to a '%s' of the following types:\n# %s\n" % ( av.src_type, av.obj_class, ", ".join(types))
|
|
|
c23a3a |
+ rule.comment += "\n#!!!! The source type '%s' can write to a '%s' of the following types:\n# %s\n" % ( av.src_type, av.obj_class, ", ".join(types))
|
|
|
c23a3a |
except:
|
|
|
c23a3a |
pass
|
|
|
c23a3a |
self.module.children.append(rule)
|
|
|
c23a3a |
diff --git a/sepolgen/src/sepolgen/refparser.py b/sepolgen/src/sepolgen/refparser.py
|
|
|
c23a3a |
index 7b76261..a05d9d1 100644
|
|
|
c23a3a |
--- a/sepolgen/src/sepolgen/refparser.py
|
|
|
c23a3a |
+++ b/sepolgen/src/sepolgen/refparser.py
|
|
|
c23a3a |
@@ -65,6 +65,7 @@ tokens = (
|
|
|
c23a3a |
'BAR',
|
|
|
c23a3a |
'EXPL',
|
|
|
c23a3a |
'EQUAL',
|
|
|
c23a3a |
+ 'FILENAME',
|
|
|
c23a3a |
'IDENTIFIER',
|
|
|
c23a3a |
'NUMBER',
|
|
|
c23a3a |
'PATH',
|
|
|
c23a3a |
@@ -249,11 +250,17 @@ def t_refpolicywarn(t):
|
|
|
c23a3a |
t.lexer.lineno += 1
|
|
|
c23a3a |
|
|
|
c23a3a |
def t_IDENTIFIER(t):
|
|
|
c23a3a |
- r'[a-zA-Z_\$\"][a-zA-Z0-9_\-\+\.\$\*\"~]*'
|
|
|
c23a3a |
+ r'[a-zA-Z_\$][a-zA-Z0-9_\-\+\.\$\*~]*'
|
|
|
c23a3a |
# Handle any keywords
|
|
|
c23a3a |
t.type = reserved.get(t.value,'IDENTIFIER')
|
|
|
c23a3a |
return t
|
|
|
c23a3a |
|
|
|
c23a3a |
+def t_FILENAME(t):
|
|
|
c23a3a |
+ r'\"[a-zA-Z0-9_\-\+\.\$\*~ :]+\"'
|
|
|
c23a3a |
+ # Handle any keywords
|
|
|
c23a3a |
+ t.type = reserved.get(t.value,'FILENAME')
|
|
|
c23a3a |
+ return t
|
|
|
c23a3a |
+
|
|
|
c23a3a |
def t_comment(t):
|
|
|
c23a3a |
r'\#.*\n'
|
|
|
c23a3a |
# Ignore all comments
|
|
|
c23a3a |
@@ -450,6 +457,7 @@ def p_interface_call_param(p):
|
|
|
c23a3a |
| nested_id_set
|
|
|
c23a3a |
| TRUE
|
|
|
c23a3a |
| FALSE
|
|
|
c23a3a |
+ | FILENAME
|
|
|
c23a3a |
'''
|
|
|
c23a3a |
# Intentionally let single identifiers pass through
|
|
|
c23a3a |
# List means set, non-list identifier
|
|
|
c23a3a |
@@ -461,6 +469,7 @@ def p_interface_call_param(p):
|
|
|
c23a3a |
def p_interface_call_param_list(p):
|
|
|
c23a3a |
'''interface_call_param_list : interface_call_param
|
|
|
c23a3a |
| interface_call_param_list COMMA interface_call_param
|
|
|
c23a3a |
+ | interface_call_param_list COMMA interface_call_param COMMA interface_call_param_list
|
|
|
c23a3a |
'''
|
|
|
c23a3a |
if len(p) == 2:
|
|
|
c23a3a |
p[0] = [p[1]]
|
|
|
c23a3a |
@@ -787,6 +796,7 @@ def p_avrule_def(p):
|
|
|
c23a3a |
|
|
|
c23a3a |
def p_typerule_def(p):
|
|
|
c23a3a |
'''typerule_def : TYPE_TRANSITION names names COLON names IDENTIFIER SEMI
|
|
|
c23a3a |
+ | TYPE_TRANSITION names names COLON names IDENTIFIER FILENAME SEMI
|
|
|
c23a3a |
| TYPE_TRANSITION names names COLON names IDENTIFIER IDENTIFIER SEMI
|
|
|
c23a3a |
| TYPE_CHANGE names names COLON names IDENTIFIER SEMI
|
|
|
c23a3a |
| TYPE_MEMBER names names COLON names IDENTIFIER SEMI
|
|
|
c23a3a |
@@ -800,6 +810,7 @@ def p_typerule_def(p):
|
|
|
c23a3a |
t.tgt_types = p[3]
|
|
|
c23a3a |
t.obj_classes = p[5]
|
|
|
c23a3a |
t.dest_type = p[6]
|
|
|
c23a3a |
+ t.file_name = p[7]
|
|
|
c23a3a |
p[0] = t
|
|
|
c23a3a |
|
|
|
c23a3a |
def p_bool(p):
|