mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-11 07:18:15 +00:00
apol: Fix model headers so extra columns aren't added.
The section number (column header) is -1 when the section is hidden. The defaultdict use would cause extra columns to be created since the column count is based on the size of the headers object and -1 would add a new entry. Change headers to lists.
This commit is contained in:
parent
7c540405ea
commit
da8a238ffc
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -45,7 +43,7 @@ class BooleanTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for booleans."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Default State"})
|
||||
headers = ["Name", "Default State"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class BoundsTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for *bounds."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Parent", 2: "Child"})
|
||||
headers = ["Rule Type", "Parent", "Child"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -49,7 +47,7 @@ class CommonTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for common permission sets."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Permissions"})
|
||||
headers = ["Name", "Permissions"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from setools.policyrep.exception import ConstraintUseError
|
||||
|
||||
@ -28,7 +26,7 @@ class ConstraintTableModel(SEToolsTableModel):
|
||||
|
||||
"""A table-based model for constraints."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Class", 2: "Permissions", 3: "Expression"})
|
||||
headers = ["Rule Type", "Class", "Permissions", "Expression"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class DefaultTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for default_*."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Class", 2: "Default", 3: "Default Range"})
|
||||
headers = ["Rule Type", "Class", "Default", "Default Range"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class FSUseTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for fs_use_*."""
|
||||
|
||||
headers = defaultdict(str, {0: "Ruletype", 1: "FS Type", 2: "Context"})
|
||||
headers = ["Ruletype", "FS Type", "Context"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -17,7 +17,6 @@
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import stat
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
@ -28,8 +27,7 @@ class GenfsconTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for genfscons."""
|
||||
|
||||
headers = defaultdict(str, {0: "FS Type", 1: "Path",
|
||||
2: "File Type", 3: "Context"})
|
||||
headers = ["FS Type", "Path", "File Type", "Context"]
|
||||
|
||||
_filetype_to_text = {
|
||||
0: "Any",
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class InitialSIDTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for initial SIDs."""
|
||||
|
||||
headers = defaultdict(str, {0: "SID", 1: "Context"})
|
||||
headers = ["SID", "Context"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -70,7 +68,7 @@ class MLSComponentTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for sensitivities and categories."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Aliases"})
|
||||
headers = ["Name", "Aliases"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,8 +25,7 @@ class MLSRuleTableModel(SEToolsTableModel):
|
||||
|
||||
"""A table-based model for MLS rules."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Source", 2: "Target",
|
||||
3: "Object Class", 4: "Default Range"})
|
||||
headers = ["Rule Type", "Source", "Target", "Object Class", "Default Range"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -17,7 +17,6 @@
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import QAbstractListModel, QItemSelectionModel, QAbstractTableModel, \
|
||||
QModelIndex, QStringListModel, Qt
|
||||
@ -142,7 +141,7 @@ class SEToolsTableModel(QAbstractTableModel):
|
||||
|
||||
"""Base class for SETools table models."""
|
||||
|
||||
headers = defaultdict(str)
|
||||
headers = []
|
||||
|
||||
def __init__(self, parent):
|
||||
super(SEToolsTableModel, self).__init__(parent)
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class NetifconTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for netifcons."""
|
||||
|
||||
headers = defaultdict(str, {0: "Device", 1: "Device Context", 2: "Packet Context"})
|
||||
headers = ["Device", "Device Context", "Packet Context"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class NodeconTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for nodecons."""
|
||||
|
||||
headers = defaultdict(str, {0: "Network", 1: "Context"})
|
||||
headers = ["Network", "Context"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,7 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
from itertools import chain
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
@ -64,7 +63,7 @@ class ObjClassTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for object classes."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Permissions"})
|
||||
headers = ["Name", "Permissions"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from .models import SEToolsTableModel
|
||||
@ -27,7 +25,7 @@ class PortconTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for portcons."""
|
||||
|
||||
headers = defaultdict(str, {0: "Port/Port Range", 1: "Protocol", 2: "Context"})
|
||||
headers = ["Port/Port Range", "Protocol", "Context"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from setools.policyrep.exception import RuleUseError
|
||||
|
||||
@ -28,8 +26,7 @@ class RBACRuleTableModel(SEToolsTableModel):
|
||||
|
||||
"""A table-based model for RBAC rules."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Source", 2: "Target",
|
||||
3: "Object Class", 4: "Default Role"})
|
||||
headers = ["Rule Type", "Source", "Target", "Object Class", "Default Role"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -51,7 +49,7 @@ class RoleTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for roles."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Types"})
|
||||
headers = ["Name", "Types"]
|
||||
|
||||
def data(self, index, role):
|
||||
# There are two roles here.
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from setools.policyrep.exception import RuleNotConditional, RuleUseError
|
||||
|
||||
@ -28,9 +26,8 @@ class TERuleTableModel(SEToolsTableModel):
|
||||
|
||||
"""A table-based model for TE rules."""
|
||||
|
||||
headers = defaultdict(str, {0: "Rule Type", 1: "Source", 2: "Target",
|
||||
3: "Object Class", 4: "Permissions/Default Type",
|
||||
5: "Conditional Expression", 6: "Conditional Block"})
|
||||
headers = ["Rule Type", "Source", "Target", "Object Class", "Permissions/Default Type",
|
||||
"Conditional Expression", "Conditional Block"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -51,7 +49,7 @@ class TypeAttributeTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for roles."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Types"})
|
||||
headers = ["Name", "Types"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPalette, QTextCursor
|
||||
|
||||
@ -57,7 +55,7 @@ class TypeTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for types."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Attributes", 2: "Aliases", 3: "Permissive"})
|
||||
headers = ["Name", "Attributes", "Aliases", "Permissive"]
|
||||
|
||||
def data(self, index, role):
|
||||
if self.resultlist and index.isValid():
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License along with SETools. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.QtCore import Qt, QModelIndex
|
||||
from setools.policyrep.exception import MLSDisabled
|
||||
|
||||
@ -60,7 +58,7 @@ class UserTableModel(SEToolsTableModel):
|
||||
|
||||
"""Table-based model for users."""
|
||||
|
||||
headers = defaultdict(str, {0: "Name", 1: "Roles", 2: "Default Level", 3: "Range"})
|
||||
headers = ["Name", "Roles", "Default Level", "Range"]
|
||||
|
||||
def __init__(self, parent, mls):
|
||||
super(UserTableModel, self).__init__(parent)
|
||||
|
Loading…
Reference in New Issue
Block a user