Skip to content

Commit e51eeae

Browse files
authored
Merge pull request #158 from pebenito/seinfo-improvements
Seinfo improvements
2 parents d575f0b + ab9ea42 commit e51eeae

21 files changed

Lines changed: 276 additions & 166 deletions

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- {python: '3.10', tox: python3}
3131
- {python: '3.11', tox: python3}
3232
- {python: '3.12', tox: python3}
33+
- {python: '3.13', tox: python3}
3334
- {python: '3.11', tox: pep8}
3435
- {python: '3.11', tox: lint}
3536
- {python: '3.11', tox: mypy}
@@ -41,7 +42,7 @@ jobs:
4142

4243
# This should be the minimum required Python version to build refpolicy.
4344
- name: Set up Python ${{ matrix.build-opts.python }}
44-
uses: actions/setup-python@v4
45+
uses: actions/setup-python@v6
4546
with:
4647
python-version: ${{ matrix.build-opts.python }}
4748

seinfo

Lines changed: 165 additions & 110 deletions
Large diffs are not rendered by default.

setools/devicetreeconquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class DevicetreeconQuery(mixins.MatchContext, query.PolicyQuery):
4444
No effect if not using set operations.
4545
"""
4646

47+
required_platform = policyrep.PolicyTarget.xen
48+
4749
path: str | None = None
4850

4951
def results(self) -> Iterable[policyrep.Devicetreecon]:

setools/exception.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ class MLSDisabled(PolicyrepException):
4949
pass
5050

5151

52+
class PlatformMismatch(ValueError, PolicyrepException):
53+
54+
"""
55+
Exception when the policy platform does not match the requested
56+
platform. For example a Xen policy is loaded, but a query
57+
requiring SELinux is attempted.
58+
"""
59+
pass
60+
61+
5262
#
5363
# Invalid component exceptions
5464
#

setools/fsusequery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class FSUseQuery(mixins.MatchContext, query.PolicyQuery):
4444
No effect if not using set operations.
4545
"""
4646

47+
required_platform = policyrep.PolicyTarget.selinux
48+
4749
ruletype = CriteriaSetDescriptor[policyrep.FSUseRuletype](enum_class=policyrep.FSUseRuletype)
4850
fs = CriteriaDescriptor[str]("fs_regex")
4951
fs_regex: bool = False

setools/genfsconquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class GenfsconQuery(mixins.MatchContext, query.PolicyQuery):
4646
No effect if not using set operations.
4747
"""
4848

49+
required_platform = policyrep.PolicyTarget.selinux
50+
4951
filetype: int | None = None
5052
fs = CriteriaDescriptor[str]("fs_regex")
5153
fs_regex: bool = False

setools/ibendportconquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class IbendportconQuery(mixins.MatchContext, mixins.MatchName, query.PolicyQuery
4343
No effect if not using set operations.
4444
"""
4545

46+
required_platform = policyrep.PolicyTarget.selinux
47+
4648
_port: int | None = None
4749

4850
@property

setools/ibpkeyconquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class IbpkeyconQuery(mixins.MatchContext, query.PolicyQuery):
5151
No effect if not using set operations.
5252
"""
5353

54+
required_platform = policyrep.PolicyTarget.selinux
55+
5456
_subnet_prefix: IPv6Address | None = None
5557
_pkeys: policyrep.IbpkeyconRange | None = None
5658
pkeys_subset: bool = False

setools/initsidquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class InitialSIDQuery(mixins.MatchName, mixins.MatchContext, query.PolicyQuery):
4242
No effect if not using set operations.
4343
"""
4444

45+
required_platform = policyrep.PolicyTarget.selinux
46+
4547
def results(self) -> Iterable[policyrep.InitialSID]:
4648
"""Generator which yields all matching initial SIDs."""
4749
self.log.info(f"Generating initial SID results from {self.policy}")

setools/iomemconquery.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class IomemconQuery(mixins.MatchContext, query.PolicyQuery):
5353
No effect if not using set operations.
5454
"""
5555

56+
required_platform = policyrep.PolicyTarget.xen
57+
5658
_addr: policyrep.IomemconRange | None = None
5759
addr_subset: bool = False
5860
addr_overlap: bool = False
@@ -64,11 +66,11 @@ def addr(self) -> policyrep.IomemconRange | None:
6466
return self._addr
6567

6668
@addr.setter
67-
def addr(self, value: tuple[int, int] | None) -> None:
68-
if value:
69-
self._addr = policyrep.IomemconRange(*value)
69+
def addr(self, value: policyrep.IomemconRange | tuple[int, int] | None) -> None:
70+
if isinstance(value, policyrep.IomemconRange):
71+
self._addr = value
7072
else:
71-
self._addr = None
73+
self._addr = policyrep.IomemconRange(*value) if value else None
7274

7375
def results(self) -> Iterable[policyrep.Iomemcon]:
7476
"""Generator which yields all matching iomemcons."""

0 commit comments

Comments
 (0)