mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-29 14:56:21 +00:00
TabRegistry: Add a new metaclass for generating the tab selection.
The ChooseAnalysis dialog lists the analysis tabs so the user can select them. Create a new metaclass so the listing of tabs, grouping in the menu, and the invocation of the tab's class is automatic. This requires section, tab_title, and mlsonly class attributes. Signed-off-by: Chris PeBenito <pebenito@ieee.org>
This commit is contained in:
parent
72ab536933
commit
d3687c7705
.mypy.ini
setoolsgui/apol
__init__.pyanalysistab.pyboolquery.pyboundsquery.pycategoryquery.pychooseanalysis.pycommonquery.pyconstraintquery.pydefaultquery.pydta.pyfsusequery.pygenfsconquery.pyibendportconquery.pyibpkeyconquery.pyinfoflow.pyinitsidquery.pymainwindow.pymlsrulequery.pynetifconquery.pynodeconquery.pyobjclassquery.pyportconquery.pyrbacrulequery.pyrolequery.pysensitivityquery.pysummary.pyterulequery.pytypeattrquery.pytypequery.pyuserquery.py
@ -11,3 +11,6 @@ ignore_missing_imports = True
|
||||
|
||||
[mypy-PyQt5.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-sip]
|
||||
ignore_missing_imports = True
|
||||
|
@ -18,3 +18,31 @@
|
||||
#
|
||||
|
||||
from .mainwindow import ApolMainWindow
|
||||
|
||||
# Analysis tabs:
|
||||
from .boolquery import BoolQueryTab
|
||||
from .boundsquery import BoundsQueryTab
|
||||
from .categoryquery import CategoryQueryTab
|
||||
from .commonquery import CommonQueryTab
|
||||
from .constraintquery import ConstraintQueryTab
|
||||
from .defaultquery import DefaultQueryTab
|
||||
from .dta import DomainTransitionAnalysisTab
|
||||
from .fsusequery import FSUseQueryTab
|
||||
from .genfsconquery import GenfsconQueryTab
|
||||
from .ibendportconquery import IbendportconQueryTab
|
||||
from .ibpkeyconquery import IbpkeyconQueryTab
|
||||
from .infoflow import InfoFlowAnalysisTab
|
||||
from .initsidquery import InitialSIDQueryTab
|
||||
from .mlsrulequery import MLSRuleQueryTab
|
||||
from .netifconquery import NetifconQueryTab
|
||||
from .nodeconquery import NodeconQueryTab
|
||||
from .objclassquery import ObjClassQueryTab
|
||||
from .portconquery import PortconQueryTab
|
||||
from .rbacrulequery import RBACRuleQueryTab
|
||||
from .rolequery import RoleQueryTab
|
||||
from .sensitivityquery import SensitivityQueryTab
|
||||
from .summary import SummaryTab
|
||||
from .terulequery import TERuleQueryTab
|
||||
from .typeattrquery import TypeAttributeQueryTab
|
||||
from .typequery import TypeQueryTab
|
||||
from .userquery import UserQueryTab
|
||||
|
@ -16,12 +16,69 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from typing import Dict, NamedTuple
|
||||
from enum import Enum
|
||||
|
||||
import sip
|
||||
from PyQt5.QtWidgets import QDialogButtonBox, QScrollArea
|
||||
|
||||
from ..widget import SEToolsWidget
|
||||
|
||||
|
||||
class AnalysisTab(SEToolsWidget, QScrollArea):
|
||||
class AnalysisSection(Enum):
|
||||
|
||||
"""Groupings of analysis tabs"""
|
||||
|
||||
Analysis = 1
|
||||
Components = 2
|
||||
General = 3
|
||||
Labeling = 4
|
||||
Other = 5
|
||||
Rules = 6
|
||||
|
||||
|
||||
TAB_REGISTRY: Dict[str, type] = {}
|
||||
|
||||
|
||||
class TabRegistry(sip.wrappertype):
|
||||
|
||||
"""
|
||||
Analysis tab registry metaclass. This registers tabs to be used both for
|
||||
populating the content of the "choose analysis" dialog and also for
|
||||
saving tab/workspace info.
|
||||
"""
|
||||
|
||||
def __new__(cls, clsname, superclasses, attributedict):
|
||||
classdef = super().__new__(cls, clsname, superclasses, attributedict)
|
||||
|
||||
if clsname != "AnalysisTab":
|
||||
assert "section" in attributedict, "Class {} is missing the section value, " \
|
||||
"this is an setools bug".format(clsname)
|
||||
|
||||
assert "tab_title" in attributedict, "Class {} is missing the tab_title value, " \
|
||||
"this is an setools bug".format(clsname)
|
||||
|
||||
assert "mlsonly" in attributedict, "Class {} is missing the mlsonly value, " \
|
||||
"this is an setools bug".format(clsname)
|
||||
|
||||
# ensure there is no duplication of class name or title
|
||||
for existing_tabname, existing_class in TAB_REGISTRY.items():
|
||||
if existing_tabname == clsname:
|
||||
raise TypeError("Analysis tab {} conflicts with registered tab {}, "
|
||||
"this is an setools bug".format(clsname, existing_tabname))
|
||||
|
||||
if existing_class.tab_title == attributedict["tab_title"]:
|
||||
raise TypeError("Analysis tab {}'s title \"{}\" conflicts with registered tab "
|
||||
"{}, this is an setools bug.".
|
||||
format(clsname, attributedict["tab_title"], existing_tabname))
|
||||
|
||||
TAB_REGISTRY[clsname] = classdef
|
||||
|
||||
return classdef
|
||||
|
||||
|
||||
# pylint: disable=invalid-metaclass
|
||||
class AnalysisTab(SEToolsWidget, QScrollArea, metaclass=TabRegistry):
|
||||
|
||||
"""Base class for Apol analysis tabs."""
|
||||
|
||||
|
@ -27,7 +27,7 @@ from setools import BoolQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..boolmodel import BooleanTableModel, boolean_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class BoolQueryTab(AnalysisTab):
|
||||
|
||||
"""Bool browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Booleans"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(BoolQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import BoundsQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..boundsmodel import BoundsTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class BoundsQueryTab(AnalysisTab):
|
||||
|
||||
"""Bounds browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Other
|
||||
tab_title = "Bounds"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(BoundsQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import CategoryQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..mlsmodel import MLSComponentTableModel, category_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class CategoryQueryTab(AnalysisTab):
|
||||
|
||||
"""Category browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "MLS Categories"
|
||||
mlsonly = True
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(CategoryQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -16,68 +16,13 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
|
||||
|
||||
from ..widget import SEToolsWidget
|
||||
|
||||
# Analysis tabs:
|
||||
from .boolquery import BoolQueryTab
|
||||
from .boundsquery import BoundsQueryTab
|
||||
from .categoryquery import CategoryQueryTab
|
||||
from .commonquery import CommonQueryTab
|
||||
from .constraintquery import ConstraintQueryTab
|
||||
from .defaultquery import DefaultQueryTab
|
||||
from .dta import DomainTransitionAnalysisTab
|
||||
from .fsusequery import FSUseQueryTab
|
||||
from .genfsconquery import GenfsconQueryTab
|
||||
from .ibendportconquery import IbendportconQueryTab
|
||||
from .ibpkeyconquery import IbpkeyconQueryTab
|
||||
from .infoflow import InfoFlowAnalysisTab
|
||||
from .initsidquery import InitialSIDQueryTab
|
||||
from .mlsrulequery import MLSRuleQueryTab
|
||||
from .netifconquery import NetifconQueryTab
|
||||
from .nodeconquery import NodeconQueryTab
|
||||
from .objclassquery import ObjClassQueryTab
|
||||
from .portconquery import PortconQueryTab
|
||||
from .rbacrulequery import RBACRuleQueryTab
|
||||
from .rolequery import RoleQueryTab
|
||||
from .sensitivityquery import SensitivityQueryTab
|
||||
from .summary import SummaryTab
|
||||
from .terulequery import TERuleQueryTab
|
||||
from .typeattrquery import TypeAttributeQueryTab
|
||||
from .typequery import TypeQueryTab
|
||||
from .userquery import UserQueryTab
|
||||
|
||||
|
||||
# TODO: is there a better way than hardcoding this while still being safe?
|
||||
tab_map = {"BoolQueryTab": BoolQueryTab,
|
||||
"BoundsQueryTab": BoundsQueryTab,
|
||||
"CategoryQueryTab": CategoryQueryTab,
|
||||
"CommonQueryTab": CommonQueryTab,
|
||||
"ConstraintQueryTab": ConstraintQueryTab,
|
||||
"DefaultQueryTab": DefaultQueryTab,
|
||||
"DomainTransitionAnalysisTab": DomainTransitionAnalysisTab,
|
||||
"FSUseQueryTab": FSUseQueryTab,
|
||||
"GenfsconQueryTab": GenfsconQueryTab,
|
||||
"IbendportconQueryTab": IbendportconQueryTab,
|
||||
"IbpkeyconQueryTab": IbpkeyconQueryTab,
|
||||
"InfoFlowAnalysisTab": InfoFlowAnalysisTab,
|
||||
"InitialSIDQueryTab": InitialSIDQueryTab,
|
||||
"MLSRuleQueryTab": MLSRuleQueryTab,
|
||||
"NetifconQueryTab": NetifconQueryTab,
|
||||
"NodeconQueryTab": NodeconQueryTab,
|
||||
"ObjClassQueryTab": ObjClassQueryTab,
|
||||
"PortconQueryTab": PortconQueryTab,
|
||||
"RBACRuleQueryTab": RBACRuleQueryTab,
|
||||
"RoleQueryTab": RoleQueryTab,
|
||||
"SensitivityQueryTab": SensitivityQueryTab,
|
||||
"SummaryTab": SummaryTab,
|
||||
"TERuleQueryTab": TERuleQueryTab,
|
||||
"TypeAttributeQueryTab": TypeAttributeQueryTab,
|
||||
"TypeQueryTab": TypeQueryTab,
|
||||
"UserQueryTab": UserQueryTab}
|
||||
from .analysistab import AnalysisSection, AnalysisTab, TAB_REGISTRY
|
||||
|
||||
|
||||
class ChooseAnalysis(SEToolsWidget, QDialog):
|
||||
@ -93,54 +38,27 @@ class ChooseAnalysis(SEToolsWidget, QDialog):
|
||||
def __init__(self, parent):
|
||||
super(ChooseAnalysis, self).__init__(parent)
|
||||
self.parent = parent
|
||||
|
||||
# populate the analysis choices tree:
|
||||
self.analysis_choices = defaultdict(dict)
|
||||
for clsobj in TAB_REGISTRY.values():
|
||||
self.analysis_choices[clsobj.section.name][clsobj.tab_title] = clsobj
|
||||
|
||||
self.setupUi()
|
||||
|
||||
def setupUi(self):
|
||||
self.load_ui("apol/choose_analysis.ui")
|
||||
|
||||
def show(self, mls):
|
||||
analysis_map = {"Domain Transition Analysis": DomainTransitionAnalysisTab,
|
||||
"Information Flow Analysis": InfoFlowAnalysisTab}
|
||||
components_map = {"Booleans": BoolQueryTab,
|
||||
"Commons": CommonQueryTab,
|
||||
"Roles": RoleQueryTab,
|
||||
"Object Classes": ObjClassQueryTab,
|
||||
"Types": TypeQueryTab,
|
||||
"Type Attributes": TypeAttributeQueryTab,
|
||||
"Users": UserQueryTab}
|
||||
rule_map = {"Constraints": ConstraintQueryTab,
|
||||
"RBAC Rules": RBACRuleQueryTab,
|
||||
"TE Rules": TERuleQueryTab}
|
||||
labeling_map = {"Fs_use_* Statements": FSUseQueryTab,
|
||||
"Genfscon Statements": GenfsconQueryTab,
|
||||
"Infiniband Endport Contexts": IbendportconQueryTab,
|
||||
"Infiniband Partition Key Contexts": IbpkeyconQueryTab,
|
||||
"Initial SID Statements": InitialSIDQueryTab,
|
||||
"Network Interface Contexts": NetifconQueryTab,
|
||||
"Network Node Contexts": NodeconQueryTab,
|
||||
"Network Port Contexts": PortconQueryTab}
|
||||
general_choices = {"Summary": SummaryTab}
|
||||
other_choices = {"Bounds": BoundsQueryTab,
|
||||
"Defaults": DefaultQueryTab}
|
||||
analysis_choices = {"Components": components_map,
|
||||
"Rules": rule_map,
|
||||
"Analyses": analysis_map,
|
||||
"Labeling": labeling_map,
|
||||
"General": general_choices,
|
||||
"Other": other_choices}
|
||||
|
||||
if mls:
|
||||
rule_map["MLS Rules"] = MLSRuleQueryTab
|
||||
components_map["Categories"] = CategoryQueryTab
|
||||
components_map["Sensitivities"] = SensitivityQueryTab
|
||||
|
||||
# populate the item list:
|
||||
self.analysisTypes.clear()
|
||||
for groupname, group in analysis_choices.items():
|
||||
for groupname, group in self.analysis_choices.items():
|
||||
groupitem = QTreeWidgetItem(self.analysisTypes)
|
||||
groupitem.setText(0, groupname)
|
||||
groupitem._tab_class = None
|
||||
for entryname, cls in group.items():
|
||||
if cls.mlsonly and not mls:
|
||||
continue
|
||||
|
||||
item = QTreeWidgetItem(groupitem)
|
||||
item.setText(0, entryname)
|
||||
item._tab_class = cls
|
||||
|
@ -27,7 +27,7 @@ from setools import CommonQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..commonmodel import CommonTableModel, common_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class CommonQueryTab(AnalysisTab):
|
||||
|
||||
"""Common browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Common Permission Sets"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(CommonQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import ConstraintQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import PermListModel, SEToolsListModel, invert_list_selection
|
||||
from ..constraintmodel import ConstraintTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class ConstraintQueryTab(AnalysisTab):
|
||||
|
||||
"""A constraint query."""
|
||||
|
||||
section = AnalysisSection.Rules
|
||||
tab_title = "Constraints"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(ConstraintQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -28,7 +28,7 @@ from setools import DefaultQuery, DefaultValue, DefaultRangeValue
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..defaultmodel import DefaultTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_comboboxes, load_listviews, load_textedits, \
|
||||
save_checkboxes, save_comboboxes, save_listviews, save_textedits
|
||||
@ -38,6 +38,10 @@ class DefaultQueryTab(AnalysisTab):
|
||||
|
||||
"""Default browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Other
|
||||
tab_title = "Defaults"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(DefaultQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from PyQt5.QtWidgets import QCompleter, QHeaderView, QMessageBox, QProgressDialo
|
||||
from setools import DomainTransitionAnalysis
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .excludetypes import ExcludeTypes
|
||||
from .exception import TabFieldError
|
||||
from .workspace import load_checkboxes, load_spinboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class DomainTransitionAnalysisTab(AnalysisTab):
|
||||
|
||||
"""A domain transition analysis tab."""
|
||||
|
||||
section = AnalysisSection.Analysis
|
||||
tab_title = "Domain Transition Analysis"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(DomainTransitionAnalysisTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from setools import FSUseQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..fsusemodel import FSUseTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class FSUseQueryTab(AnalysisTab):
|
||||
|
||||
"""A fs_use_* rule query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Fs_use_* Statements"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(FSUseQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from setools import GenfsconQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..genfsconmodel import GenfsconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class GenfsconQueryTab(AnalysisTab):
|
||||
|
||||
"""A fs_use_* rule query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Genfscon Statements"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(GenfsconQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from setools import IbendportconQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..ibendportconmodel import IbendportconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class IbendportconQueryTab(AnalysisTab):
|
||||
|
||||
"""An ibendportcon query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Infiniband Endport Contexts"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super().__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from setools import IbpkeyconQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..ibpkeyconmodel import IbpkeyconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class IbpkeyconQueryTab(AnalysisTab):
|
||||
|
||||
"""An ibpkeycon query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Infiniband Partition Key Contexts"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super().__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -30,7 +30,7 @@ from setools import InfoFlowAnalysis
|
||||
from setools.exception import UnmappedClass, UnmappedPermission
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .excludetypes import ExcludeTypes
|
||||
from .permmapedit import PermissionMapEditor
|
||||
@ -42,6 +42,10 @@ class InfoFlowAnalysisTab(AnalysisTab):
|
||||
|
||||
"""An information flow analysis tab."""
|
||||
|
||||
section = AnalysisSection.Analysis
|
||||
tab_title = "Information Flow Analysis"
|
||||
mlsonly = False
|
||||
|
||||
@property
|
||||
def perm_map(self):
|
||||
return self.query.perm_map
|
||||
|
@ -26,7 +26,7 @@ from setools import InitialSIDQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..initsidmodel import InitialSIDTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class InitialSIDQueryTab(AnalysisTab):
|
||||
|
||||
"""An initial SID query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Initial SID Statements"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(InitialSIDQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -30,7 +30,8 @@ from setools import __version__, PermissionMap, SELinuxPolicy
|
||||
|
||||
from ..widget import SEToolsWidget
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from .chooseanalysis import ChooseAnalysis, tab_map
|
||||
from .analysistab import TAB_REGISTRY
|
||||
from .chooseanalysis import ChooseAnalysis
|
||||
from .config import ApolConfig
|
||||
from .exception import TabFieldError
|
||||
from .permmapedit import PermissionMapEditor
|
||||
@ -393,7 +394,7 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
|
||||
|
||||
if new:
|
||||
try:
|
||||
tabclass = tab_map[settings["__tab__"]]
|
||||
tabclass = TAB_REGISTRY[settings["__tab__"]]
|
||||
except KeyError:
|
||||
self.log.critical("Missing analysis type in \"{0}\"".format(filename))
|
||||
self.error_msg.critical(self, "Failed to load settings",
|
||||
@ -546,7 +547,7 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
|
||||
loading_errors = []
|
||||
for i, settings in enumerate(tab_list):
|
||||
try:
|
||||
tabclass = tab_map[settings["__tab__"]]
|
||||
tabclass = TAB_REGISTRY[settings["__tab__"]]
|
||||
except KeyError:
|
||||
error_str = "Missing analysis type for tab {0}. Skipping this tab.".format(i)
|
||||
self.log.error(error_str)
|
||||
|
@ -27,7 +27,7 @@ from setools import MLSRuleQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..mlsrulemodel import MLSRuleTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class MLSRuleQueryTab(AnalysisTab):
|
||||
|
||||
"""An MLS rule query."""
|
||||
|
||||
section = AnalysisSection.Rules
|
||||
tab_title = "MLS Rules"
|
||||
mlsonly = True
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(MLSRuleQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -26,7 +26,7 @@ from setools import NetifconQuery
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..netifconmodel import NetifconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -37,6 +37,10 @@ class NetifconQueryTab(AnalysisTab):
|
||||
|
||||
"""A netifcon query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Network Interface Contexts"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(NetifconQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import NodeconQuery, NodeconIPVersion
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..nodeconmodel import NodeconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, load_comboboxes, \
|
||||
@ -38,6 +38,10 @@ class NodeconQueryTab(AnalysisTab):
|
||||
|
||||
"""An nodecon query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Network Node Contexts"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(NodeconQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import ObjClassQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import PermListModel, SEToolsListModel, invert_list_selection
|
||||
from ..objclassmodel import ObjClassTableModel, class_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class ObjClassQueryTab(AnalysisTab):
|
||||
|
||||
"""ObjClass browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Object Classes"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(ObjClassQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import PortconQuery, PortconProtocol
|
||||
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..portconmodel import PortconTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, load_comboboxes, \
|
||||
@ -38,6 +38,10 @@ class PortconQueryTab(AnalysisTab):
|
||||
|
||||
"""An portcon query."""
|
||||
|
||||
section = AnalysisSection.Labeling
|
||||
tab_title = "Network Port Contexts"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(PortconQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import RBACRuleQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..rbacrulemodel import RBACRuleTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class RBACRuleQueryTab(AnalysisTab):
|
||||
|
||||
"""A RBAC rule query."""
|
||||
|
||||
section = AnalysisSection.Rules
|
||||
tab_title = "RBAC Rules"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(RBACRuleQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import RoleQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..rolemodel import RoleTableModel, role_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class RoleQueryTab(AnalysisTab):
|
||||
|
||||
"""Role browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Roles"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(RoleQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import SensitivityQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..mlsmodel import MLSComponentTableModel, sensitivity_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class SensitivityQueryTab(AnalysisTab):
|
||||
|
||||
"""Sensitivity browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "MLS Sensitivities"
|
||||
mlsonly = True
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(SensitivityQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -28,7 +28,7 @@ from setools import MLSRuleQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..mlsrulemodel import MLSRuleTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_textedits, save_checkboxes, save_textedits
|
||||
|
||||
@ -37,6 +37,10 @@ class SummaryTab(AnalysisTab):
|
||||
|
||||
"""An SELinux policy summary."""
|
||||
|
||||
section = AnalysisSection.General
|
||||
tab_title = "Summary"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(SummaryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import TERuleQuery, xperm_str_to_tuple_ranges
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import PermListModel, SEToolsListModel, invert_list_selection
|
||||
from ..terulemodel import TERuleTableModel
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class TERuleQueryTab(AnalysisTab):
|
||||
|
||||
"""A Type Enforcement rule query."""
|
||||
|
||||
section = AnalysisSection.Rules
|
||||
tab_title = "TE Rules"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(TERuleQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import TypeAttributeQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..typeattrmodel import TypeAttributeTableModel, typeattr_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class TypeAttributeQueryTab(AnalysisTab):
|
||||
|
||||
"""TypeAttribute browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Type Attributes"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(TypeAttributeQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import TypeQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..typemodel import TypeTableModel, type_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class TypeQueryTab(AnalysisTab):
|
||||
|
||||
"""Type browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Types"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(TypeQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
@ -27,7 +27,7 @@ from setools import UserQuery
|
||||
from ..logtosignal import LogHandlerToSignal
|
||||
from ..models import SEToolsListModel, invert_list_selection
|
||||
from ..usermodel import UserTableModel, user_detail
|
||||
from .analysistab import AnalysisTab
|
||||
from .analysistab import AnalysisSection, AnalysisTab
|
||||
from .exception import TabFieldError
|
||||
from .queryupdater import QueryResultsUpdater
|
||||
from .workspace import load_checkboxes, load_lineedits, load_listviews, load_textedits, \
|
||||
@ -38,6 +38,10 @@ class UserQueryTab(AnalysisTab):
|
||||
|
||||
"""User browser and query tab."""
|
||||
|
||||
section = AnalysisSection.Components
|
||||
tab_title = "Users"
|
||||
mlsonly = False
|
||||
|
||||
def __init__(self, parent, policy, perm_map):
|
||||
super(UserQueryTab, self).__init__(parent)
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
Loading…
Reference in New Issue
Block a user