2014-07-08 18:28:55 +00:00
|
|
|
#!/usr/bin/python
|
2015-03-06 14:19:35 +00:00
|
|
|
# Copyright 2014-2015, Tresys Technology, LLC
|
2014-07-08 18:28:55 +00:00
|
|
|
#
|
|
|
|
# This file is part of SETools.
|
|
|
|
#
|
|
|
|
# SETools 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 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# SETools 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 SETools. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2014-10-25 01:23:13 +00:00
|
|
|
import setools
|
2014-07-08 18:28:55 +00:00
|
|
|
import argparse
|
|
|
|
import sys
|
2015-03-19 12:07:23 +00:00
|
|
|
import logging
|
2014-07-08 18:28:55 +00:00
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
|
|
|
|
def expand_attr(attr):
|
|
|
|
"""Render type and role attributes."""
|
|
|
|
items = "\n\t".join(sorted(str(i) for i in attr.expand()))
|
|
|
|
contents = items if items else "<empty set>"
|
|
|
|
return "{0}\n\t{1}".format(attr.statement(), contents)
|
|
|
|
|
2014-07-08 18:28:55 +00:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="SELinux policy information tool.")
|
2014-10-25 01:23:13 +00:00
|
|
|
parser.add_argument("--version", action="version", version=setools.__version__)
|
2015-05-08 19:21:00 +00:00
|
|
|
parser.add_argument("policy", help="Path to the SELinux policy to query.", nargs="?")
|
2015-02-12 18:59:54 +00:00
|
|
|
parser.add_argument("-x", "--expand", action="store_true",
|
|
|
|
help="Print additional information about the specified components.")
|
2015-02-06 14:10:06 +00:00
|
|
|
parser.add_argument("--flat", help="Print without item count nor indentation.",
|
|
|
|
dest="flat", default=False, action="store_true")
|
2015-03-19 12:07:23 +00:00
|
|
|
parser.add_argument("-v", "--verbose", action="store_true",
|
|
|
|
help="Print extra informational messages")
|
2015-03-07 16:41:04 +00:00
|
|
|
parser.add_argument("--debug", action="store_true", dest="debug", help="Enable debugging.")
|
2014-07-08 18:28:55 +00:00
|
|
|
|
|
|
|
queries = parser.add_argument_group("Component Queries")
|
2015-03-16 14:46:33 +00:00
|
|
|
queries.add_argument("-a", "--attribute", help="Print type attributes.", dest="typeattrquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="ATTR")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("-b", "--bool", help="Print Booleans.", dest="boolquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="BOOL")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("-c", "--class", help="Print object classes.", dest="classquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="CLASS")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("-r", "--role", help="Print roles.", dest="rolequery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="ROLE")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("-t", "--type", help="Print types.", dest="typequery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="TYPE")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("-u", "--user", help="Print users.", dest="userquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="USER")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--category", help="Print MLS categories.", dest="mlscatsquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="CAT")
|
2015-03-20 15:50:25 +00:00
|
|
|
queries.add_argument("--common", help="Print common permission set.", dest="commonquery",
|
|
|
|
nargs='?', const=True, metavar="COMMON")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--constrain", help="Print constraints.", dest="constraintquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="CLASS")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--fs_use", help="Print fs_use statements.", dest="fsusequery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="FS_TYPE")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--genfscon", help="Print genfscon statements.", dest="genfsconquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="FS_TYPE")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("--initialsid", help="Print initial SIDs (contexts).", dest="initialsidquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="NAME")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--netifcon", help="Print netifcon statements.", dest="netifconquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="DEVICE")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--nodecon", help="Print nodecon statements.", dest="nodeconquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="ADDR")
|
2015-03-08 19:00:51 +00:00
|
|
|
queries.add_argument("--permissive", help="Print permissive types.", dest="permissivequery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="TYPE")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--polcap", help="Print policy capabilities.", dest="polcapquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="NAME")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("--portcon", help="Print portcon statements.", dest="portconquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="PORTNUM[-PORTNUM]")
|
2015-03-13 17:00:55 +00:00
|
|
|
queries.add_argument("--sensitivity", help="Print MLS sensitivities.", dest="mlssensquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="SENS")
|
2015-03-12 17:45:42 +00:00
|
|
|
queries.add_argument("--validatetrans", help="Print validatetrans.", dest="validatetransquery",
|
2015-03-19 19:20:37 +00:00
|
|
|
nargs='?', const=True, metavar="CLASS")
|
2015-02-12 18:59:54 +00:00
|
|
|
queries.add_argument("--all", help="Print all of the above.",
|
2015-02-04 09:01:09 +00:00
|
|
|
dest="all", default=False, action="store_true")
|
2014-07-08 18:28:55 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2015-03-19 12:07:23 +00:00
|
|
|
if args.debug:
|
2015-03-25 17:40:03 +00:00
|
|
|
logging.basicConfig(level=logging.DEBUG,
|
|
|
|
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
2015-03-19 12:07:23 +00:00
|
|
|
elif args.verbose:
|
2015-03-25 17:40:03 +00:00
|
|
|
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
|
|
|
else:
|
|
|
|
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
2015-03-19 12:07:23 +00:00
|
|
|
|
2014-07-08 18:28:55 +00:00
|
|
|
try:
|
2014-10-25 01:23:13 +00:00
|
|
|
p = setools.SELinuxPolicy(args.policy)
|
2015-02-04 09:01:09 +00:00
|
|
|
components = []
|
2014-07-08 18:28:55 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.boolquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.BoolQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.boolquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.boolquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Booleans", q, lambda x: x.statement()))
|
2014-07-08 18:28:55 +00:00
|
|
|
|
2015-03-07 14:39:01 +00:00
|
|
|
if args.mlscatsquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.CategoryQuery(p)
|
2015-03-07 14:39:01 +00:00
|
|
|
if isinstance(args.mlscatsquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.mlscatsquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Categories", q, lambda x: x.statement()))
|
2015-03-07 14:39:01 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.classquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.ObjClassQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.classquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.classquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Classes", q, lambda x: x.statement()))
|
2014-07-08 18:28:55 +00:00
|
|
|
|
2015-03-20 15:50:25 +00:00
|
|
|
if args.commonquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.CommonQuery(p)
|
2015-03-20 15:50:25 +00:00
|
|
|
if isinstance(args.commonquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.commonquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Commons", q, lambda x: x.statement()))
|
2015-03-20 15:50:25 +00:00
|
|
|
|
2015-03-08 18:50:43 +00:00
|
|
|
if args.constraintquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.ConstraintQuery(p, ruletype=["constrain", "mlsconstrain"])
|
2015-03-08 18:50:43 +00:00
|
|
|
if isinstance(args.constraintquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
# pylint: disable=no-member
|
|
|
|
q.set_tclass(args.constraintquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Constraints", q, lambda x: x.statement()))
|
2015-03-08 18:50:43 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.fsusequery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.FSUseQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.fsusequery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
# pylint: disable=no-member
|
|
|
|
q.set_fs(args.fsusequery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Fs_use", q, lambda x: x.statement()))
|
2014-07-17 13:39:06 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.genfsconquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.GenfsconQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.genfsconquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
# pylint: disable=no-member
|
|
|
|
q.set_fs(args.genfsconquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Genfscon", q, lambda x: x.statement()))
|
2014-07-21 17:26:30 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.initialsidquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.InitialSIDQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.initialsidquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.initialsidquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Initial SIDs", q, lambda x: x.statement()))
|
2014-08-01 12:56:29 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.netifconquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.NetifconQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.netifconquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.netifconquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Netifcon", q, lambda x: x.statement()))
|
2014-10-08 15:31:05 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.nodeconquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.NodeconQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.nodeconquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
# pylint: disable=no-member
|
|
|
|
q.set_network(args.nodeconquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Nodecon", q, lambda x: x.statement()))
|
2014-11-03 18:50:06 +00:00
|
|
|
|
2015-03-08 19:00:51 +00:00
|
|
|
if args.permissivequery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.TypeQuery(p, permissive=True, match_permissive=True)
|
2015-03-08 19:00:51 +00:00
|
|
|
if isinstance(args.permissivequery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.permissivequery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Permissive Types", q, lambda x: x.statement()))
|
2015-03-08 19:00:51 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.polcapquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.PolCapQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.polcapquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.polcapquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Polcap", q, lambda x: x.statement()))
|
2014-11-03 18:50:06 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.portconquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.PortconQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.portconquery, str):
|
|
|
|
try:
|
|
|
|
ports = [int(i) for i in args.portconquery.split("-")]
|
2015-04-02 18:50:21 +00:00
|
|
|
except ValueError:
|
2015-02-14 15:40:38 +00:00
|
|
|
parser.error("Enter a port number or range, e.g. 22 or 6000-6020")
|
2014-11-05 18:09:35 +00:00
|
|
|
|
2014-11-30 14:34:59 +00:00
|
|
|
if len(ports) == 2:
|
2015-04-06 13:51:32 +00:00
|
|
|
# pylint: disable=no-member
|
2014-11-30 14:34:59 +00:00
|
|
|
q.set_ports((ports[0], ports[1]))
|
|
|
|
elif len(ports) == 1:
|
2015-04-06 13:51:32 +00:00
|
|
|
# pylint: disable=no-member
|
2014-11-30 14:34:59 +00:00
|
|
|
q.set_ports((ports[0], ports[0]))
|
|
|
|
else:
|
2015-02-14 15:40:38 +00:00
|
|
|
parser.error("Enter a port number or range, e.g. 22 or 6000-6020")
|
2014-11-09 03:44:58 +00:00
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Portcon", q, lambda x: x.statement()))
|
2014-11-09 03:44:58 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.rolequery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.RoleQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.rolequery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.rolequery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Roles", q, lambda x: x.statement()))
|
2014-11-25 03:08:34 +00:00
|
|
|
|
2015-03-07 16:16:59 +00:00
|
|
|
if args.mlssensquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.SensitivityQuery(p)
|
2015-03-07 16:16:59 +00:00
|
|
|
if isinstance(args.mlssensquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.mlssensquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Sensitivities", q, lambda x: x.statement()))
|
2015-03-07 16:16:59 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.typequery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.TypeQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.typequery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.typequery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Types", q, lambda x: x.statement()))
|
2014-11-25 03:08:34 +00:00
|
|
|
|
2015-03-16 14:46:33 +00:00
|
|
|
if args.typeattrquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.TypeAttributeQuery(p)
|
2015-03-16 14:46:33 +00:00
|
|
|
if isinstance(args.typeattrquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.typeattrquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Type Attributes", q, expand_attr))
|
2015-03-16 14:46:33 +00:00
|
|
|
|
2015-02-04 09:01:09 +00:00
|
|
|
if args.userquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.UserQuery(p)
|
2014-11-30 14:34:59 +00:00
|
|
|
if isinstance(args.userquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
q.set_name(args.userquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Users", q, lambda x: x.statement()))
|
2014-11-25 03:08:34 +00:00
|
|
|
|
2015-03-12 17:45:42 +00:00
|
|
|
if args.validatetransquery or args.all:
|
2015-04-15 16:00:59 +00:00
|
|
|
q = setools.ConstraintQuery(p, ruletype=["validatetrans", "mlsvalidatetrans"])
|
2015-03-12 17:45:42 +00:00
|
|
|
if isinstance(args.validatetransquery, str):
|
2015-04-15 16:00:59 +00:00
|
|
|
# pylint: disable=no-member
|
|
|
|
q.set_tclass(args.validatetransquery)
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
components.append(("Validatetrans", q, lambda x: x.statement()))
|
2015-03-12 17:45:42 +00:00
|
|
|
|
2015-02-05 23:22:46 +00:00
|
|
|
if (not components or args.all) and not args.flat:
|
2015-02-06 14:11:44 +00:00
|
|
|
mls = "enabled" if p.mls else "disabled"
|
2014-11-30 18:30:36 +00:00
|
|
|
|
2015-05-08 19:21:00 +00:00
|
|
|
print("Statistics for policy file: {0}".format(p))
|
2014-11-30 18:30:36 +00:00
|
|
|
print("Policy Version: {0} (MLS {1})".format(p.version, mls))
|
|
|
|
print(" Classes: {0:7} Permissions: {1:7}".format(
|
|
|
|
p.class_count, p.permission_count))
|
|
|
|
print(" Sensitivities: {0:7} Categories: {1:7}".format(
|
|
|
|
p.level_count, p.category_count))
|
|
|
|
print(" Types: {0:7} Attributes: {1:7}".format(
|
2015-03-16 14:46:33 +00:00
|
|
|
p.type_count, p.type_attribute_count))
|
2014-11-30 18:30:36 +00:00
|
|
|
print(" Users: {0:7} Roles: {1:7}".format(
|
|
|
|
p.user_count, p.role_count))
|
|
|
|
print(" Booleans: {0:7} Cond. Expr.: {1:7}".format(
|
|
|
|
p.boolean_count, p.conditional_count))
|
|
|
|
print(" Allow: {0:7} Neverallow: {1:7}".format(
|
|
|
|
p.allow_count, p.neverallow_count))
|
|
|
|
print(" Auditallow: {0:7} Dontaudit: {1:7}".format(
|
|
|
|
p.auditallow_count, p.dontaudit_count))
|
|
|
|
print(" Type_trans: {0:7} Type_change: {1:7}".format(
|
|
|
|
p.type_transition_count, p.type_change_count))
|
|
|
|
print(" Type_member: {0:7} Range_trans: {1:7}".format(
|
|
|
|
p.type_member_count, p.range_transition_count))
|
|
|
|
print(" Role allow: {0:7} Role_trans: {1:7}".format(
|
|
|
|
p.role_allow_count, p.role_transition_count))
|
|
|
|
print(" Constraints: {0:7} Validatetrans: {1:7}".format(
|
|
|
|
p.constraint_count, p.validatetrans_count))
|
|
|
|
print(" MLS Constrain: {0:7} MLS Val. Tran: {1:7}".format(
|
|
|
|
p.mlsconstraint_count, p.mlsvalidatetrans_count))
|
|
|
|
print(" Initial SIDs: {0:7} Fs_use: {1:7}".format(
|
|
|
|
p.initialsids_count, p.fs_use_count))
|
|
|
|
print(" Genfscon: {0:7} Portcon: {1:7}".format(
|
|
|
|
p.genfscon_count, p.portcon_count))
|
|
|
|
print(" Netifcon: {0:7} Nodecon: {1:7}".format(
|
|
|
|
p.netifcon_count, p.nodecon_count))
|
|
|
|
print(" Permissives: {0:7} Polcap: {1:7}".format(
|
|
|
|
p.permissives_count, p.polcap_count))
|
|
|
|
|
2015-03-22 15:46:44 +00:00
|
|
|
for desc, component, expander in components:
|
2015-02-04 09:01:09 +00:00
|
|
|
results = sorted(component.results())
|
2015-02-05 23:22:46 +00:00
|
|
|
if not args.flat:
|
|
|
|
print("\n{0}: {1}".format(desc, len(results)))
|
2015-02-04 09:01:09 +00:00
|
|
|
for item in results:
|
2015-03-22 15:46:44 +00:00
|
|
|
result = expander(item) if args.expand else item
|
2015-02-06 14:08:45 +00:00
|
|
|
strfmt = " {0}" if not args.flat else "{0}"
|
2015-02-05 23:22:46 +00:00
|
|
|
print(strfmt.format(result))
|
2015-02-04 09:01:09 +00:00
|
|
|
|
2014-11-30 14:34:59 +00:00
|
|
|
except Exception as err:
|
2015-03-07 16:41:04 +00:00
|
|
|
if args.debug:
|
|
|
|
import traceback
|
|
|
|
traceback.print_exc()
|
|
|
|
else:
|
|
|
|
print(err)
|
|
|
|
|
2014-11-30 14:34:59 +00:00
|
|
|
sys.exit(-1)
|