sesearch: Fix static type checking issues.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
This commit is contained in:
Chris PeBenito 2020-10-02 15:33:38 -04:00
parent 463f6741bb
commit 1830ca6848

View File

@ -144,7 +144,7 @@ try:
p = setools.SELinuxPolicy(args.policy)
if args.tertypes:
q = setools.TERuleQuery(p,
terq = setools.TERuleQuery(p,
ruletype=args.tertypes,
source=args.source,
source_indirect=args.source_indirect,
@ -164,12 +164,12 @@ try:
# with an empty string in it (split on empty string)
if args.tclass:
if args.tclass_regex:
q.tclass = args.tclass
terq.tclass = args.tclass
else:
q.tclass = args.tclass.split(",")
terq.tclass = args.tclass.split(",")
if args.perms:
q.perms = args.perms.split(",")
terq.perms = args.perms.split(",")
if args.xperms:
xperms = []
@ -183,24 +183,25 @@ try:
parser.error("Enter an extended permission or extended permission range, e.g. "
"0x5411 or 0x8800-0x88ff.")
q.xperms = xperms
# https://github.com/python/mypy/issues/220
terq.xperms = setools.xperm_str_to_tuple_ranges(xperms) # type: ignore
if args.boolean:
if args.boolean_regex:
q.boolean = args.boolean
terq.boolean = args.boolean
else:
if args.policy:
q.boolean = args.boolean.split(",")
terq.boolean = args.boolean.split(",")
else:
# try to find substitutions for old boolean names
q.boolean = map(setools.policyrep.lookup_boolean_name_sub,
terq.boolean = map(setools.policyrep.lookup_boolean_name_sub,
args.boolean.split(","))
for r in sorted(q.results()):
print(r)
for te_result in sorted(terq.results()):
print(te_result)
if args.rbacrtypes:
q = setools.RBACRuleQuery(p,
rbacrq = setools.RBACRuleQuery(p,
ruletype=args.rbacrtypes,
source=args.source,
source_indirect=args.source_indirect,
@ -216,15 +217,15 @@ try:
# with an empty string in it (split on empty string)
if args.tclass:
if args.tclass_regex:
q.tclass = args.tclass
rbacrq.tclass = args.tclass
else:
q.tclass = args.tclass.split(",")
rbacrq.tclass = args.tclass.split(",")
for r in sorted(q.results()):
print(r)
for rbac_result in sorted(rbacrq.results()):
print(rbac_result)
if args.mlsrtypes:
q = setools.MLSRuleQuery(p,
mlsrq = setools.MLSRuleQuery(p,
ruletype=args.mlsrtypes,
source=args.source,
source_indirect=args.source_indirect,
@ -239,12 +240,12 @@ try:
# with an empty string in it (split on empty string)
if args.tclass:
if args.tclass_regex:
q.tclass = args.tclass
mlsrq.tclass = args.tclass
else:
q.tclass = args.tclass.split(",")
mlsrq.tclass = args.tclass.split(",")
for r in sorted(q.results()):
print(r)
for mls_result in sorted(mlsrq.results()):
print(mls_result)
except Exception as err:
if args.debug: