sayfirst-testing 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sayfirst_testing/__init__.py +6 -0
- sayfirst_testing/account_directory_contract.py +95 -0
- sayfirst_testing/clock_contract.py +49 -0
- sayfirst_testing/decision_store_contract.py +142 -0
- sayfirst_testing/doubles.py +121 -0
- sayfirst_testing/guard_gates.py +145 -0
- sayfirst_testing/peer_identity_contract.py +72 -0
- sayfirst_testing/platforms.py +56 -0
- sayfirst_testing/policy_archive_contract.py +87 -0
- sayfirst_testing/policy_projection_contract.py +40 -0
- sayfirst_testing/policy_store_contract.py +40 -0
- sayfirst_testing/privileges.py +74 -0
- sayfirst_testing/schemas.py +107 -0
- sayfirst_testing-0.3.0.dist-info/METADATA +29 -0
- sayfirst_testing-0.3.0.dist-info/RECORD +18 -0
- sayfirst_testing-0.3.0.dist-info/WHEEL +4 -0
- sayfirst_testing-0.3.0.dist-info/licenses/LICENSE +202 -0
- sayfirst_testing-0.3.0.dist-info/licenses/NOTICE +12 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""The contract of the AccountDirectory port, run against every provider.
|
|
3
|
+
|
|
4
|
+
Article 8: a provider that does not pass this suite is not a provider. The
|
|
5
|
+
suite asks only what the port promises — that ids resolve to names and
|
|
6
|
+
memberships, that an id with no entry is `None` and never an invented one,
|
|
7
|
+
and that the answers are the directory's own words.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Protocol
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _Directory(Protocol):
|
|
16
|
+
VERSION: int
|
|
17
|
+
|
|
18
|
+
def account(self, uid: int): ... # type: ignore[no-untyped-def]
|
|
19
|
+
|
|
20
|
+
def group_ids(self, name: str, primary_gid: int) -> tuple[int, ...]: ...
|
|
21
|
+
|
|
22
|
+
def group_name(self, gid: int) -> str | None: ...
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def assert_the_port_is_versioned(directory: _Directory) -> None:
|
|
26
|
+
"""Article 8: a port carries an integer version, and so does its provider."""
|
|
27
|
+
assert isinstance(directory.VERSION, int)
|
|
28
|
+
assert not isinstance(directory.VERSION, bool)
|
|
29
|
+
assert directory.VERSION >= 1
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def assert_a_known_account_resolves(directory: _Directory, uid: int, name: str) -> None:
|
|
33
|
+
"""A uid the host knows is answered with its name and its primary group."""
|
|
34
|
+
account = directory.account(uid)
|
|
35
|
+
assert account is not None, f"uid {uid} has no account"
|
|
36
|
+
assert account.name == name
|
|
37
|
+
assert isinstance(account.primary_gid, int)
|
|
38
|
+
assert account.primary_gid >= 0
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def assert_an_unknown_id_is_none(directory: _Directory, absent_uid: int, absent_gid: int) -> None:
|
|
42
|
+
"""No entry is `None`, never a fabricated account and never an exception.
|
|
43
|
+
|
|
44
|
+
Article 2: the directory saying nothing about an id is its own answer.
|
|
45
|
+
"""
|
|
46
|
+
assert directory.account(absent_uid) is None
|
|
47
|
+
assert directory.group_name(absent_gid) is None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def assert_a_membership_includes_its_primary_group(
|
|
51
|
+
directory: _Directory, name: str, primary_gid: int
|
|
52
|
+
) -> None:
|
|
53
|
+
"""Rule G1: the primary group is a membership, listed with the others."""
|
|
54
|
+
gids = directory.group_ids(name, primary_gid)
|
|
55
|
+
assert isinstance(gids, tuple)
|
|
56
|
+
assert all(isinstance(gid, int) for gid in gids)
|
|
57
|
+
assert primary_gid in gids
|
|
58
|
+
assert len(set(gids)) == len(gids), "a group is listed twice"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def assert_group_names_are_returned_as_they_are(
|
|
62
|
+
directory: _Directory, gid: int, expected: str
|
|
63
|
+
) -> None:
|
|
64
|
+
"""Rule G6: no case folding, no trimming, no domain stripping."""
|
|
65
|
+
answered = directory.group_name(gid)
|
|
66
|
+
assert answered == expected
|
|
67
|
+
assert answered is not None
|
|
68
|
+
assert answered == answered.strip() or answered != expected.strip()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def assert_the_directory_answers_the_same_way_twice(
|
|
72
|
+
directory: _Directory, uid: int, gid: int
|
|
73
|
+
) -> None:
|
|
74
|
+
"""A resolution the daemon repeats within a lifetime must be repeatable."""
|
|
75
|
+
assert directory.account(uid) == directory.account(uid)
|
|
76
|
+
assert directory.group_name(gid) == directory.group_name(gid)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def run_the_account_directory_contract(
|
|
80
|
+
directory: _Directory,
|
|
81
|
+
*,
|
|
82
|
+
known_uid: int,
|
|
83
|
+
known_name: str,
|
|
84
|
+
known_primary_gid: int,
|
|
85
|
+
known_group_name: str,
|
|
86
|
+
absent_uid: int,
|
|
87
|
+
absent_gid: int,
|
|
88
|
+
) -> None:
|
|
89
|
+
"""Every promise of the port, against one provider."""
|
|
90
|
+
assert_the_port_is_versioned(directory)
|
|
91
|
+
assert_a_known_account_resolves(directory, known_uid, known_name)
|
|
92
|
+
assert_an_unknown_id_is_none(directory, absent_uid, absent_gid)
|
|
93
|
+
assert_a_membership_includes_its_primary_group(directory, known_name, known_primary_gid)
|
|
94
|
+
assert_group_names_are_returned_as_they_are(directory, known_primary_gid, known_group_name)
|
|
95
|
+
assert_the_directory_answers_the_same_way_twice(directory, known_uid, known_primary_gid)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""The contract of the Clock port, run against every provider.
|
|
3
|
+
|
|
4
|
+
Article 8: a provider that does not pass this suite is not a provider. Every
|
|
5
|
+
instant this project records comes through here, and every one of them is
|
|
6
|
+
offset-aware — an instant without an offset is not a time anyone can compare
|
|
7
|
+
across hosts (article 2).
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from typing import Protocol
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _Clock(Protocol):
|
|
17
|
+
VERSION: int
|
|
18
|
+
|
|
19
|
+
def now(self) -> datetime: ...
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def assert_the_port_is_versioned(clock: _Clock) -> None:
|
|
23
|
+
"""Article 8: a port carries an integer version, and so does its provider."""
|
|
24
|
+
assert isinstance(clock.VERSION, int)
|
|
25
|
+
assert not isinstance(clock.VERSION, bool)
|
|
26
|
+
assert clock.VERSION >= 1
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def assert_every_instant_carries_its_offset(clock: _Clock) -> None:
|
|
30
|
+
"""An instant with no offset is one no other host can read."""
|
|
31
|
+
instant = clock.now()
|
|
32
|
+
assert isinstance(instant, datetime)
|
|
33
|
+
assert instant.tzinfo is not None
|
|
34
|
+
assert instant.utcoffset() is not None
|
|
35
|
+
assert datetime.fromisoformat(instant.isoformat()) == instant
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def assert_time_does_not_run_backwards(clock: _Clock) -> None:
|
|
39
|
+
"""Two readings in order are in order: a lifetime is computed from them."""
|
|
40
|
+
first = clock.now()
|
|
41
|
+
second = clock.now()
|
|
42
|
+
assert second >= first
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def run_the_clock_contract(clock: _Clock) -> None:
|
|
46
|
+
"""Every promise of the port, against one provider."""
|
|
47
|
+
assert_the_port_is_versioned(clock)
|
|
48
|
+
assert_every_instant_carries_its_offset(clock)
|
|
49
|
+
assert_time_does_not_run_backwards(clock)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Reusable contract suite for an append-only scoped decision authority.
|
|
3
|
+
|
|
4
|
+
Article 3: a decision is an authority record, appended once and never updated;
|
|
5
|
+
article 5: every read names its scope, and the local default never applies to
|
|
6
|
+
a read. Block 2.7 adds what a durable store owes on top: an append answers the
|
|
7
|
+
position it committed the record at, in a store it names, and the store says
|
|
8
|
+
where it keeps its records so the grade can inspect them (article 7).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from copy import deepcopy
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from sayfirst_contract.decisions import Decision, Outcome, Reason
|
|
17
|
+
from sayfirst_control_plane.ports.decision_store import (
|
|
18
|
+
DecisionAlreadyExists,
|
|
19
|
+
DecisionPosition,
|
|
20
|
+
DecisionStore,
|
|
21
|
+
ScopeRequired,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _decision(reference: str, *, scope: str = "local", outcome: Outcome = Outcome.DENY) -> Decision:
|
|
26
|
+
return Decision(
|
|
27
|
+
decision_ref=reference,
|
|
28
|
+
scope=scope,
|
|
29
|
+
capability="mail.send",
|
|
30
|
+
outcome=outcome,
|
|
31
|
+
reason=Reason.POLICY_ABSENT,
|
|
32
|
+
policy_version="sha256:" + "a" * 64,
|
|
33
|
+
approval_ref=None,
|
|
34
|
+
decided_at="2026-09-04T00:00:00Z",
|
|
35
|
+
correlation=None,
|
|
36
|
+
contract_generation=1,
|
|
37
|
+
extra={
|
|
38
|
+
"principal": {"kind": "process", "uid": 1000, "name": "build"},
|
|
39
|
+
"arguments_digest": None,
|
|
40
|
+
"rule_id": None,
|
|
41
|
+
"grant_id": None,
|
|
42
|
+
},
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def assert_decision_store_contract(
|
|
47
|
+
store: DecisionStore,
|
|
48
|
+
first: Decision,
|
|
49
|
+
replacement: Decision,
|
|
50
|
+
) -> None:
|
|
51
|
+
"""Prove append-only identity, copy isolation, and explicit scoped reads."""
|
|
52
|
+
assert store.VERSION == 1
|
|
53
|
+
expected = deepcopy(first)
|
|
54
|
+
store.append(first)
|
|
55
|
+
if isinstance(first.extra, dict):
|
|
56
|
+
first.extra["planted"] = "caller mutation"
|
|
57
|
+
assert store.get(expected.scope, expected.decision_ref) == expected
|
|
58
|
+
try:
|
|
59
|
+
store.append(replacement)
|
|
60
|
+
except DecisionAlreadyExists:
|
|
61
|
+
pass
|
|
62
|
+
else:
|
|
63
|
+
raise AssertionError("a duplicate decision was accepted")
|
|
64
|
+
assert store.get(expected.scope, expected.decision_ref) == expected
|
|
65
|
+
try:
|
|
66
|
+
store.get("", expected.decision_ref)
|
|
67
|
+
except ScopeRequired:
|
|
68
|
+
pass
|
|
69
|
+
else:
|
|
70
|
+
raise AssertionError("an unscoped read was accepted")
|
|
71
|
+
assert store.get(f"{expected.scope}-other", expected.decision_ref) is None
|
|
72
|
+
assert store.get(f"{expected.scope}-other", "never-existed") is None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class DecisionStoreContract:
|
|
76
|
+
"""Subclass, implement `make_store`, and every case below runs against the adapter."""
|
|
77
|
+
|
|
78
|
+
def make_store(self, tmp_path: Path) -> DecisionStore:
|
|
79
|
+
raise NotImplementedError
|
|
80
|
+
|
|
81
|
+
def test_a_decision_appended_is_read_back_as_appended(self, tmp_path: Path) -> None:
|
|
82
|
+
"""Article 3: the record read is the record appended, whole, not rebuilt."""
|
|
83
|
+
store = self.make_store(tmp_path)
|
|
84
|
+
given = _decision("decision-1", outcome=Outcome.ALLOW)
|
|
85
|
+
expected = deepcopy(given)
|
|
86
|
+
store.append(given)
|
|
87
|
+
given.extra["planted"] = "caller mutation" # type: ignore[index]
|
|
88
|
+
read = store.get("local", "decision-1")
|
|
89
|
+
assert read == expected
|
|
90
|
+
assert read is not given
|
|
91
|
+
|
|
92
|
+
def test_a_duplicate_decision_reference_is_refused_never_upserted(self, tmp_path: Path) -> None:
|
|
93
|
+
"""Article 3: an authority identity is append-only within its scope."""
|
|
94
|
+
store = self.make_store(tmp_path)
|
|
95
|
+
store.append(_decision("decision-1"))
|
|
96
|
+
try:
|
|
97
|
+
store.append(_decision("decision-1", outcome=Outcome.ALLOW))
|
|
98
|
+
except DecisionAlreadyExists:
|
|
99
|
+
pass
|
|
100
|
+
else:
|
|
101
|
+
raise AssertionError("a duplicate decision reference was accepted")
|
|
102
|
+
read = store.get("local", "decision-1")
|
|
103
|
+
assert read is not None and read.outcome is Outcome.DENY
|
|
104
|
+
|
|
105
|
+
def test_a_read_without_a_scope_is_refused(self, tmp_path: Path) -> None:
|
|
106
|
+
"""Article 5: the local default never applies to a read."""
|
|
107
|
+
store = self.make_store(tmp_path)
|
|
108
|
+
store.append(_decision("decision-1"))
|
|
109
|
+
try:
|
|
110
|
+
store.get("", "decision-1")
|
|
111
|
+
except ScopeRequired:
|
|
112
|
+
pass
|
|
113
|
+
else:
|
|
114
|
+
raise AssertionError("an unscoped read was accepted")
|
|
115
|
+
|
|
116
|
+
def test_another_scopes_decision_is_never_read_here(self, tmp_path: Path) -> None:
|
|
117
|
+
"""Article 5: an id in another scope is indistinguishable from no id."""
|
|
118
|
+
store = self.make_store(tmp_path)
|
|
119
|
+
store.append(_decision("decision-1", scope="one"))
|
|
120
|
+
assert store.get("two", "decision-1") is None
|
|
121
|
+
assert store.get("two", "never-existed") is None
|
|
122
|
+
read = store.get("one", "decision-1")
|
|
123
|
+
assert read is not None and read.scope == "one"
|
|
124
|
+
|
|
125
|
+
def test_an_append_answers_its_committed_position_in_a_named_store(
|
|
126
|
+
self, tmp_path: Path
|
|
127
|
+
) -> None:
|
|
128
|
+
"""C2: the position is fixed when the append completes, and never recycled."""
|
|
129
|
+
store = self.make_store(tmp_path)
|
|
130
|
+
first = store.append(_decision("decision-1"))
|
|
131
|
+
second = store.append(_decision("decision-2"))
|
|
132
|
+
other = store.append(_decision("decision-3", scope="other"))
|
|
133
|
+
assert isinstance(first, DecisionPosition) and isinstance(second, DecisionPosition)
|
|
134
|
+
assert first.store_id and first.store_id == second.store_id
|
|
135
|
+
assert (first.position, second.position) == (1, 2)
|
|
136
|
+
assert other.position == 1 and other.store_id != first.store_id
|
|
137
|
+
|
|
138
|
+
def test_the_store_says_where_it_keeps_its_records(self, tmp_path: Path) -> None:
|
|
139
|
+
"""Article 7: a grade inspects what it can name."""
|
|
140
|
+
location = self.make_store(tmp_path).location()
|
|
141
|
+
assert location.kind
|
|
142
|
+
assert location.retention
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Scripted doubles of the ports, mutable between calls so a test can revoke.
|
|
3
|
+
|
|
4
|
+
These are doubles of the conformance kit, never providers a configuration may
|
|
5
|
+
name (article 8: the kit is the contract of a port, not an implementation of
|
|
6
|
+
it that a deployment could accidentally activate).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import socket
|
|
12
|
+
from collections.abc import Mapping, Sequence
|
|
13
|
+
from datetime import UTC, datetime, timedelta
|
|
14
|
+
from typing import Final
|
|
15
|
+
|
|
16
|
+
from sayfirst_contract.transport.peer import PeerCredential, PeerCredentialUnavailable
|
|
17
|
+
from sayfirst_control_plane.ports.account_directory import Account
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class FixedClock:
|
|
21
|
+
"""A clock a test moves by hand."""
|
|
22
|
+
|
|
23
|
+
VERSION: Final[int] = 1
|
|
24
|
+
|
|
25
|
+
def __init__(self, start: datetime | None = None) -> None:
|
|
26
|
+
self._now = start or datetime(2026, 9, 4, tzinfo=UTC)
|
|
27
|
+
|
|
28
|
+
def now(self) -> datetime:
|
|
29
|
+
return self._now
|
|
30
|
+
|
|
31
|
+
def advance(self, seconds: float) -> None:
|
|
32
|
+
self._now += timedelta(seconds=seconds)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class StaticPeerIdentity:
|
|
36
|
+
"""A scripted credential, or a scripted absence of one."""
|
|
37
|
+
|
|
38
|
+
VERSION: Final[int] = 1
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
credential: PeerCredential | None = None,
|
|
43
|
+
*,
|
|
44
|
+
unavailable: bool = False,
|
|
45
|
+
by_socket: Mapping[int, PeerCredential] | None = None,
|
|
46
|
+
) -> None:
|
|
47
|
+
self.credential = credential
|
|
48
|
+
self.unavailable = unavailable
|
|
49
|
+
self.by_socket = dict(by_socket or {})
|
|
50
|
+
self.calls = 0
|
|
51
|
+
|
|
52
|
+
def establish(self, connection: socket.socket) -> PeerCredential:
|
|
53
|
+
self.calls += 1
|
|
54
|
+
if self.unavailable:
|
|
55
|
+
raise PeerCredentialUnavailable("scripted absence of a credential")
|
|
56
|
+
scripted = self.by_socket.get(id(connection))
|
|
57
|
+
if scripted is not None:
|
|
58
|
+
return scripted
|
|
59
|
+
if self.credential is None:
|
|
60
|
+
raise PeerCredentialUnavailable("scripted absence of a credential")
|
|
61
|
+
return self.credential
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class DirectoryOutage(Exception):
|
|
65
|
+
"""The scripted directory cannot be consulted."""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class StaticAccountDirectory:
|
|
69
|
+
"""A scripted table of accounts and memberships, mutable between calls."""
|
|
70
|
+
|
|
71
|
+
VERSION: Final[int] = 1
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
accounts: Mapping[int, tuple[str, int]] | None = None,
|
|
76
|
+
memberships: Mapping[str, Sequence[int]] | None = None,
|
|
77
|
+
group_names: Mapping[int, str] | None = None,
|
|
78
|
+
*,
|
|
79
|
+
outage: bool = False,
|
|
80
|
+
delay_seconds: float = 0.0,
|
|
81
|
+
) -> None:
|
|
82
|
+
self.accounts = dict(accounts or {})
|
|
83
|
+
self.memberships = {name: tuple(gids) for name, gids in (memberships or {}).items()}
|
|
84
|
+
self.group_names = dict(group_names or {})
|
|
85
|
+
self.outage = outage
|
|
86
|
+
self.delay_seconds = delay_seconds
|
|
87
|
+
self.calls: list[tuple[str, object]] = []
|
|
88
|
+
|
|
89
|
+
def _consult(self, call: str, argument: object) -> None:
|
|
90
|
+
self.calls.append((call, argument))
|
|
91
|
+
if self.delay_seconds:
|
|
92
|
+
import time
|
|
93
|
+
|
|
94
|
+
time.sleep(self.delay_seconds)
|
|
95
|
+
if self.outage:
|
|
96
|
+
raise DirectoryOutage("the scripted directory cannot be consulted")
|
|
97
|
+
|
|
98
|
+
def account(self, uid: int) -> Account | None:
|
|
99
|
+
self._consult("account", uid)
|
|
100
|
+
entry = self.accounts.get(uid)
|
|
101
|
+
return None if entry is None else Account(entry[0], entry[1])
|
|
102
|
+
|
|
103
|
+
def group_ids(self, name: str, primary_gid: int) -> tuple[int, ...]:
|
|
104
|
+
self._consult("group_ids", name)
|
|
105
|
+
listed = self.memberships.get(name)
|
|
106
|
+
if listed is None:
|
|
107
|
+
return (primary_gid,)
|
|
108
|
+
return tuple(dict.fromkeys((primary_gid, *listed)))
|
|
109
|
+
|
|
110
|
+
def group_name(self, gid: int) -> str | None:
|
|
111
|
+
self._consult("group_name", gid)
|
|
112
|
+
return self.group_names.get(gid)
|
|
113
|
+
|
|
114
|
+
def revoke(self, name: str, gid: int) -> None:
|
|
115
|
+
"""Take a membership away between two calls, as an administrator would."""
|
|
116
|
+
self.memberships[name] = tuple(
|
|
117
|
+
item for item in self.memberships.get(name, ()) if item != gid
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def grant(self, name: str, gid: int) -> None:
|
|
121
|
+
self.memberships[name] = (*self.memberships.get(name, ()), gid)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Which guards a runner owes, and which of them a run actually held.
|
|
3
|
+
|
|
4
|
+
A platform gate is written in the guard's own source, so the set a runner owes
|
|
5
|
+
is read from the source and never from a hand-kept list that can drift away
|
|
6
|
+
from it (article 2: the claim and its evidence are the same thing). What a run
|
|
7
|
+
did is read from its JUnit report, because "reported as skipped" and "held" are
|
|
8
|
+
two outcomes and a step that treats them alike proves nothing.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import ast
|
|
14
|
+
from collections.abc import Iterable, Mapping
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Final
|
|
17
|
+
from xml.etree import ElementTree
|
|
18
|
+
|
|
19
|
+
OS_REAL_PLATFORMS: Final[tuple[str, ...]] = ("linux", "darwin")
|
|
20
|
+
"""The two operating systems article 6's guards bind, and the two adapters."""
|
|
21
|
+
|
|
22
|
+
GATE_DECORATORS: Final[frozenset[str]] = frozenset({"requires_platform", "requires_platforms"})
|
|
23
|
+
"""The two decorators that gate a guard to an operating system."""
|
|
24
|
+
|
|
25
|
+
PRIVILEGE_DECORATORS: Final[Mapping[str, str]] = {
|
|
26
|
+
"requires_root": "root",
|
|
27
|
+
"requires_unprivileged": "unprivileged",
|
|
28
|
+
}
|
|
29
|
+
"""The two decorators that gate a guard to a privilege, and the privilege each names.
|
|
30
|
+
|
|
31
|
+
A privilege gate is the second axis of the same question a platform gate asks.
|
|
32
|
+
A guard that only a root container can hold is not owed by an ordinary runner,
|
|
33
|
+
and one whose premise is that the tester is not root is not owed by a root one:
|
|
34
|
+
either way the runner that *can* hold it owes it, and the runner that cannot
|
|
35
|
+
reports a skip that is not counted as a pass (article 2).
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
_STARRED: Final[Mapping[str, tuple[str, ...]]] = {"OS_REAL_PLATFORMS": OS_REAL_PLATFORMS}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def gated_guards(*trees: Path) -> dict[str, frozenset[str]]:
|
|
42
|
+
"""Every platform-gated guard under `trees`, with the platforms it admits."""
|
|
43
|
+
gates: dict[str, frozenset[str]] = {}
|
|
44
|
+
for tree in trees:
|
|
45
|
+
for source in sorted(Path(tree).rglob("test_*.py")):
|
|
46
|
+
module = ast.parse(source.read_text(encoding="utf-8"), filename=str(source))
|
|
47
|
+
for node in ast.walk(module):
|
|
48
|
+
if not isinstance(node, ast.FunctionDef):
|
|
49
|
+
continue
|
|
50
|
+
platforms = _gate_of(node)
|
|
51
|
+
if platforms is not None:
|
|
52
|
+
gates[node.name] = platforms
|
|
53
|
+
return gates
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _gate_of(node: ast.FunctionDef) -> frozenset[str] | None:
|
|
57
|
+
for decorator in node.decorator_list:
|
|
58
|
+
if not isinstance(decorator, ast.Call):
|
|
59
|
+
continue
|
|
60
|
+
if ast.unparse(decorator.func) not in GATE_DECORATORS:
|
|
61
|
+
continue
|
|
62
|
+
platforms: set[str] = set()
|
|
63
|
+
for argument in decorator.args:
|
|
64
|
+
rendered = ast.unparse(argument)
|
|
65
|
+
if rendered.startswith("*"):
|
|
66
|
+
platforms |= set(_STARRED.get(rendered[1:], ()))
|
|
67
|
+
else:
|
|
68
|
+
platforms.add(rendered.strip("\"'"))
|
|
69
|
+
return frozenset(platforms)
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def privilege_gated_guards(*trees: Path) -> dict[str, str]:
|
|
74
|
+
"""Every privilege-gated guard under `trees`, with the privilege it needs."""
|
|
75
|
+
gates: dict[str, str] = {}
|
|
76
|
+
for tree in trees:
|
|
77
|
+
for source in sorted(Path(tree).rglob("test_*.py")):
|
|
78
|
+
module = ast.parse(source.read_text(encoding="utf-8"), filename=str(source))
|
|
79
|
+
for node in ast.walk(module):
|
|
80
|
+
if not isinstance(node, ast.FunctionDef):
|
|
81
|
+
continue
|
|
82
|
+
privilege = _privilege_of(node)
|
|
83
|
+
if privilege is not None:
|
|
84
|
+
gates[node.name] = privilege
|
|
85
|
+
return gates
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _privilege_of(node: ast.FunctionDef) -> str | None:
|
|
89
|
+
for decorator in node.decorator_list:
|
|
90
|
+
if not isinstance(decorator, ast.Call):
|
|
91
|
+
continue
|
|
92
|
+
privilege = PRIVILEGE_DECORATORS.get(ast.unparse(decorator.func))
|
|
93
|
+
if privilege is not None:
|
|
94
|
+
return privilege
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def guards_required_on(
|
|
99
|
+
platform: str, *trees: Path, privilege: str = "unprivileged"
|
|
100
|
+
) -> frozenset[str]:
|
|
101
|
+
"""The gated guards this runner owes: every one both of its gates admit.
|
|
102
|
+
|
|
103
|
+
A guard gated to one operating system is owed by that runner alone — it has
|
|
104
|
+
nowhere else it can be held, so a run of that runner in which it did not
|
|
105
|
+
run is a run that proved nothing about it. A guard gated to a privilege as
|
|
106
|
+
well is owed only by the runner that has that privilege too: requiring a
|
|
107
|
+
root-container guard of an ordinary runner would fail every ordinary run
|
|
108
|
+
over a skip that runner was right to report.
|
|
109
|
+
"""
|
|
110
|
+
privileges = privilege_gated_guards(*trees)
|
|
111
|
+
return frozenset(
|
|
112
|
+
name
|
|
113
|
+
for name, platforms in gated_guards(*trees).items()
|
|
114
|
+
if platform in platforms and privileges.get(name, privilege) == privilege
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def outcomes(junit_report: Path) -> dict[str, str]:
|
|
119
|
+
"""Each test case in a JUnit report, as `held`, `not runnable` or `broken`.
|
|
120
|
+
|
|
121
|
+
Parametrised cases collapse onto their guard's name; a guard is `held` only
|
|
122
|
+
when every case of it was.
|
|
123
|
+
"""
|
|
124
|
+
read: dict[str, str] = {}
|
|
125
|
+
root = ElementTree.parse(junit_report).getroot()
|
|
126
|
+
for case in root.iter("testcase"):
|
|
127
|
+
name = str(case.get("name", "")).partition("[")[0]
|
|
128
|
+
if not name:
|
|
129
|
+
continue
|
|
130
|
+
outcome = "held"
|
|
131
|
+
if case.find("skipped") is not None:
|
|
132
|
+
outcome = "not runnable"
|
|
133
|
+
if case.find("failure") is not None or case.find("error") is not None:
|
|
134
|
+
outcome = "broken"
|
|
135
|
+
if read.get(name) in {"broken", "not runnable"}:
|
|
136
|
+
continue
|
|
137
|
+
read[name] = outcome
|
|
138
|
+
return read
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def guards_not_held(required: Iterable[str], read: Mapping[str, str]) -> dict[str, str]:
|
|
142
|
+
"""The required guards this run did not hold, and what happened instead."""
|
|
143
|
+
return {
|
|
144
|
+
name: read.get(name, "never ran") for name in sorted(required) if read.get(name) != "held"
|
|
145
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""The contract of the PeerIdentity port, run against every adapter.
|
|
3
|
+
|
|
4
|
+
It covers `establish(connection)`: what the kernel recorded for the process at
|
|
5
|
+
the other end, read on both sides of a local stream.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import socket
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from sayfirst_contract.transport.peer import (
|
|
15
|
+
PeerCredential,
|
|
16
|
+
PeerCredentialUnavailable,
|
|
17
|
+
PeerIdentity,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _assert_is_this_process(credential: PeerCredential) -> None:
|
|
22
|
+
assert credential.uid == os.geteuid()
|
|
23
|
+
assert credential.gid == os.getegid()
|
|
24
|
+
assert credential.pid == os.getpid()
|
|
25
|
+
assert credential.captured_at
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def assert_own_credential_over_a_socketpair(adapter: PeerIdentity) -> None:
|
|
29
|
+
"""Both ends of a socketpair belong to this process, so both report it."""
|
|
30
|
+
left, right = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
31
|
+
with left, right:
|
|
32
|
+
_assert_is_this_process(adapter.establish(left))
|
|
33
|
+
_assert_is_this_process(adapter.establish(right))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def assert_both_sides_of_a_listener_are_read(adapter: PeerIdentity, bound_at: Path) -> None:
|
|
37
|
+
"""The connecting side reads the listener's record and the reverse."""
|
|
38
|
+
listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
39
|
+
with listener:
|
|
40
|
+
listener.bind(str(bound_at))
|
|
41
|
+
listener.listen(1)
|
|
42
|
+
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
43
|
+
with client:
|
|
44
|
+
client.connect(str(bound_at))
|
|
45
|
+
accepted, _ = listener.accept()
|
|
46
|
+
with accepted:
|
|
47
|
+
_assert_is_this_process(adapter.establish(accepted))
|
|
48
|
+
_assert_is_this_process(adapter.establish(client))
|
|
49
|
+
bound_at.unlink(missing_ok=True)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def assert_no_identity_is_unavailable(adapter: PeerIdentity) -> None:
|
|
53
|
+
"""A record the adapter cannot read is unavailable, never an identity."""
|
|
54
|
+
|
|
55
|
+
class _Refusing:
|
|
56
|
+
def getsockopt(self, *_: object) -> bytes:
|
|
57
|
+
raise OSError(22, "Invalid argument")
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
adapter.establish(_Refusing()) # type: ignore[arg-type]
|
|
61
|
+
except PeerCredentialUnavailable:
|
|
62
|
+
return
|
|
63
|
+
raise AssertionError("an unreadable credential must be unavailable")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def run_the_peer_identity_contract(adapter: PeerIdentity, *, bound_at: Path) -> None:
|
|
67
|
+
"""Every promise of the port, against one adapter (article 8)."""
|
|
68
|
+
assert isinstance(adapter.VERSION, int) and not isinstance(adapter.VERSION, bool)
|
|
69
|
+
assert adapter.VERSION >= 1
|
|
70
|
+
assert_own_credential_over_a_socketpair(adapter)
|
|
71
|
+
assert_both_sides_of_a_listener_are_read(adapter, bound_at)
|
|
72
|
+
assert_no_identity_is_unavailable(adapter)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Platform gates whose skips are reported, never counted as passes."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from collections.abc import Callable, Sequence
|
|
8
|
+
from typing import TypeVar
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from .guard_gates import OS_REAL_PLATFORMS
|
|
13
|
+
|
|
14
|
+
F = TypeVar("F", bound=Callable[..., object])
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"OS_REAL_PLATFORMS",
|
|
18
|
+
"identity_summary",
|
|
19
|
+
"requires_platform",
|
|
20
|
+
"requires_platforms",
|
|
21
|
+
"skip_reason",
|
|
22
|
+
"skip_reason_for",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def skip_reason(platform: str) -> str:
|
|
27
|
+
"""The one sentence a host that cannot run a guard reports."""
|
|
28
|
+
return f"not runnable on this host (requires {platform})"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def skip_reason_for(platforms: Sequence[str]) -> str:
|
|
32
|
+
"""The same sentence for a guard that either operating system can run."""
|
|
33
|
+
return skip_reason(" or ".join(platforms))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def requires_platform(platform: str) -> Callable[[F], F]:
|
|
37
|
+
"""Skip a guard this host cannot run, saying which host runs it."""
|
|
38
|
+
return pytest.mark.skipif( # type: ignore[return-value]
|
|
39
|
+
sys.platform != platform, reason=skip_reason(platform)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def requires_platforms(*platforms: str) -> Callable[[F], F]:
|
|
44
|
+
"""Skip a guard no host of this kind can run, naming the hosts that can.
|
|
45
|
+
|
|
46
|
+
A guard the host boundary defines runs on every operating system that has
|
|
47
|
+
an adapter; one that reads a facility only one of them has names that one.
|
|
48
|
+
"""
|
|
49
|
+
return pytest.mark.skipif( # type: ignore[return-value]
|
|
50
|
+
sys.platform not in platforms, reason=skip_reason_for(platforms)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def identity_summary(*, passed: int, skipped: int, failed: int) -> str:
|
|
55
|
+
"""Render the identity summary; a skip is its own column, never a pass."""
|
|
56
|
+
return f"identity: {passed} held, {skipped} not runnable on this host, {failed} broken"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Reusable contract suite for an immutable, content-addressed policy archive.
|
|
3
|
+
|
|
4
|
+
The archive keeps the exact bytes of every policy version a decision names, so
|
|
5
|
+
a reader holding an export and the contract can re-derive the answer from the
|
|
6
|
+
bytes the daemon actually read (articles 3, 10, 13). A version is the SHA-256
|
|
7
|
+
of its bytes; a keep that disagrees with its own version is refused, a second
|
|
8
|
+
keep of a present version rewrites nothing, and bytes that no longer hash to
|
|
9
|
+
their name are reported damaged and never overwritten, never evaluated.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import hashlib
|
|
15
|
+
from collections.abc import Callable
|
|
16
|
+
|
|
17
|
+
from sayfirst_control_plane.ports.policy_archive import ArchiveState, PolicyArchive
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def version_of(content: bytes) -> str:
|
|
21
|
+
return "sha256:" + hashlib.sha256(content).hexdigest()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def assert_policy_archive_contract(
|
|
25
|
+
archive: PolicyArchive,
|
|
26
|
+
*,
|
|
27
|
+
damage: Callable[[str, bytes], None],
|
|
28
|
+
) -> None:
|
|
29
|
+
"""Prove keep, read, idempotence, refusal, damage reporting and absence.
|
|
30
|
+
|
|
31
|
+
`damage(version, bytes)` rewrites the stored bytes of `version` outside the
|
|
32
|
+
port, the way an operator or a fault would; the suite cannot do it through
|
|
33
|
+
a port that publishes no write of that kind, and that absence is the point.
|
|
34
|
+
"""
|
|
35
|
+
assert archive.VERSION == 1
|
|
36
|
+
content = b'format = 1\n[revision]\nreason = "archive contract"\n'
|
|
37
|
+
version = version_of(content)
|
|
38
|
+
|
|
39
|
+
assert archive.read(version).state is ArchiveState.absent
|
|
40
|
+
assert archive.read(version).content is None
|
|
41
|
+
|
|
42
|
+
kept = archive.keep(version, content)
|
|
43
|
+
assert (kept.version, kept.state, kept.content) == (version, ArchiveState.present, content)
|
|
44
|
+
again = archive.keep(version, content)
|
|
45
|
+
assert (again.version, again.state, again.content) == (version, ArchiveState.present, content)
|
|
46
|
+
read = archive.read(version)
|
|
47
|
+
assert (read.version, read.state, read.content) == (version, ArchiveState.present, content)
|
|
48
|
+
|
|
49
|
+
other = b'format = 1\n[revision]\nreason = "other"\n'
|
|
50
|
+
try:
|
|
51
|
+
archive.keep(version, other)
|
|
52
|
+
except ValueError:
|
|
53
|
+
pass
|
|
54
|
+
else:
|
|
55
|
+
raise AssertionError("bytes that do not hash to their version were kept")
|
|
56
|
+
assert archive.read(version).content == content
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
archive.keep("policy-1", content)
|
|
60
|
+
except ValueError:
|
|
61
|
+
pass
|
|
62
|
+
else:
|
|
63
|
+
raise AssertionError("a version that is not a sha256 digest was kept")
|
|
64
|
+
|
|
65
|
+
# Trailing bytes are a different version: the archive is exact to the byte.
|
|
66
|
+
with_newline = content + b"\n"
|
|
67
|
+
assert version_of(with_newline) != version
|
|
68
|
+
kept = archive.keep(version_of(with_newline), with_newline)
|
|
69
|
+
assert kept.content == with_newline
|
|
70
|
+
assert archive.read(version).content == content
|
|
71
|
+
|
|
72
|
+
damage(version, other)
|
|
73
|
+
damaged = archive.read(version)
|
|
74
|
+
assert (damaged.version, damaged.state, damaged.content) == (
|
|
75
|
+
version,
|
|
76
|
+
ArchiveState.damaged,
|
|
77
|
+
None,
|
|
78
|
+
)
|
|
79
|
+
# A keep of the right bytes under a damaged name reports the damage and
|
|
80
|
+
# overwrites nothing: restoration is an operator's act, not a store API.
|
|
81
|
+
kept = archive.keep(version, content)
|
|
82
|
+
assert kept.state is ArchiveState.damaged
|
|
83
|
+
assert archive.read(version).state is ArchiveState.damaged
|
|
84
|
+
|
|
85
|
+
location = archive.location()
|
|
86
|
+
assert location.kind
|
|
87
|
+
assert location.retention
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Reusable contract suite for a rebuild-only policy projection."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from sayfirst_control_plane.ports.policy_projection import (
|
|
7
|
+
PROJECTION_KIND_UNKNOWN,
|
|
8
|
+
PolicyProjection,
|
|
9
|
+
ProjectedPolicy,
|
|
10
|
+
projection_kind,
|
|
11
|
+
)
|
|
12
|
+
from sayfirst_control_plane.ports.policy_store import LoadedPolicy
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def assert_policy_projection_contract(
|
|
16
|
+
projection: PolicyProjection,
|
|
17
|
+
loaded: LoadedPolicy,
|
|
18
|
+
) -> None:
|
|
19
|
+
"""Prove that clear plus rebuild reproduces the complete authority snapshot."""
|
|
20
|
+
assert projection.VERSION == 1
|
|
21
|
+
# A provider names itself inside the shape the policy status publishes, so
|
|
22
|
+
# that a status answer never leaves it (articles 8 and 13).
|
|
23
|
+
assert projection_kind(projection) != PROJECTION_KIND_UNKNOWN, (
|
|
24
|
+
f"projection kind {getattr(projection, 'KIND', None)!r} is outside the published shape"
|
|
25
|
+
)
|
|
26
|
+
projection.clear()
|
|
27
|
+
assert projection.current() is None
|
|
28
|
+
projection.rebuild(loaded)
|
|
29
|
+
expected = ProjectedPolicy(
|
|
30
|
+
policy_version=loaded.policy_version,
|
|
31
|
+
format=loaded.policy.format,
|
|
32
|
+
loaded_at=loaded.loaded_at,
|
|
33
|
+
rule_count=len(loaded.policy.rules),
|
|
34
|
+
rules=loaded.policy.rules,
|
|
35
|
+
)
|
|
36
|
+
assert projection.current() == expected
|
|
37
|
+
projection.clear()
|
|
38
|
+
assert projection.current() is None
|
|
39
|
+
projection.rebuild(loaded)
|
|
40
|
+
assert projection.current() == expected
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Reusable contract suite for the read-only policy authority port."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from sayfirst_control_plane.domain.policy import Principal
|
|
7
|
+
from sayfirst_control_plane.ports.policy_store import (
|
|
8
|
+
AccessState,
|
|
9
|
+
LoadedPolicy,
|
|
10
|
+
PolicyStore,
|
|
11
|
+
PolicyUnavailable,
|
|
12
|
+
ProtectionExpectation,
|
|
13
|
+
ProtectionState,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def assert_policy_store_contract(
|
|
18
|
+
available: PolicyStore,
|
|
19
|
+
unavailable: PolicyStore,
|
|
20
|
+
exposed: PolicyStore,
|
|
21
|
+
*,
|
|
22
|
+
expectation: ProtectionExpectation,
|
|
23
|
+
principal: Principal,
|
|
24
|
+
) -> None:
|
|
25
|
+
"""Prove whole-load, classified absence, and both access verdicts."""
|
|
26
|
+
assert available.VERSION == unavailable.VERSION == exposed.VERSION == 1
|
|
27
|
+
first = available.load()
|
|
28
|
+
second = available.load()
|
|
29
|
+
assert isinstance(first, LoadedPolicy)
|
|
30
|
+
assert second == first
|
|
31
|
+
absent = unavailable.load()
|
|
32
|
+
assert isinstance(absent, PolicyUnavailable)
|
|
33
|
+
assert absent.reason == "absent"
|
|
34
|
+
assert not hasattr(absent, "outcome")
|
|
35
|
+
# Both arms are asserted: an adapter answering one fixed verdict for every
|
|
36
|
+
# path fails one of them, whichever verdict it fixes (articles 2 and 8).
|
|
37
|
+
assert available.protection_at_start(expectation).kind is ProtectionState.PROTECTED
|
|
38
|
+
assert available.write_access_of(principal).kind is AccessState.NOT_WRITABLE
|
|
39
|
+
assert exposed.protection_at_start(expectation).kind is ProtectionState.EXPOSED
|
|
40
|
+
assert exposed.write_access_of(principal).kind is AccessState.WRITABLE
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Privilege gates: a guard that only a root container can hold says so.
|
|
3
|
+
|
|
4
|
+
A platform gate (`platforms.py`) answers "which operating system can hold this
|
|
5
|
+
guard". This answers the other question the identity guards raise: "which
|
|
6
|
+
privilege can". They are separate axes, and a guard can carry one of each — the
|
|
7
|
+
system-mode drop is Linux's and root's alike.
|
|
8
|
+
|
|
9
|
+
Two guards need this in opposite directions. One needs root, because system
|
|
10
|
+
mode refuses to start below it, so on an ordinary runner it has never executed
|
|
11
|
+
at all. The other needs *not* root: it drives an irreversible `setuid` in the
|
|
12
|
+
test process, or it reads uid 0 as a stranger, and either claim is false the
|
|
13
|
+
moment the tester is root. A guard whose premise is "the tester happened to
|
|
14
|
+
lack privilege" is a guard that was never held; article 2 asks that the claim
|
|
15
|
+
and the check be the same thing, so the premise is written into the gate where
|
|
16
|
+
`guard_gates` can read it and `scripts/require_platform_guards.py` can require
|
|
17
|
+
it of the runner that has it.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
from collections.abc import Callable
|
|
24
|
+
from typing import TypeVar
|
|
25
|
+
|
|
26
|
+
import pytest
|
|
27
|
+
|
|
28
|
+
F = TypeVar("F", bound=Callable[..., object])
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"PRIVILEGES",
|
|
32
|
+
"privilege_of_this_process",
|
|
33
|
+
"requires_root",
|
|
34
|
+
"requires_unprivileged",
|
|
35
|
+
"skip_reason_for_privilege",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
PRIVILEGES: tuple[str, ...] = ("root", "unprivileged")
|
|
39
|
+
"""The two privileges a runner can have, and the two gates that name them."""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def privilege_of_this_process() -> str:
|
|
43
|
+
"""`root` when this process can do what only uid 0 can, else `unprivileged`."""
|
|
44
|
+
return "root" if os.geteuid() == 0 else "unprivileged"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def skip_reason_for_privilege(privilege: str) -> str:
|
|
48
|
+
"""The one sentence a runner that cannot hold a guard reports."""
|
|
49
|
+
if privilege == "root":
|
|
50
|
+
return "not runnable here (requires a throwaway root container)"
|
|
51
|
+
return "not runnable as root (requires an unprivileged tester)"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def requires_root() -> Callable[[F], F]:
|
|
55
|
+
"""Skip a guard only a root container can hold, saying that is what it needs.
|
|
56
|
+
|
|
57
|
+
System mode refuses to start when `geteuid()` is not 0, so every claim
|
|
58
|
+
about what it does after that refusal is unexecuted on an ordinary runner.
|
|
59
|
+
"""
|
|
60
|
+
return pytest.mark.skipif( # type: ignore[return-value]
|
|
61
|
+
os.geteuid() != 0, reason=skip_reason_for_privilege("root")
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def requires_unprivileged() -> Callable[[F], F]:
|
|
66
|
+
"""Skip a guard whose premise is that the tester is not root.
|
|
67
|
+
|
|
68
|
+
Not a convenience: a guard that reads uid 0 as a stranger, or that relies
|
|
69
|
+
on a call failing for want of privilege, states something false under root,
|
|
70
|
+
and a false statement that passes is worse than one that is not made.
|
|
71
|
+
"""
|
|
72
|
+
return pytest.mark.skipif( # type: ignore[return-value]
|
|
73
|
+
os.geteuid() == 0, reason=skip_reason_for_privilege("unprivileged")
|
|
74
|
+
)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Validation of a document against one published schema and its neighbours.
|
|
3
|
+
|
|
4
|
+
The published schemas point at each other by file name; a validator needs
|
|
5
|
+
them all before it can read one. The validator itself is an optional extra of
|
|
6
|
+
this kit, never a dependency of the contract.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from collections.abc import Mapping
|
|
12
|
+
from contextlib import suppress
|
|
13
|
+
from functools import cache
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
from sayfirst_contract.artifacts import DOMAIN_SCHEMAS, domain_schema
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@cache
|
|
20
|
+
def _validator(schema_name: str) -> Any:
|
|
21
|
+
"""One validator per published schema, built once.
|
|
22
|
+
|
|
23
|
+
Building it reads every published schema into a registry, which is work
|
|
24
|
+
proportional to the contract and not to the document; a caller driving a
|
|
25
|
+
generated corpus through this pays it once rather than once per document.
|
|
26
|
+
The published schemas do not change while a process runs — they are
|
|
27
|
+
packaged artefacts — so one validator answers for all of them.
|
|
28
|
+
"""
|
|
29
|
+
import jsonschema
|
|
30
|
+
from referencing import Registry, Resource
|
|
31
|
+
from referencing.jsonschema import DRAFT202012
|
|
32
|
+
|
|
33
|
+
resources = [
|
|
34
|
+
(f"{name}.schema.json", Resource(contents=domain_schema(name), specification=DRAFT202012))
|
|
35
|
+
for name in DOMAIN_SCHEMAS
|
|
36
|
+
]
|
|
37
|
+
registry = Registry().with_resources(resources)
|
|
38
|
+
return jsonschema.Draft202012Validator(domain_schema(schema_name), registry=registry)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ByteBoundExceeded(ValueError):
|
|
42
|
+
"""A string longer than the UTF-8 byte bound its schema publishes."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _byte_bounds(schema: object, document: object) -> None:
|
|
46
|
+
"""Hold `x-max-bytes`, the bound JSON Schema has no keyword for.
|
|
47
|
+
|
|
48
|
+
`maxLength` counts code points, so a published byte bound needs its own
|
|
49
|
+
keyword and its own check; without it the contract would accept strings
|
|
50
|
+
the daemon refuses.
|
|
51
|
+
"""
|
|
52
|
+
if not isinstance(schema, Mapping):
|
|
53
|
+
return
|
|
54
|
+
reference = schema.get("$ref")
|
|
55
|
+
if isinstance(reference, str) and reference.endswith(".schema.json"):
|
|
56
|
+
_byte_bounds(domain_schema(reference.removesuffix(".schema.json")), document)
|
|
57
|
+
return
|
|
58
|
+
limit = schema.get("x-max-bytes")
|
|
59
|
+
if isinstance(limit, int) and isinstance(document, str):
|
|
60
|
+
try:
|
|
61
|
+
width = len(document.encode())
|
|
62
|
+
except UnicodeEncodeError as failure:
|
|
63
|
+
# A lone surrogate has no UTF-8 form at all, so it is not within a
|
|
64
|
+
# bound counted in UTF-8 bytes; refusing it is the honest answer,
|
|
65
|
+
# and raising `UnicodeEncodeError` at a caller asking a yes-or-no
|
|
66
|
+
# question is not.
|
|
67
|
+
raise ByteBoundExceeded(f"{document!r} is not UTF-8: {failure}") from None
|
|
68
|
+
if width > limit:
|
|
69
|
+
raise ByteBoundExceeded(f"{document!r} is longer than {limit} bytes")
|
|
70
|
+
if isinstance(document, Mapping):
|
|
71
|
+
for member, value in document.items():
|
|
72
|
+
_byte_bounds(schema.get("properties", {}).get(member), value)
|
|
73
|
+
elif isinstance(document, list):
|
|
74
|
+
for item in document:
|
|
75
|
+
_byte_bounds(schema.get("items"), item)
|
|
76
|
+
for keyword in ("oneOf", "anyOf", "allOf"):
|
|
77
|
+
for branch in schema.get(keyword, ()):
|
|
78
|
+
with suppress(ByteBoundExceeded):
|
|
79
|
+
_byte_bounds(branch, document)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def validate_document(document: Mapping[str, object], schema_name: str) -> None:
|
|
83
|
+
"""Raise when a document does not satisfy its published schema."""
|
|
84
|
+
_validator(schema_name).validate(dict(document))
|
|
85
|
+
_byte_bounds(domain_schema(schema_name), dict(document))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def document_is_valid(document: Mapping[str, object], schema_name: str) -> bool:
|
|
89
|
+
"""Whether a document satisfies its published schema."""
|
|
90
|
+
if not _validator(schema_name).is_valid(dict(document)):
|
|
91
|
+
return False
|
|
92
|
+
try:
|
|
93
|
+
_byte_bounds(domain_schema(schema_name), dict(document))
|
|
94
|
+
except ByteBoundExceeded:
|
|
95
|
+
return False
|
|
96
|
+
return True
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def jsonschema_accepts(document: Mapping[str, object], schema_name: str) -> bool:
|
|
100
|
+
"""Whether JSON Schema alone accepts `document`, byte bounds set aside.
|
|
101
|
+
|
|
102
|
+
`document_is_valid` is the published schema read whole; this is the part of
|
|
103
|
+
it a generic validator can check on its own. The two part company exactly
|
|
104
|
+
where `x-max-bytes` does the work, which is the one thing JSON Schema has
|
|
105
|
+
no keyword for, so a test that needs to name that gap needs both.
|
|
106
|
+
"""
|
|
107
|
+
return bool(_validator(schema_name).is_valid(dict(document)))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sayfirst-testing
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Published conformance suites for control-plane ports
|
|
5
|
+
Project-URL: Repository, https://github.com/fredaime/sayfirst-control-plane
|
|
6
|
+
Project-URL: Documentation, https://github.com/fredaime/sayfirst-control-plane/blob/main/packages/testing/README.md
|
|
7
|
+
Project-URL: Changelog, https://github.com/fredaime/sayfirst-control-plane/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: fredaime <frederic.aime@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: <3.15,>=3.12
|
|
18
|
+
Requires-Dist: sayfirst-contract==0.3.0
|
|
19
|
+
Requires-Dist: sayfirst-control-plane==0.3.0
|
|
20
|
+
Provides-Extra: schemas
|
|
21
|
+
Requires-Dist: jsonschema<5,>=4.25; extra == 'schemas'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
25
|
+
# `sayfirst` port conformance kit
|
|
26
|
+
|
|
27
|
+
This distribution publishes reusable contract suites for the policy authority,
|
|
28
|
+
policy projection, and append-only decision store ports. A provider is a
|
|
29
|
+
provider only when its adapter passes the corresponding suite.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
sayfirst_testing/__init__.py,sha256=CXPyLWmtpJRFfSbZtyb5Q0kurNpepcWwhHFuPfWgmRw,257
|
|
2
|
+
sayfirst_testing/account_directory_contract.py,sha256=nHZS5GwJvqMK1FngGJtkTD_V17LlKbmKp9x5-CYTiiA,3594
|
|
3
|
+
sayfirst_testing/clock_contract.py,sha256=269kZwAjRpuV-6RiLxmfJE8-jkE8Pxj09x6HDg6brNM,1617
|
|
4
|
+
sayfirst_testing/decision_store_contract.py,sha256=dUU1hJWxgXxOPL4gOWa5ddu8SYoQGsoNdAjNAMbmgnI,5698
|
|
5
|
+
sayfirst_testing/doubles.py,sha256=CpPybmuFMO-bHGXu9s0xa2pdhKrXLUplSnqeUWKY3s0,4108
|
|
6
|
+
sayfirst_testing/guard_gates.py,sha256=sacMhND3spqlpyZ83M4_Lpyc8lCBnSw4iBYkhAxGqwI,5839
|
|
7
|
+
sayfirst_testing/peer_identity_contract.py,sha256=CRK7HnZkBGrLLqpEoPFWQ9u2CajgOVzBYbORLCqt6W0,2647
|
|
8
|
+
sayfirst_testing/platforms.py,sha256=t4gJ115BxQpnIKIWDuNW4QnLmKFkJFGRDXUZkRXT-f8,1799
|
|
9
|
+
sayfirst_testing/policy_archive_contract.py,sha256=eVqEBkkCevv4CPMNnuAEOonsSc15NzCsfbe5XN-EDxg,3340
|
|
10
|
+
sayfirst_testing/policy_projection_contract.py,sha256=ChMApPcP2XZD_ErnfT_3y6m-76hv3L5ylDmd0Fmb4_o,1424
|
|
11
|
+
sayfirst_testing/policy_store_contract.py,sha256=0iljIoGLbMbVp0w9dmc0E87qKH0mvAb4_3klPjbeJFk,1513
|
|
12
|
+
sayfirst_testing/privileges.py,sha256=3T8ceWbk1LPoiDy-MKbA1HEemO6W55ICq-RxDEs046E,2910
|
|
13
|
+
sayfirst_testing/schemas.py,sha256=uFCjqP841kNvszoP-FTCgqw0ifLfPSnzO1SXtKzPw4s,4452
|
|
14
|
+
sayfirst_testing-0.3.0.dist-info/METADATA,sha256=-h9ko2LBReXnPp5K5cggdCnZr0B6l88G3nZuEbUkOqQ,1309
|
|
15
|
+
sayfirst_testing-0.3.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
16
|
+
sayfirst_testing-0.3.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
17
|
+
sayfirst_testing-0.3.0.dist-info/licenses/NOTICE,sha256=LkjzbuEsvI-1vovqWcVWpdFHf5K94SPnh90HSgAhzMA,514
|
|
18
|
+
sayfirst_testing-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
sayfirst control plane
|
|
2
|
+
Copyright 2026 Frédéric Aime
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use these files except in compliance with the License. A copy of the
|
|
6
|
+
License is in the LICENSE file at the root of this repository.
|
|
7
|
+
|
|
8
|
+
Distributions that incorporate this software must reproduce the attribution
|
|
9
|
+
notices this file carries (Apache License 2.0, section 4(d)).
|
|
10
|
+
|
|
11
|
+
The Apache License grants no rights in the names and marks of this project; see
|
|
12
|
+
TRADEMARKS.md.
|