Skip to contentSkip to conversation

sepolgen: strip non-printable characters when parsing audit messages

PATCH Applied Vit Mojzis 2 participants 2 messages Feb 21, 2017 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 sepolgen: strip non-printable characters when parsing audit messages

Strip the following characters
\x1c File Separator
\x1d Group Separator
\x1e Record Separator
\x85 Next Line (C1 Control Code)
from audit message fields to make sure they are not evaluated as part of some identifier (eg. ausearch used insert \x1d into --raw output resulting in "unrecognized class" error messages).

This is done as part of str.split() in python3.

---
 python/sepolgen/src/sepolgen/audit.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
python/sepolgen/src/sepolgen/audit.py +3 -1
index 724d3ea..26ce6c9 100644
@@ -376,7 +376,9 @@ class AuditParser:
     #   AuditMessage (or subclass) - object representing a parsed
     #      and valid audit message.
     def __parse_line(self, line):
-        rec = line.split()
+        # strip("\x1c\x1d\x1e\x85") is only needed for python2
+        # since str.split() in python3 already does this
+        rec = [x.strip("\x1c\x1d\x1e\x85") for x in line.split()]
         for i in rec:
             found = False
             if i == "avc:" or i == "message=avc:" or i == "msg='avc:":
Signature · 1 line
2.9.3
Applied
#1 lore raw
Quoted 9 lines · Vit Mojzis

Strip the following characters
\x1c File Separator
\x1d Group Separator
\x1e Record Separator
\x85 Next Line (C1 Control Code)
from audit message fields to make sure they are not evaluated as part of some identifier (eg. ausearch used insert \x1d into --raw output resulting in "unrecognized class" error messages).

Quoted 3 lines

This is done as part of str.split() in python3.

Applied.

Thanks,
Jim

Quoted 20 lines
---
 python/sepolgen/src/sepolgen/audit.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
python/sepolgen/src/sepolgen/audit.py +3 -1
index 724d3ea..26ce6c9 100644
@@ -376,7 +376,9 @@ class AuditParser:
     #   AuditMessage (or subclass) - object representing a parsed
     #      and valid audit message.
     def __parse_line(self, line):
-        rec = line.split()
+        # strip("\x1c\x1d\x1e\x85") is only needed for python2
+        # since str.split() in python3 already does this
+        rec = [x.strip("\x1c\x1d\x1e\x85") for x in line.split()]
         for i in rec:
             found = False
             if i == "avc:" or i == "message=avc:" or i == "msg='avc:":
Signature · 2 lines
James Carter <[email protected]>
National Security Agency