compose-plugins 0.2.0__tar.gz → 0.4.0__tar.gz
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.
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/PKG-INFO +30 -8
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/README.md +29 -7
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/__init__.py +11 -5
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/conformance.py +152 -2
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/consent.py +161 -11
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/derive.py +18 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/errors.py +42 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/host.py +58 -2
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/lifecycle.py +415 -56
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/manifest.py +278 -10
- compose_plugins-0.4.0/compose_plugins/schema/manifest-0.3.schema.json +265 -0
- compose_plugins-0.4.0/compose_plugins/schema/manifest-0.4.schema.json +269 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/store.py +64 -7
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/version.py +1 -1
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/web.py +158 -19
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/PKG-INFO +30 -8
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/SOURCES.txt +11 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/pyproject.toml +1 -1
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_schema_file.py +9 -1
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_v02_install_log.py +22 -6
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_v02_license_eula.py +13 -6
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_v02_schema_by_contract.py +8 -4
- compose_plugins-0.4.0/tests/test_v03_lifecycle.py +695 -0
- compose_plugins-0.4.0/tests/test_v03_manifest.py +462 -0
- compose_plugins-0.4.0/tests/test_v03_r27.py +514 -0
- compose_plugins-0.4.0/tests/test_v03_r27_round3.py +234 -0
- compose_plugins-0.4.0/tests/test_v03_reads_0_2.py +224 -0
- compose_plugins-0.4.0/tests/test_v03_uninstall_data.py +274 -0
- compose_plugins-0.4.0/tests/test_v03_warnings.py +385 -0
- compose_plugins-0.4.0/tests/test_v03_web.py +254 -0
- compose_plugins-0.4.0/tests/test_v04_may_not_embed.py +416 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_version.py +7 -6
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_lifecycle.py +3 -1
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/LICENSE +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/_child.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/_probe.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/config.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_eula/EULA.txt +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_eula/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_eula/hello_world/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_eula/hello_world/plugin.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_eula/manifest.json +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v1/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v1/hello_world/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v1/hello_world/plugin.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v1/manifest.json +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v2/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v2/hello_world/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v2/hello_world/plugin.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/fixtures/hello_world_v2/manifest.json +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/package.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/probe_client.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/runner.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/schema/__init__.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/schema/manifest-0.1.schema.json +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins/schema/manifest-0.2.schema.json +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/dependency_links.txt +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/entry_points.txt +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/requires.txt +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/compose_plugins.egg-info/top_level.txt +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/setup.cfg +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_consent.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_consent_record_r9.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_host_name_r10.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_manifest.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_package.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_qa_wave1_rulings.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_r21_permissions.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_r24_conformance_hooks.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_v02_record_decline.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_v02_uninstall_confirm.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_validator_readings.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_build.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_conformance.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_r18.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_r19.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_runner.py +0 -0
- {compose_plugins-0.2.0 → compose_plugins-0.4.0}/tests/test_wave2_web.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compose-plugins
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: The shared plug-in contract library (manifest, consent, version rule) for ComposeIO and Gnomon hosts
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,9 +12,29 @@ Dynamic: license-file
|
|
|
12
12
|
# compose-plugins
|
|
13
13
|
|
|
14
14
|
The shared plug-in contract library for ComposeIO's ComposeServer and for
|
|
15
|
-
Gnomon, implementing the Shared Plug-in Contract v0.
|
|
16
|
-
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta
|
|
17
|
-
a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
15
|
+
Gnomon, implementing the Shared Plug-in Contract v0.4 (ComposeIO spec 95,
|
|
16
|
+
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta plus the v0.3 and v0.4 deltas,
|
|
17
|
+
sections 18 and 20). It is the layer a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
18
|
+
manager that drives it. See `CHANGELOG.md` for what 0.4.0 changes and what was measured.
|
|
19
|
+
|
|
20
|
+
Contract 0.4 is an additive MINOR over 0.3 that adds one optional manifest field,
|
|
21
|
+
`may_not_embed` (a boolean, default false; valid only in a manifest that states 0.4): when
|
|
22
|
+
true, a host that embeds plug-in apps opens that plug-in's app only in a separate window. The
|
|
23
|
+
library records and shows it and never verifies it; changing it in an upgrade asks for no
|
|
24
|
+
consent.
|
|
25
|
+
|
|
26
|
+
Contract 0.3 is an additive MINOR over 0.2 that FREEZES the manifest schema: optional
|
|
27
|
+
`capabilities` (`agent-messaging` is defined) and `warnings` (`{id, title, text}`, each
|
|
28
|
+
acknowledged on its own, its sha256 stored in the consent record); an optional
|
|
29
|
+
`Host.policy` hook (host-required warnings, refusal by policy) and `Host.data_dir`;
|
|
30
|
+
consent only at install and at an upgrade that widens or changes the EULA, a capability
|
|
31
|
+
or a warning; a refuse that always stops (an upgrade with no gate and `accepted=False`
|
|
32
|
+
raises `OperatorDeclined`); an operator-attributed lifecycle record in `installs.jsonl`
|
|
33
|
+
(`operator`, `result`, `consent_id`, new events `configure` and `decline`); an advisory
|
|
34
|
+
for grant-bearing `config_schema` fields; and a keep-or-delete choice for the plug-in's
|
|
35
|
+
data folder at uninstall. A host that mounts the web manager MUST keep every
|
|
36
|
+
state-changing route out of agents' reach (`[CXC-PC-V03-HOST-AGENT-BLOCK]`): the
|
|
37
|
+
library cannot tell a person from an agent.
|
|
18
38
|
|
|
19
39
|
Contract 0.2 is an additive MINOR over 0.1: optional manifest fields `license`
|
|
20
40
|
(an SPDX expression, informational) and `eula` (a package-relative UTF-8 text
|
|
@@ -33,7 +53,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
33
53
|
|
|
34
54
|
| module | what |
|
|
35
55
|
|---|---|
|
|
36
|
-
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json`,
|
|
56
|
+
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json` and `schema/manifest-0.2.schema.json`, both byte-identical to the compose-plugins 0.2.0 files, `schema/manifest-0.3.schema.json`, byte-identical to the compose-plugins 0.3.0 file, and `schema/manifest-0.4.schema.json`, frozen at the tag; `schema_for(manifest)` picks by the manifest's `contract`), generated from the validator's own patterns |
|
|
37
57
|
| `compose_plugins.package` | reading `manifest.json` from a directory or a wheel WITHOUT executing anything, and the `manifest_sha256` rule (exact bytes, no canonicalization) |
|
|
38
58
|
| `compose_plugins.version` | the contract version rule: a host accepts the same MAJOR and a MINOR at or below its own, and refuses anything newer, naming both versions |
|
|
39
59
|
| `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
|
|
@@ -45,7 +65,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
45
65
|
| `compose_plugins.store` | the install records (the registry), stored config, and the append-only install event log `InstallLog` with its findings |
|
|
46
66
|
| `compose_plugins.web` | the plain Plugin Manager: server-rendered HTML, a mountable WSGI app that is correct under any URL prefix, with the host's auth hook and CSRF defence |
|
|
47
67
|
| `compose_plugins.conformance` | the conformance script (below) |
|
|
48
|
-
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA) |
|
|
68
|
+
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA); unmodified since 0.2 |
|
|
49
69
|
|
|
50
70
|
```python
|
|
51
71
|
from compose_plugins.package import read_manifest
|
|
@@ -64,7 +84,9 @@ non-conformant. It runs the hello-world lifecycle in nine steps (install with
|
|
|
64
84
|
consent, configure, start, health, a publish/subscribe round trip, an upgrade
|
|
65
85
|
to v2 with re-consent and config migration, disable, re-enable, and uninstall
|
|
66
86
|
with the retained topic tombstoned and the consent record kept). It then runs
|
|
67
|
-
negative controls NC1 to
|
|
87
|
+
negative controls NC1 to NC10 (NC9: a non-widening upgrade with `accepted=False`
|
|
88
|
+
stops and writes one `decline` entry; NC10: a grant-bearing config property draws a
|
|
89
|
+
named advisory and is not refused), each of which must fail loudly. This happens once
|
|
68
90
|
per host and per isolation level the host supports. At the subprocess level it
|
|
69
91
|
also checks that the child holds no network socket and that a child crash is
|
|
70
92
|
reported as `failed(<reason>)`.
|
|
@@ -85,7 +107,7 @@ plus the two members added in spec 95 r24:
|
|
|
85
107
|
installed.
|
|
86
108
|
- `host_section(fixture: str) -> dict` (optional): this host's own valid
|
|
87
109
|
section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
|
|
88
|
-
negative-control id `NC1` to `
|
|
110
|
+
negative-control id `NC1` to `NC10`. Before every install it hands to the
|
|
89
111
|
host, the runner writes that value at `hosts.<target.host.name>`, so the
|
|
90
112
|
consented `manifest_sha256` covers it. A target without the hook gets `{}`
|
|
91
113
|
there. The shared fixtures never decide a host's section: each host owns its
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
# compose-plugins
|
|
2
2
|
|
|
3
3
|
The shared plug-in contract library for ComposeIO's ComposeServer and for
|
|
4
|
-
Gnomon, implementing the Shared Plug-in Contract v0.
|
|
5
|
-
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta
|
|
6
|
-
a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
4
|
+
Gnomon, implementing the Shared Plug-in Contract v0.4 (ComposeIO spec 95,
|
|
5
|
+
`[SPEC:CXC-PLUGIN-CONTRACT]`, revision r24 plus its v0.2 delta plus the v0.3 and v0.4 deltas,
|
|
6
|
+
sections 18 and 20). It is the layer a plug-in is INSTALLED and CONSENTED to, plus the shared
|
|
7
|
+
manager that drives it. See `CHANGELOG.md` for what 0.4.0 changes and what was measured.
|
|
8
|
+
|
|
9
|
+
Contract 0.4 is an additive MINOR over 0.3 that adds one optional manifest field,
|
|
10
|
+
`may_not_embed` (a boolean, default false; valid only in a manifest that states 0.4): when
|
|
11
|
+
true, a host that embeds plug-in apps opens that plug-in's app only in a separate window. The
|
|
12
|
+
library records and shows it and never verifies it; changing it in an upgrade asks for no
|
|
13
|
+
consent.
|
|
14
|
+
|
|
15
|
+
Contract 0.3 is an additive MINOR over 0.2 that FREEZES the manifest schema: optional
|
|
16
|
+
`capabilities` (`agent-messaging` is defined) and `warnings` (`{id, title, text}`, each
|
|
17
|
+
acknowledged on its own, its sha256 stored in the consent record); an optional
|
|
18
|
+
`Host.policy` hook (host-required warnings, refusal by policy) and `Host.data_dir`;
|
|
19
|
+
consent only at install and at an upgrade that widens or changes the EULA, a capability
|
|
20
|
+
or a warning; a refuse that always stops (an upgrade with no gate and `accepted=False`
|
|
21
|
+
raises `OperatorDeclined`); an operator-attributed lifecycle record in `installs.jsonl`
|
|
22
|
+
(`operator`, `result`, `consent_id`, new events `configure` and `decline`); an advisory
|
|
23
|
+
for grant-bearing `config_schema` fields; and a keep-or-delete choice for the plug-in's
|
|
24
|
+
data folder at uninstall. A host that mounts the web manager MUST keep every
|
|
25
|
+
state-changing route out of agents' reach (`[CXC-PC-V03-HOST-AGENT-BLOCK]`): the
|
|
26
|
+
library cannot tell a person from an agent.
|
|
7
27
|
|
|
8
28
|
Contract 0.2 is an additive MINOR over 0.1: optional manifest fields `license`
|
|
9
29
|
(an SPDX expression, informational) and `eula` (a package-relative UTF-8 text
|
|
@@ -22,7 +42,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
22
42
|
|
|
23
43
|
| module | what |
|
|
24
44
|
|---|---|
|
|
25
|
-
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json`,
|
|
45
|
+
| `compose_plugins.manifest` | the v0.1 manifest validator (authoritative) and the shipped JSON Schemas, one per contract (`schema/manifest-0.1.schema.json` and `schema/manifest-0.2.schema.json`, both byte-identical to the compose-plugins 0.2.0 files, `schema/manifest-0.3.schema.json`, byte-identical to the compose-plugins 0.3.0 file, and `schema/manifest-0.4.schema.json`, frozen at the tag; `schema_for(manifest)` picks by the manifest's `contract`), generated from the validator's own patterns |
|
|
26
46
|
| `compose_plugins.package` | reading `manifest.json` from a directory or a wheel WITHOUT executing anything, and the `manifest_sha256` rule (exact bytes, no canonicalization) |
|
|
27
47
|
| `compose_plugins.version` | the contract version rule: a host accepts the same MAJOR and a MINOR at or below its own, and refuses anything newer, naming both versions |
|
|
28
48
|
| `compose_plugins.consent` | consent content rendered from the manifest alone, the granted set, the widening rule, and the append-only consent-record store |
|
|
@@ -34,7 +54,7 @@ that is not ComposeIO can use the library on its own.
|
|
|
34
54
|
| `compose_plugins.store` | the install records (the registry), stored config, and the append-only install event log `InstallLog` with its findings |
|
|
35
55
|
| `compose_plugins.web` | the plain Plugin Manager: server-rendered HTML, a mountable WSGI app that is correct under any URL prefix, with the host's auth hook and CSRF defence |
|
|
36
56
|
| `compose_plugins.conformance` | the conformance script (below) |
|
|
37
|
-
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA) |
|
|
57
|
+
| `compose_plugins.fixtures` | the hello-world v1 and v2 conformance plug-ins, and `hello-world-eula` (contract 0.2, declares a EULA); unmodified since 0.2 |
|
|
38
58
|
|
|
39
59
|
```python
|
|
40
60
|
from compose_plugins.package import read_manifest
|
|
@@ -53,7 +73,9 @@ non-conformant. It runs the hello-world lifecycle in nine steps (install with
|
|
|
53
73
|
consent, configure, start, health, a publish/subscribe round trip, an upgrade
|
|
54
74
|
to v2 with re-consent and config migration, disable, re-enable, and uninstall
|
|
55
75
|
with the retained topic tombstoned and the consent record kept). It then runs
|
|
56
|
-
negative controls NC1 to
|
|
76
|
+
negative controls NC1 to NC10 (NC9: a non-widening upgrade with `accepted=False`
|
|
77
|
+
stops and writes one `decline` entry; NC10: a grant-bearing config property draws a
|
|
78
|
+
named advisory and is not refused), each of which must fail loudly. This happens once
|
|
57
79
|
per host and per isolation level the host supports. At the subprocess level it
|
|
58
80
|
also checks that the child holds no network socket and that a child crash is
|
|
59
81
|
reported as `failed(<reason>)`.
|
|
@@ -74,7 +96,7 @@ plus the two members added in spec 95 r24:
|
|
|
74
96
|
installed.
|
|
75
97
|
- `host_section(fixture: str) -> dict` (optional): this host's own valid
|
|
76
98
|
section for a fixture id: `hello-world-v1`, `hello-world-v2`, or a
|
|
77
|
-
negative-control id `NC1` to `
|
|
99
|
+
negative-control id `NC1` to `NC10`. Before every install it hands to the
|
|
78
100
|
host, the runner writes that value at `hosts.<target.host.name>`, so the
|
|
79
101
|
consented `manifest_sha256` covers it. A target without the hook gets `{}`
|
|
80
102
|
there. The shared fixtures never decide a host's section: each host owns its
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""compose_plugins — the shared plug-in contract library ([SPEC:CXC-PLUGIN-CONTRACT],
|
|
2
|
-
contract 0.
|
|
2
|
+
contract 0.4: spec 95 r24 plus its v0.2 delta, [DELTA:CXC-PLUGIN-CONTRACT-V0-2-DELTA],
|
|
3
|
+
plus the v0.3 delta, section 18 of spec 95 ([CXC-PC-V03-BASIS]), plus the v0.4 delta,
|
|
4
|
+
section 20 ([CXC-PC-V04-BASIS])).
|
|
3
5
|
|
|
4
6
|
The manifest validator and JSON Schema (``manifest``), the no-execution manifest
|
|
5
7
|
and EULA reader and the manifest_sha256 rule (``package``), the version rule
|
|
@@ -11,16 +13,20 @@ subprocess runner (``runner``), the registry, config and install-event-log
|
|
|
11
13
|
stores (``store``), the plain web Plugin Manager (``web``), and the conformance
|
|
12
14
|
script (``conformance``) with its hello-world fixtures. See README.md.
|
|
13
15
|
|
|
14
|
-
Contract 0.2 adds these exports ([CXC-PC-V02-STORES-COMPAT] manager-signatures)
|
|
16
|
+
Contract 0.2 adds these exports ([CXC-PC-V02-STORES-COMPAT] manager-signatures);
|
|
17
|
+
contract 0.3 adds ``OperatorDeclined``, ``PolicyRefused`` and ``WarningAckRefused``
|
|
18
|
+
([CXC-PC-V03-STORES-COMPAT] manager-signatures).
|
|
15
19
|
"""
|
|
16
20
|
|
|
17
|
-
__version__ = "0.
|
|
21
|
+
__version__ = "0.4.0"
|
|
18
22
|
|
|
19
23
|
from .consent import eula_text_shown # noqa: E402
|
|
20
24
|
from .errors import ( # noqa: E402
|
|
21
|
-
EulaShaMismatch, InstallLogRefused,
|
|
25
|
+
EulaShaMismatch, InstallLogRefused, OperatorDeclined, PolicyRefused, PromptNotPrepared,
|
|
26
|
+
PromptStale, WarningAckRefused,
|
|
22
27
|
)
|
|
23
28
|
from .store import InstallLog, InstallLogFinding # noqa: E402
|
|
24
29
|
|
|
25
30
|
__all__ = ["EulaShaMismatch", "InstallLog", "InstallLogFinding", "InstallLogRefused",
|
|
26
|
-
"
|
|
31
|
+
"OperatorDeclined", "PolicyRefused", "PromptNotPrepared", "PromptStale",
|
|
32
|
+
"WarningAckRefused", "__version__", "eula_text_shown"]
|
|
@@ -42,7 +42,7 @@ from dataclasses import dataclass
|
|
|
42
42
|
from pathlib import Path
|
|
43
43
|
from typing import Any, Callable
|
|
44
44
|
|
|
45
|
-
from .errors import HostNameRefused, ManifestRefused, ManifestShaMismatch
|
|
45
|
+
from .errors import HostNameRefused, ManifestRefused, ManifestShaMismatch, OperatorDeclined
|
|
46
46
|
from .fixtures import package_dir
|
|
47
47
|
from .lifecycle import ConsentDenied
|
|
48
48
|
from .manifest import check_host_name
|
|
@@ -71,7 +71,7 @@ class Fail(AssertionError):
|
|
|
71
71
|
#: the script's own fixture ids, the only values ``host_section`` is called with
|
|
72
72
|
#: ([CXC-PC-CONFORMANCE-SCRIPT] ``host-section-hook``, spec 95 r24)
|
|
73
73
|
FIXTURE_IDS = ("hello-world-v1", "hello-world-v2",
|
|
74
|
-
"NC1", "NC2", "NC3", "NC4", "NC5", "NC6", "NC7", "NC8")
|
|
74
|
+
"NC1", "NC2", "NC3", "NC4", "NC5", "NC6", "NC7", "NC8", "NC9", "NC10")
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
class ConformanceRefused(Exception):
|
|
@@ -601,6 +601,154 @@ def nc8(r: Run, t) -> None:
|
|
|
601
601
|
check(t.manager.state(DOMAIN) == "installed", "hello-world's own manifest did not install")
|
|
602
602
|
|
|
603
603
|
|
|
604
|
+
def _web_decide(t, path: str, form: dict, decision: str) -> "tuple[str, str]":
|
|
605
|
+
"""POST ``form`` plus ``decision`` to the library's web manager mounted on the target's
|
|
606
|
+
manager under an empty prefix, as a same-origin request with a valid CSRF token and a
|
|
607
|
+
script-only identity (the target's own auth hook is replaced on the instance for the
|
|
608
|
+
call and put back). Returns (status, Location)."""
|
|
609
|
+
import io
|
|
610
|
+
from urllib.parse import urlencode
|
|
611
|
+
from .web import PluginManagerApp
|
|
612
|
+
host = t.host
|
|
613
|
+
had = "auth_hook" in vars(host)
|
|
614
|
+
old = vars(host).get("auth_hook")
|
|
615
|
+
host.auth_hook = lambda environ: environ.get("_conformance_operator")
|
|
616
|
+
try:
|
|
617
|
+
app = PluginManagerApp(t.manager)
|
|
618
|
+
ident = "conformance-operator"
|
|
619
|
+
body = urlencode({**form, "decision": decision, "csrf": app.csrf_token(ident)}).encode()
|
|
620
|
+
environ = {"REQUEST_METHOD": "POST", "SCRIPT_NAME": "", "PATH_INFO": path,
|
|
621
|
+
"CONTENT_LENGTH": str(len(body)), "wsgi.input": io.BytesIO(body),
|
|
622
|
+
"wsgi.url_scheme": "http", "HTTP_HOST": "127.0.0.1:8080",
|
|
623
|
+
"REMOTE_ADDR": "127.0.0.1", "_conformance_operator": ident}
|
|
624
|
+
out: dict = {}
|
|
625
|
+
app(environ, lambda status, headers: out.update(status=status, headers=dict(headers)))
|
|
626
|
+
return out["status"], out["headers"].get("Location", "")
|
|
627
|
+
finally:
|
|
628
|
+
if had:
|
|
629
|
+
host.auth_hook = old
|
|
630
|
+
else:
|
|
631
|
+
del host.auth_hook
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
@_fresh
|
|
635
|
+
def nc9(r: Run, t) -> None:
|
|
636
|
+
"""[CXC-PC-V03-NC-UPGRADE-DECLINED]: a non-widening upgrade with
|
|
637
|
+
``accepted=False`` aborts with no change and writes one ``decline`` entry."""
|
|
638
|
+
m = t.manager
|
|
639
|
+
r.install(t, r.fixture(t, "v1", "NC9"))
|
|
640
|
+
m.configure(DOMAIN, {"greeting": "nc9"})
|
|
641
|
+
m.enable(DOMAIN)
|
|
642
|
+
check(settle(t, lambda s: s == "running") == "running", "v1 did not reach running")
|
|
643
|
+
root = Path(t.host.state_root)
|
|
644
|
+
cfg = root / "config" / f"{DOMAIN}.json"
|
|
645
|
+
snap = lambda: ((root / "installs.json").read_bytes(), # noqa: E731
|
|
646
|
+
sorted(str(p.relative_to(t.host.install_root))
|
|
647
|
+
for p in t.host.install_root.rglob("*") if p.is_file()))
|
|
648
|
+
v1b = r.fixture(t, "v1", "NC9", lambda d: d.update(version="1.0.1"))
|
|
649
|
+
p = m.prepare_upgrade(v1b)
|
|
650
|
+
check(p.gate is False, "a version-only upgrade claims it needs the consent gate")
|
|
651
|
+
before, n_consent, n_log = snap(), len(m.consent.records()), len(m.install_log.events())
|
|
652
|
+
cfg_before = cfg.read_bytes()
|
|
653
|
+
log_before = [(e["seq"], e["consent_basis"], e["consent_id"]) for e in m.install_log.events()]
|
|
654
|
+
try:
|
|
655
|
+
m.upgrade(v1b, consented_sha256=p.manifest_sha256, operator=t.operator,
|
|
656
|
+
accepted=False)
|
|
657
|
+
except OperatorDeclined as exc:
|
|
658
|
+
r.observe("refusal", exc)
|
|
659
|
+
check("DECLINED by the operator" in str(exc), "the refusal does not say declined")
|
|
660
|
+
else:
|
|
661
|
+
raise Fail("a declined upgrade went ahead")
|
|
662
|
+
check(snap() == before, "installs.json or the install root changed")
|
|
663
|
+
check(len(m.consent.records()) == n_consent, "a consent record was written")
|
|
664
|
+
new = m.install_log.events()[n_log:]
|
|
665
|
+
r.observe("log entries added", [(e["event"], e.get("result")) for e in new])
|
|
666
|
+
check(len(new) == 1 and new[0]["event"] == "decline" and new[0]["result"] == "declined"
|
|
667
|
+
and new[0]["consent"] is None, "not exactly one decline entry")
|
|
668
|
+
check(m.record(DOMAIN)["version"] == "1.0.0" and m.state(DOMAIN) == "enabled",
|
|
669
|
+
"v1 is not still enabled")
|
|
670
|
+
# [CXC-PC-V03-RULING-CONFORMANCE-NC9]: the spec's full `expected` list
|
|
671
|
+
check(cfg.read_bytes() == cfg_before, "the stored config changed")
|
|
672
|
+
check(m.status(DOMAIN) == "running", f"v1 is not running ({m.status(DOMAIN)})")
|
|
673
|
+
check(new[0]["consent_basis"] == "none" and new[0]["consent_id"] is None,
|
|
674
|
+
"the decline entry carries a consent_basis or consent_id")
|
|
675
|
+
check([(e["seq"], e["consent_basis"], e["consent_id"])
|
|
676
|
+
for e in m.install_log.events()[:n_log]] == log_before,
|
|
677
|
+
"an earlier entry's consent_basis or consent_id changed")
|
|
678
|
+
# [CXC-PC-V03-RULING-CONFORMANCE-NC9] the web half: the web manager's no-gate upgrade
|
|
679
|
+
# screen, answered with Cancel and with Refuse, redirects to the plug-in's detail page
|
|
680
|
+
# and changes nothing; each writes one `decline` entry (the library's own half above)
|
|
681
|
+
for decision in ("cancel", "refuse"):
|
|
682
|
+
n_before = len(m.install_log.events())
|
|
683
|
+
st, location = _web_decide(t, f"/plugin/{DOMAIN}/upgrade/decide",
|
|
684
|
+
{"source": str(v1b), "sha256": p.manifest_sha256}, decision)
|
|
685
|
+
r.observe(f"web decision={decision}", f"{st} -> {location}")
|
|
686
|
+
check(st.startswith("303") and location == f"/plugin/{DOMAIN}",
|
|
687
|
+
f"web {decision}: not a 303 to the detail page ({st} {location})")
|
|
688
|
+
check(snap() == before and cfg.read_bytes() == cfg_before,
|
|
689
|
+
f"web {decision}: installs.json, the code tree or the config changed")
|
|
690
|
+
check(len(m.consent.records()) == n_consent, f"web {decision}: a consent record was written")
|
|
691
|
+
added = m.install_log.events()[n_before:]
|
|
692
|
+
check(len(added) == 1 and added[0]["event"] == "decline"
|
|
693
|
+
and added[0]["consent"] is None and added[0]["consent_id"] is None,
|
|
694
|
+
f"web {decision}: not exactly one decline entry")
|
|
695
|
+
check(m.record(DOMAIN)["version"] == "1.0.0" and m.status(DOMAIN) == "running",
|
|
696
|
+
f"web {decision}: v1 is not still running")
|
|
697
|
+
m.upgrade(v1b, consented_sha256=p.manifest_sha256, operator=t.operator, accepted=True)
|
|
698
|
+
check(m.record(DOMAIN)["version"] == "1.0.1", "the accepted upgrade did not upgrade")
|
|
699
|
+
check(len(m.consent.records()) == n_consent, "a no-gate upgrade wrote a consent record")
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
@_fresh
|
|
703
|
+
def nc10(r: Run, t) -> None:
|
|
704
|
+
"""[CXC-PC-V03-NC-GRANT-BEARING-CONFIG]: a 0.3 manifest whose config_schema
|
|
705
|
+
names a grant-bearing property draws one named advisory and is NOT refused;
|
|
706
|
+
the same manifest stating 0.2 draws none."""
|
|
707
|
+
cases = {
|
|
708
|
+
"target_host": ({"target_host": {"type": "string"}},
|
|
709
|
+
"config_schema/properties/target_host"),
|
|
710
|
+
"site": ({"site": {"type": "string", "format": "uri"}},
|
|
711
|
+
"config_schema/properties/site"),
|
|
712
|
+
"$defs": (None, "config_schema/$defs/endpoint/properties/data_path"),
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
def edit_for(name: str, contract: str):
|
|
716
|
+
def edit(d: dict) -> None:
|
|
717
|
+
d["contract"] = contract
|
|
718
|
+
props, _ = cases[name]
|
|
719
|
+
if props is not None:
|
|
720
|
+
d["config_schema"]["properties"].update(props)
|
|
721
|
+
else:
|
|
722
|
+
d["config_schema"]["$defs"] = {"endpoint": {"type": "object", "properties": {
|
|
723
|
+
"data_path": {"type": "string"}}}}
|
|
724
|
+
return edit
|
|
725
|
+
for name, (_, pointer) in cases.items():
|
|
726
|
+
for contract, want in (("0.3", [pointer]), ("0.2", [])):
|
|
727
|
+
tt = r.new_target()
|
|
728
|
+
try:
|
|
729
|
+
p = tt.manager.prepare_install(
|
|
730
|
+
r.fixture(tt, "v1", "NC10", edit_for(name, contract)))
|
|
731
|
+
got = [a.field for a in p.manifest.advisories]
|
|
732
|
+
r.observe(f"{name} stating {contract}: advisories", got)
|
|
733
|
+
check(got == want, f"{name} {contract}: advisories {got} != {want}")
|
|
734
|
+
line = f"config field {pointer} looks grant-bearing (structural check; not verified)"
|
|
735
|
+
check((line in p.content.text()) == bool(want), "consent line wrong")
|
|
736
|
+
tt.manager.install(p.source, consented_sha256=p.manifest_sha256,
|
|
737
|
+
operator=tt.operator, accepted=True)
|
|
738
|
+
check(tt.manager.state(DOMAIN) == "installed", f"{name} {contract} not installed")
|
|
739
|
+
finally:
|
|
740
|
+
tt.close()
|
|
741
|
+
tt = r.new_target()
|
|
742
|
+
try:
|
|
743
|
+
def plain(d: dict) -> None:
|
|
744
|
+
d["contract"] = "0.3"
|
|
745
|
+
d["config_schema"]["properties"]["repeat"] = {"type": "integer"}
|
|
746
|
+
p = tt.manager.prepare_install(r.fixture(tt, "v1", "NC10", plain))
|
|
747
|
+
check(list(p.manifest.advisories) == [], "greeting and repeat drew an advisory")
|
|
748
|
+
finally:
|
|
749
|
+
tt.close()
|
|
750
|
+
|
|
751
|
+
|
|
604
752
|
@_fresh
|
|
605
753
|
def nc_r15(r: Run, t) -> None:
|
|
606
754
|
_refused_at_install(r, t, "hello-world-v1",
|
|
@@ -650,6 +798,8 @@ STEPS: "tuple[Step, ...]" = (
|
|
|
650
798
|
Step("NC6", "widening-refused", "CXC-PC-NC-WIDENING-REFUSED", nc6),
|
|
651
799
|
Step("NC7", "host-provided-requirement", "CXC-PC-NC-HOST-PROVIDED-REQUIREMENT", nc7),
|
|
652
800
|
Step("NC8", "malformed-permission", "CXC-PC-NC-MALFORMED-PERMISSION", nc8),
|
|
801
|
+
Step("NC9", "upgrade-declined", "CXC-PC-V03-NC-UPGRADE-DECLINED", nc9),
|
|
802
|
+
Step("NC10", "grant-bearing-config", "CXC-PC-V03-NC-GRANT-BEARING-CONFIG", nc10),
|
|
653
803
|
Step("R15", "requirements-refused-in-v0.1", "CXC-PC-LIFECYCLE-INSTALL (r15)", nc_r15),
|
|
654
804
|
Step("H1", "degraded-empty-greeting", "CXC-PC-HELLO-V1 / LIFECYCLE-HEALTH", h1_degraded),
|
|
655
805
|
Step("L1", "runner-refuses-non-AF_UNIX", "CXC-PC-RUNNER-LOCAL-ONLY", l1_refuses_non_unix,
|