From 263b588a6d8926812d13aa100ab635e0af903898 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 13:46:17 -0500 Subject: [PATCH 1/6] TabRegistry: Switch __new__() use to *args, **kwargs. This fixes a pylint issue. Signed-off-by: Chris PeBenito --- setoolsgui/apol/analysistab.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setoolsgui/apol/analysistab.py b/setoolsgui/apol/analysistab.py index a85529b..1ed8034 100644 --- a/setoolsgui/apol/analysistab.py +++ b/setoolsgui/apol/analysistab.py @@ -35,9 +35,11 @@ class TabRegistry(sip.wrappertype): saving tab/workspace info. """ - def __new__(cls, clsname, superclasses, attributedict): - classdef = super().__new__(cls, clsname, superclasses, attributedict) + def __new__(cls, *args, **kwargs): + classdef = super().__new__(cls, *args, **kwargs) + clsname = args[0] + attributedict = args[2] if clsname != "AnalysisTab": assert "section" in attributedict, "Class {} is missing the section value, " \ "this is an setools bug".format(clsname) From 6a00d5d5f35fd28a511513765e03714c40670dd2 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 13:48:00 -0500 Subject: [PATCH 2/6] PermissionMap: Fix error in __deepcopy__(). Signed-off-by: Chris PeBenito --- setools/permmap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setools/permmap.py b/setools/permmap.py index 4cadb02..728ea87 100644 --- a/setools/permmap.py +++ b/setools/permmap.py @@ -115,8 +115,8 @@ class PermissionMap: def __deepcopy__(self, memo) -> 'PermissionMap': newobj = PermissionMap.__new__(PermissionMap) newobj.log = self.log - newobj.permmap = copy.deepcopy(self._permmap) - newobj.permmapfile = self._permmapfile + newobj._permmap = copy.deepcopy(self._permmap) + newobj._permmapfile = self._permmapfile memo[id(self)] = newobj return newobj From ee214122340e21e72d45f47aae6d8c9ead26a68a Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 14:26:06 -0500 Subject: [PATCH 3/6] policyrep.pyi: Remove incorrect attribute overrides. This fixes mypy issues. Signed-off-by: Chris PeBenito --- setools/policyrep.pyi | 84 ------------------------------------------- 1 file changed, 84 deletions(-) diff --git a/setools/policyrep.pyi b/setools/policyrep.pyi index 68a7ac5..7b31be8 100644 --- a/setools/policyrep.pyi +++ b/setools/policyrep.pyi @@ -139,12 +139,6 @@ class Bounds(PolicyObject): def __setstate__(self, state) -> Any: ... class BoundsRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... typebounds: int = ... class Category(PolicySymbol): @@ -337,12 +331,6 @@ class ConstraintIterator(PolicyIterator): def __setstate__(self, state) -> Any: ... class ConstraintRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... constrain: int = ... mlsconstrain: int = ... mlsvalidatetrans: int = ... @@ -397,12 +385,6 @@ class DefaultRange(Default): def __setstate__(self, state) -> Any: ... class DefaultRangeValue(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... high: int = ... low: int = ... low_high: int = ... @@ -410,24 +392,12 @@ class DefaultRangeValue(PolicyEnum): def from_default_range(self, range: Optional[int]) -> Optional[DefaultRangeValue]: ... class DefaultRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... default_range: int = ... default_role: int = ... default_type: int = ... default_user: int = ... class DefaultValue(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... glblub: int = ... source: int = ... target: int = ... @@ -486,12 +456,6 @@ class FSUseIterator(OcontextIterator): def __setstate__(self, state) -> Any: ... class FSUseRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... fs_use_task: int = ... fs_use_trans: int = ... fs_use_xattr: int = ... @@ -573,12 +537,6 @@ class GenfsconOcontextIterator(OcontextIterator): def __setstate__(self, state) -> Any: ... class HandleUnknown(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... allow: int = ... deny: int = ... reject: int = ... @@ -867,12 +825,6 @@ class MLSRuleIterator(HashtabIterator): def __setstate__(self, state) -> Any: ... class MLSRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... range_transition: int = ... class Netifcon(Ocontext): @@ -924,12 +876,6 @@ class Nodecon(Ocontext): def __setstate__(self, state) -> Any: ... class NodeconIPVersion(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... ipv4: int = ... ipv6: int = ... @@ -1047,12 +993,6 @@ class PolicyCapabilityIterator(EbitmapIterator): def __setstate__(self, state) -> Any: ... class PolicyEnum(enum.Enum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... @classmethod def lookup(self, value) -> Any: ... def __eq__(self, other) -> bool: ... @@ -1112,12 +1052,6 @@ class PolicySymbol(PolicyObject): def __setstate__(self, state) -> Any: ... class PolicyTarget(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... selinux: int = ... xen: int = ... @@ -1147,12 +1081,6 @@ class PortconIterator(OcontextIterator): def __setstate__(self, state) -> Any: ... class PortconProtocol(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... dccp: int = ... sctp: int = ... tcp: int = ... @@ -1173,12 +1101,6 @@ class PortconRange(Tuple[int, int]): def _make(self, *args, **kwargs) -> Any: ... class RBACRuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... allow: int = ... role_transition: int = ... @@ -1460,12 +1382,6 @@ class TERuleIterator(PolicyIterator): class TERuleNoFilename(AttributeError, setools.exception.PolicyrepException): ... class TERuletype(PolicyEnum): - __new__: Any = ... - _generate_next_value_: Any = ... - _member_map_: Any = ... - _member_names_: Any = ... - _member_type_: Any = ... - _value2member_map_: Any = ... allow: int = ... allowxperm: int = ... auditallow: int = ... From f1e003502919339a62bf829d6b576a03a9e57720 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 14:43:41 -0500 Subject: [PATCH 4/6] CriteriaDescriptor: Fix typing for enum_class keyword parameter. Signed-off-by: Chris PeBenito --- setools/descriptors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setools/descriptors.py b/setools/descriptors.py index 2bf2256..40936fd 100644 --- a/setools/descriptors.py +++ b/setools/descriptors.py @@ -18,7 +18,7 @@ from abc import ABC, abstractmethod from collections import defaultdict from collections.abc import Collection from enum import Enum -from typing import Any, Callable, MutableMapping, Optional, Union +from typing import Any, Callable, MutableMapping, Optional, Type, Union from weakref import WeakKeyDictionary from .util import validate_perms_any @@ -57,7 +57,7 @@ class CriteriaDescriptor: def __init__(self, name_regex: Optional[str] = None, lookup_function: Optional[Union[Callable, str]] = None, - default_value=None, enum_class: Optional[Enum] = None) -> None: + default_value=None, enum_class: Optional[Type[Enum]] = None) -> None: assert name_regex or lookup_function or enum_class, \ "A simple attribute should be used if there is no regex, lookup function, or enum." From fc0aadf3ae7b6765c72703bf0342e72a6f6536c7 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 14:52:50 -0500 Subject: [PATCH 5/6] tests.yml: Update GitHub actions versions. Signed-off-by: Chris PeBenito --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bef60c1..2a6a5e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,11 +24,11 @@ jobs: #- {python: 3.6, tox: coverage} 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 }} From c0d0f0d3b8df73017c391798dbd2c245e78658e7 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Wed, 30 Nov 2022 14:56:00 -0500 Subject: [PATCH 6/6] tests.yml: Add Python 3.10 and 3.11 CI tests. Signed-off-by: Chris PeBenito --- .github/workflows/tests.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2a6a5e8..16ae6af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,14 +14,16 @@ jobs: matrix: build-opts: - - {python: 3.6, tox: py36} - - {python: 3.7, tox: py37} - - {python: 3.8, tox: py38} - - {python: 3.9, tox: py39} - - {python: 3.6, tox: pep8} - - {python: 3.6, tox: lint} - - {python: 3.6, tox: mypy} - #- {python: 3.6, tox: coverage} + - {python: '3.6', tox: py36} + - {python: '3.7', tox: py37} + - {python: '3.8', tox: py38} + - {python: '3.9', tox: py39} + - {python: '3.10', tox: py310} + - {python: '3.11', tox: py311} + - {python: '3.6', tox: pep8} + - {python: '3.6', tox: lint} + - {python: '3.6', tox: mypy} + #- {python: '3.6', tox: coverage} steps: - uses: actions/checkout@v3