Fix neverallow test generator
Section headers such as END_TREBLE_ONLY shouldn't be processed as a
neverallow rule.
Bug: 142959085
Test: m cts && run CtsSecurityHostTestCases on walleye
Change-Id: Iece18fef54faa6da0f13f67d92f6ff44a953967e
diff --git a/tools/selinux/SELinuxNeverallowTestGen.py b/tools/selinux/SELinuxNeverallowTestGen.py
index 1e78347..8ecd2b6a 100755
--- a/tools/selinux/SELinuxNeverallowTestGen.py
+++ b/tools/selinux/SELinuxNeverallowTestGen.py
@@ -49,17 +49,21 @@
for section in sections:
depths[section] = 0
for line in lines:
+ is_header = False
for section in sections:
if line.startswith("BEGIN_%s" % section):
depths[section] += 1
+ is_header = True
break
elif line.startswith("END_%s" % section):
if depths[section] < 1:
exit("ERROR: END_%s outside of %s section" % (section, section))
depths[section] -= 1
+ is_header = True
break
- rule = NeverallowRule(line, depths)
- rules.append(rule)
+ if not is_header:
+ rule = NeverallowRule(line, depths)
+ rules.append(rule)
for section in sections:
if depths[section] != 0: