Skip to content

Commit

Permalink
Merge pull request #115 from pebenito/4.4
Browse files Browse the repository at this point in the history
Backport fixes for 4.4.4.
  • Loading branch information
pebenito authored Dec 7, 2023
2 parents d3dbddb + ee13b8a commit a04b015
Show file tree
Hide file tree
Showing 65 changed files with 237 additions and 224 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,21 @@ jobs:

matrix:
build-opts:
- {python: '3.6', tox: python3.6}
- {python: '3.7', tox: python3.7}
- {python: '3.8', tox: python3.8}
- {python: '3.9', tox: python3.9}
- {python: '3.10', tox: python3.10}
- {python: '3.11', tox: python3.11}
- {python: '3.6', tox: pep8}
- {python: '3.6', tox: lint}
- {python: '3.6', tox: mypy}
- {python: '3.6', tox: coverage}
- {python: '3.6', tox: install}
- {python: '3.11', tox: pep8}
- {python: '3.11', tox: lint}
- {python: '3.11', tox: mypy}
- {python: '3.11', tox: coverage}
- {python: '3.11', tox: install}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# This should be the minimum required Python version to build refpolicy.
- name: Set up Python ${{ matrix.build-opts.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.build-opts.python }}

Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*setools-4-4.4 (07 Dec 2023)
* Update for compiling with libsepol 3.6.
* Update apol to use fully specified PyQt enums.
* Correct minor code lint issues.

*setools-4-4.3 (27 Jul 2023)
* Fix compilation with Cython 3.0.0.
* Improve man pages.
Expand Down
10 changes: 5 additions & 5 deletions setools/diff/difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ class Wrapper(ABC, Generic[T]):

__slots__ = ("origin", "key")

def __init__(self, symbol: T) -> None:
pass
def __init__(self, origin: T, key: int) -> None:
self.origin = origin
self.key = key

def __repr__(self):
# pylint: disable=no-member
Expand Down Expand Up @@ -168,9 +169,8 @@ class SymbolWrapper(Wrapper[S]):
__slots__ = ("name",)

def __init__(self, symbol: S) -> None:
self.origin = symbol
self.name = str(symbol)
self.key = hash(self.name)
super().__init__(symbol, hash(symbol.name))
self.name = symbol.name

def __hash__(self):
return self.key
Expand Down
2 changes: 1 addition & 1 deletion setools/policyrep/boolcond.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ cdef class ConditionalExprIterator(PolicyIterator):

if self.curr.expr_type == sepol.COND_BOOL:
item = Boolean.factory(self.policy,
self.policy.boolean_value_to_datum(self.curr.bool - 1))
self.policy.boolean_value_to_datum(self.curr.boolean - 1))
else:
item = ConditionalOperator.factory(self.policy, self.curr)

Expand Down
3 changes: 1 addition & 2 deletions setools/policyrep/selinuxpolicy.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,7 @@ cdef class SELinuxPolicy:
"""

cdef:
size_t i, count
int bit
size_t bit, i, count
sepol.ebitmap_node_t *node = NULL
sepol.type_datum_t *tmp_type
char *tmp_name
Expand Down
10 changes: 9 additions & 1 deletion setools/policyrep/sepol.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ cdef extern from "<sepol/policydb/sidtab.h>":


cdef extern from "<sepol/policydb/conditional.h>":
"""
#if defined(COND_EXPR_T_RENAME_BOOL_BOOLEAN)
#define COND_EXPR_T_RENAME_BOOL_NAME boolean
#else
#define COND_EXPR_T_RENAME_BOOL_NAME bool
#endif
"""

cdef int COND_EXPR_MAXDEPTH
cdef int COND_MAX_BOOLS

Expand All @@ -309,7 +317,7 @@ cdef extern from "<sepol/policydb/conditional.h>":

cdef struct cond_expr:
uint32_t expr_type
uint32_t bool
uint32_t boolean "COND_EXPR_T_RENAME_BOOL_NAME"
cond_expr *next

ctypedef cond_expr cond_expr_t
Expand Down
2 changes: 1 addition & 1 deletion setoolsgui/apol/analysistab.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def clear_criteria_error(self, field, tooltip):
self._check_query()

def _check_query(self):
button = self.buttonBox.button(QDialogButtonBox.Apply)
button = self.buttonBox.button(QDialogButtonBox.StandardButton.Apply)
enabled = not self.errors
button.setEnabled(enabled)
button.setToolTip("Run the analysis." if enabled else "There are errors in the tab.")
Expand Down
8 changes: 4 additions & 4 deletions setoolsgui/apol/boolquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(0, Qt.AscendingOrder)
self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)

# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()

# set up processing thread
Expand Down Expand Up @@ -105,7 +105,7 @@ def setupUi(self):
def get_detail(self):
# .ui is set for single item selection.
index = self.bools.selectedIndexes()[0]
item = self.bool_model.data(index, Qt.UserRole)
item = self.bool_model.data(index, Qt.ItemDataRole.UserRole)

self.log.debug("Generating detail window for {0}".format(item))
boolean_detail(self, item)
Expand Down Expand Up @@ -187,6 +187,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
6 changes: 3 additions & 3 deletions setoolsgui/apol/boundsquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(1, Qt.AscendingOrder)
self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)

# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.parent.palette()
self.error_palette = self.parent.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_parent_error()
self.clear_child_error()

Expand Down Expand Up @@ -189,6 +189,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
8 changes: 4 additions & 4 deletions setoolsgui/apol/categoryquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(0, Qt.AscendingOrder)
self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)

# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()

# set up processing thread
Expand Down Expand Up @@ -105,7 +105,7 @@ def setupUi(self):
def get_detail(self):
# .ui is set for single item selection.
index = self.cats.selectedIndexes()[0]
item = self.category_model.data(index, Qt.UserRole)
item = self.category_model.data(index, Qt.ItemDataRole.UserRole)

self.log.debug("Generating detail window for {0}".format(item))
category_detail(self, item)
Expand Down Expand Up @@ -186,6 +186,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
2 changes: 1 addition & 1 deletion setoolsgui/apol/chooseanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def show(self, mls):
groupitem.addChild(item)

self.analysisTypes.expandAll()
self.analysisTypes.sortByColumn(0, Qt.AscendingOrder)
self.analysisTypes.sortByColumn(0, Qt.SortOrder.AscendingOrder)
super(ChooseAnalysis, self).show()

def accept(self, item=None):
Expand Down
10 changes: 5 additions & 5 deletions setoolsgui/apol/commonquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(0, Qt.AscendingOrder)
self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)

# setup indications of errors
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()

# set up processing thread
Expand Down Expand Up @@ -116,7 +116,7 @@ def setupUi(self):
def get_detail(self):
# .ui is set for single item selection.
index = self.commons.selectedIndexes()[0]
item = self.common_model.data(index, Qt.UserRole)
item = self.common_model.data(index, Qt.ItemDataRole.UserRole)

self.log.debug("Generating detail window for {0}".format(item))
common_detail(self, item)
Expand Down Expand Up @@ -146,7 +146,7 @@ def set_name_regex(self, state):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
selected_perms.append(self.perms_model.data(index, Qt.UserRole))
selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))

self.query.perms = selected_perms

Expand Down Expand Up @@ -212,6 +212,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
10 changes: 5 additions & 5 deletions setoolsgui/apol/constraintquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setupUi(self):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_user_error()
self.clear_type_error()
self.clear_role_error()
Expand All @@ -94,7 +94,7 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(0, Qt.AscendingOrder)
self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)

# set up processing thread
self.thread = QThread()
Expand Down Expand Up @@ -173,7 +173,7 @@ def clear_all_ruletypes(self):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
selected_classes.append(self.class_model.data(index, Qt.UserRole))
selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))

self.query.tclass = selected_classes
self.perms_model.set_classes(selected_classes)
Expand All @@ -187,7 +187,7 @@ def invert_tclass_selection(self):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
selected_perms.append(self.perms_model.data(index, Qt.UserRole))
selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))

self.query.perms = selected_perms

Expand Down Expand Up @@ -323,6 +323,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
11 changes: 6 additions & 5 deletions setoolsgui/apol/defaultquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setupUi(self):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
self.table_results.sortByColumn(1, Qt.AscendingOrder)
self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)

# populate class list
self.class_model = SEToolsListModel(self)
Expand Down Expand Up @@ -124,7 +124,7 @@ def clear_all_ruletypes(self):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
selected_classes.append(self.class_model.data(index, Qt.UserRole))
selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))

self.query.tclass = selected_classes

Expand Down Expand Up @@ -163,10 +163,11 @@ def run(self, button):
rule_types.append(mode.objectName())

self.query.ruletype = rule_types
self.query.default = self.default_value.currentData(Qt.UserRole)
self.query.default = self.default_value.currentData(Qt.ItemDataRole.UserRole)

if self.default_range_value.isEnabled():
self.query.default_range = self.default_range_value.currentData(Qt.UserRole)
self.query.default_range = self.default_range_value.currentData(
Qt.ItemDataRole.UserRole)
else:
self.query.default_range = None

Expand All @@ -193,6 +194,6 @@ def update_complete(self, count):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

self.busy.reset()
6 changes: 3 additions & 3 deletions setoolsgui/apol/dta.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setupUi(self):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
self.error_palette.setColor(QPalette.Base, Qt.red)
self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()

Expand Down Expand Up @@ -281,7 +281,7 @@ def browser_item_selected(self, current, previous):

print_transition(self.browser_details.appendPlainText, current.rules)

self.browser_details.moveCursor(QTextCursor.Start)
self.browser_details.moveCursor(QTextCursor.MoveOperation.Start)

if not current.child_populated:
self.busy.setLabelText("Gathering additional browser details for {0}...".format(
Expand Down Expand Up @@ -337,7 +337,7 @@ def update_complete(self):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
self.raw_results.moveCursor(QTextCursor.Start)
self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)

if self.flows_in.isChecked() or self.flows_out.isChecked():
# move to browser tab for transitions in/out
Expand Down
Loading

0 comments on commit a04b015

Please sign in to comment.