@synopackageland/cli 0.3.10 → 0.4.1
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.
- package/LICENSE +21 -0
- package/README.md +57 -9
- package/dist/bin.js +1 -2
- package/dist/build-spk/generator.d.ts +0 -3
- package/dist/build-spk/generator.js +138 -287
- package/dist/build-spk/native-lifecycle.js +0 -3
- package/dist/build-spk/native-payload.js +0 -1
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +178 -151
- package/dist/compose/analyze.d.ts +1 -2
- package/dist/compose/analyze.js +5 -48
- package/dist/contract/unsupported-types.d.ts +10 -0
- package/dist/contract/unsupported-types.js +49 -0
- package/dist/contract/validate.js +25 -2
- package/dist/contract/web-launch.js +0 -2
- package/dist/deploy/deploy.d.ts +1 -4
- package/dist/deploy/deploy.js +45 -156
- package/dist/deploy/homes-values.js +1 -1
- package/dist/deploy/plan.d.ts +18 -0
- package/dist/deploy/plan.js +54 -0
- package/dist/deploy/spk-version.d.ts +2 -14
- package/dist/deploy/spk-version.js +25 -111
- package/dist/dev.d.ts +1 -3
- package/dist/dev.js +14 -28
- package/dist/error-registry.js +830 -862
- package/dist/host/dsm-client.js +12 -272
- package/dist/host/dsm-port-profile.d.ts +0 -1
- package/dist/host/dsm-port-profile.js +0 -2
- package/dist/host/types.d.ts +1 -83
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6
- package/dist/info.d.ts +0 -1
- package/dist/info.js +3 -10
- package/dist/init.d.ts +15 -1
- package/dist/init.js +128 -12
- package/dist/log.js +2 -3
- package/dist/native/validate.js +0 -1
- package/dist/standalone/binary.d.ts +9 -0
- package/dist/standalone/binary.js +67 -0
- package/dist/standalone/build.d.ts +25 -0
- package/dist/standalone/build.js +110 -0
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +26 -0
- package/dist/standalone/dsm-window.js +291 -0
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +21 -0
- package/dist/standalone/helper.js +105 -0
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/i18n.d.ts +28 -0
- package/dist/standalone/i18n.js +161 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +23 -0
- package/dist/standalone/inspect-spk.js +209 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +73 -0
- package/dist/standalone/manifest.js +279 -0
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.d.ts +7 -0
- package/dist/standalone/root-messages.js +259 -0
- package/dist/standalone/root-ops.d.ts +42 -0
- package/dist/standalone/root-ops.js +101 -0
- package/dist/standalone/root-window.d.ts +36 -0
- package/dist/standalone/root-window.js +302 -0
- package/dist/standalone/spk.d.ts +23 -0
- package/dist/standalone/spk.js +192 -0
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/binary/synology-app.yaml +7 -0
- package/dist/templates/hello-files/compose.yaml +0 -1
- package/dist/templates/hello-web/compose.yaml +13 -10
- package/dist/templates/hello-web/html/app.js +1 -23
- package/dist/templates/hello-web/html/index.html +1 -3
- package/dist/templates/hello-web-page/compose.yaml +13 -10
- package/dist/templates/hello-web-page/html/app.js +1 -23
- package/dist/templates/hello-web-page/html/index.html +1 -3
- package/dist/templates/native-go/README.md +324 -0
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/dist/templates/native-go/backend/go.mod +7 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +104 -0
- package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/dist/templates/native-go/backend/internal/api/server.go +159 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +138 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +334 -0
- package/dist/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/dsm-package.yaml +58 -0
- package/dist/templates/native-go/gitignore +1 -0
- package/dist/templates/native-go/i18n/glossary.json +662 -0
- package/dist/templates/native-go/i18n/messages/de.json +28 -0
- package/dist/templates/native-go/i18n/messages/en.json +28 -0
- package/dist/templates/native-go/i18n/messages/es.json +28 -0
- package/dist/templates/native-go/i18n/messages/fr.json +28 -0
- package/dist/templates/native-go/i18n/messages/it.json +28 -0
- package/dist/templates/native-go/i18n/messages/ja.json +28 -0
- package/dist/templates/native-go/i18n/messages/ko.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/dist/templates/native-go/ui/app.css +35 -0
- package/dist/templates/native-go/ui/app.js +101 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
- package/dist/templates/native-go-better-auth/node/build.mjs +4 -0
- package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/dist/templates/native-go-better-auth/node/package.json +1 -0
- package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/dist/templates/native-go-root/root/whoami.sh +6 -0
- package/dist/templates/native-go-vue/README.md +224 -0
- package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/dist/templates/native-go-vue/frontend/package.json +6 -0
- package/dist/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/dist/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +31 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/dist/templates/native-go-vue/gitignore +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +11 -7
- package/package.json +5 -8
- package/schema/synology-app.schema.json +36 -37
- package/skills/SKILL.md +4 -48
- package/skills/reference/create.md +11 -83
- package/skills/reference/deploy.md +7 -78
- package/skills/reference/diagnose.md +4 -101
- package/skills/reference/files.md +5 -41
- package/skills/reference/identity.md +3 -29
- package/skills/reference/wrap.md +0 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/binary/synology-app.yaml +7 -0
- package/templates/hello-files/compose.yaml +0 -1
- package/templates/hello-web/compose.yaml +13 -10
- package/templates/hello-web/html/app.js +1 -23
- package/templates/hello-web/html/index.html +1 -3
- package/templates/hello-web-page/compose.yaml +13 -10
- package/templates/hello-web-page/html/app.js +1 -23
- package/templates/hello-web-page/html/index.html +1 -3
- package/templates/native-go/README.md +324 -0
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/app/main.go +49 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/templates/native-go/backend/go.mod +7 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/errors.go +33 -0
- package/templates/native-go/backend/internal/api/registry.go +104 -0
- package/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/templates/native-go/backend/internal/api/server.go +159 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/templates/native-go/backend/internal/app/routes.go +138 -0
- package/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +424 -0
- package/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/templates/native-go/backend/internal/helper/status.go +334 -0
- package/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/dsm-package.yaml +58 -0
- package/templates/native-go/gitignore +1 -0
- package/templates/native-go/i18n/glossary.json +662 -0
- package/templates/native-go/i18n/messages/de.json +28 -0
- package/templates/native-go/i18n/messages/en.json +28 -0
- package/templates/native-go/i18n/messages/es.json +28 -0
- package/templates/native-go/i18n/messages/fr.json +28 -0
- package/templates/native-go/i18n/messages/it.json +28 -0
- package/templates/native-go/i18n/messages/ja.json +28 -0
- package/templates/native-go/i18n/messages/ko.json +28 -0
- package/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/templates/native-go/ui/app.css +35 -0
- package/templates/native-go/ui/app.js +101 -0
- package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/templates/native-go-better-auth/node/app.mjs +72 -0
- package/templates/native-go-better-auth/node/build.mjs +4 -0
- package/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/templates/native-go-better-auth/node/package.json +1 -0
- package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/templates/native-go-root/root/whoami.sh +6 -0
- package/templates/native-go-vue/README.md +224 -0
- package/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/templates/native-go-vue/frontend/package.json +6 -0
- package/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +31 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/templates/native-go-vue/gitignore +2 -0
- package/dist/attestation/app-package.d.ts +0 -86
- package/dist/attestation/app-package.js +0 -206
- package/dist/attestation/install-on-host.d.ts +0 -14
- package/dist/attestation/install-on-host.js +0 -52
- package/dist/attestation/keyring.d.ts +0 -21
- package/dist/attestation/keyring.js +0 -168
- package/dist/attestation/platform-service.d.ts +0 -70
- package/dist/attestation/platform-service.js +0 -250
- package/dist/build-spk/broker-glue.d.ts +0 -16
- package/dist/build-spk/broker-glue.js +0 -40
- package/dist/deploy/catalog-publish.d.ts +0 -3
- package/dist/deploy/catalog-publish.js +0 -7
- package/dist/doctor.d.ts +0 -22
- package/dist/doctor.js +0 -822
- package/dist/error-collector.d.ts +0 -2
- package/dist/error-collector.js +0 -46
- package/dist/host/broker-paths.d.ts +0 -1
- package/dist/host/broker-paths.js +0 -1
- package/dist/host/broker-upgrade-preflight.d.ts +0 -61
- package/dist/host/broker-upgrade-preflight.js +0 -156
- package/dist/host/digests.d.ts +0 -5
- package/dist/host/digests.js +0 -63
- package/dist/host/fake-nas.d.ts +0 -49
- package/dist/host/fake-nas.js +0 -193
- package/dist/mock-broker/bootstrap.d.ts +0 -2
- package/dist/mock-broker/bootstrap.js +0 -8
- package/dist/mock-broker/files.d.ts +0 -60
- package/dist/mock-broker/files.js +0 -408
- package/dist/mock-broker/oidc.d.ts +0 -31
- package/dist/mock-broker/oidc.js +0 -161
- package/dist/mock-broker/path.d.ts +0 -9
- package/dist/mock-broker/path.js +0 -50
- package/dist/mock-broker/server.d.ts +0 -19
- package/dist/mock-broker/server.js +0 -350
- package/dist/publish/build-ledger.d.ts +0 -22
- package/dist/publish/build-ledger.js +0 -26
- package/dist/publish/community-path.d.ts +0 -6
- package/dist/publish/community-path.js +0 -41
- package/dist/publish/curated-release.d.ts +0 -78
- package/dist/publish/curated-release.js +0 -883
- package/dist/publish/file-build-ledger.d.ts +0 -18
- package/dist/publish/file-build-ledger.js +0 -268
- package/dist/publish/github-pr.d.ts +0 -25
- package/dist/publish/github-pr.js +0 -85
- package/dist/publish/github-repo.d.ts +0 -8
- package/dist/publish/github-repo.js +0 -21
- package/dist/publish/platform-service-release.d.ts +0 -60
- package/dist/publish/platform-service-release.js +0 -333
- package/dist/publish/preflight.d.ts +0 -24
- package/dist/publish/preflight.js +0 -138
- package/dist/publish/publish.d.ts +0 -27
- package/dist/publish/publish.js +0 -136
- package/dist/publish/sync-definition.d.ts +0 -4
- package/dist/publish/sync-definition.js +0 -48
- package/dist/release-bin.d.ts +0 -2
- package/dist/release-bin.js +0 -23
- package/dist/templates/hello-web/html/sdk.js +0 -68
- package/dist/templates/hello-web-page/html/sdk.js +0 -68
- package/dist/templates/native/synology-app.yaml +0 -7
- package/dist/test-host.d.ts +0 -15
- package/dist/test-host.js +0 -37
- package/templates/hello-web/html/sdk.js +0 -68
- package/templates/hello-web-page/html/sdk.js +0 -68
- package/templates/native/synology-app.yaml +0 -7
- /package/dist/templates/{native → binary}/native.yaml +0 -0
- /package/templates/{native → binary}/native.yaml +0 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// Package helper implements the opt-in per-package lifecycle contract. It has
|
|
2
|
+
// no file/grant/job API: all unimplemented operations fail closed.
|
|
3
|
+
package helper
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"context"
|
|
7
|
+
"crypto/rand"
|
|
8
|
+
"crypto/sha256"
|
|
9
|
+
"encoding/hex"
|
|
10
|
+
"encoding/json"
|
|
11
|
+
"errors"
|
|
12
|
+
"io"
|
|
13
|
+
"io/fs"
|
|
14
|
+
"net"
|
|
15
|
+
"os"
|
|
16
|
+
"path/filepath"
|
|
17
|
+
"regexp"
|
|
18
|
+
"syscall"
|
|
19
|
+
"time"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
type Inventory struct {
|
|
23
|
+
Package string `json:"package"`
|
|
24
|
+
Version string `json:"version"`
|
|
25
|
+
Protocol int `json:"protocol"`
|
|
26
|
+
PayloadDigest string `json:"payloadDigest"`
|
|
27
|
+
RegistryDigest string `json:"registryDigest"`
|
|
28
|
+
DataAccess string `json:"dataAccess,omitempty"`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var digestPattern = regexp.MustCompile(`^[a-f0-9]{64}$`)
|
|
32
|
+
var packagePattern = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]{1,63}$`)
|
|
33
|
+
var versionPattern = regexp.MustCompile(`^\d+(\.\d+){0,3}-\d{4}$`)
|
|
34
|
+
|
|
35
|
+
func (i Inventory) Valid() bool {
|
|
36
|
+
mode := i.DataAccess == "" || i.Protocol == DataProtocol && (i.DataAccess == "unavailable" || i.DataAccess == "relaxed")
|
|
37
|
+
return mode && packagePattern.MatchString(i.Package) && versionPattern.MatchString(i.Version) && (i.Protocol == 1 || i.Protocol == DataProtocol) && digestPattern.MatchString(i.PayloadDigest) && digestPattern.MatchString(i.RegistryDigest)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type Record struct {
|
|
41
|
+
Schema int `json:"schema,omitempty"`
|
|
42
|
+
Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
|
|
43
|
+
Inventory Inventory `json:"inventory"`
|
|
44
|
+
Enabled bool `json:"enabled"`
|
|
45
|
+
Residual bool `json:"residual,omitempty"`
|
|
46
|
+
}
|
|
47
|
+
type Request struct {
|
|
48
|
+
Inventory Inventory `json:"inventory"`
|
|
49
|
+
Op string `json:"op"`
|
|
50
|
+
Nonce string `json:"nonce"`
|
|
51
|
+
}
|
|
52
|
+
type Response struct {
|
|
53
|
+
Inventory Inventory `json:"inventory"`
|
|
54
|
+
Nonce string `json:"nonce"`
|
|
55
|
+
OK bool `json:"ok"`
|
|
56
|
+
Error string `json:"error,omitempty"`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func Respond(i Inventory, disabled bool, req Request) Response {
|
|
60
|
+
r := Response{Inventory: i, Nonce: req.Nonce}
|
|
61
|
+
switch {
|
|
62
|
+
case disabled:
|
|
63
|
+
r.Error = "disabled"
|
|
64
|
+
case !i.Valid() || req.Inventory != i:
|
|
65
|
+
r.Error = "incompatible"
|
|
66
|
+
case req.Op != "health":
|
|
67
|
+
r.Error = "unsupported"
|
|
68
|
+
default:
|
|
69
|
+
r.OK = true
|
|
70
|
+
}
|
|
71
|
+
return r
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// State is safe to expose to any authenticated DSM user. Paths, PIDs, worker
|
|
75
|
+
// internals, scheduler definitions and raw errors never enter this envelope.
|
|
76
|
+
type State struct {
|
|
77
|
+
State string `json:"state"`
|
|
78
|
+
Reason string `json:"reason"`
|
|
79
|
+
PackageRunning string `json:"packageRunning"`
|
|
80
|
+
Scheduler string `json:"scheduler"`
|
|
81
|
+
Cleanup string `json:"cleanup,omitempty"`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type Client struct {
|
|
85
|
+
Expected Inventory
|
|
86
|
+
StateDir, RunDir string
|
|
87
|
+
// Production uses UID 0 and RootPeer. Tests inject only local fixture identity.
|
|
88
|
+
Owner uint32
|
|
89
|
+
Peer func(*net.UnixConn) error
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func NewClient(i Inventory) Client {
|
|
93
|
+
return Client{Expected: i, StateDir: "/var/lib/synopkgland-" + i.Package, RunDir: "/run/synopkgland-helper-" + i.Package, Peer: RootPeer}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// LocalClient is a nonprivileged diagnostic entry point for package hooks.
|
|
97
|
+
// Hashing the local executable establishes only the expected build inventory;
|
|
98
|
+
// readiness still requires the protected record and root socket handshake.
|
|
99
|
+
func LocalClient(i Inventory) (Client, error) {
|
|
100
|
+
exe, err := os.Executable()
|
|
101
|
+
if err != nil {
|
|
102
|
+
return Client{}, err
|
|
103
|
+
}
|
|
104
|
+
f, err := os.Open(exe)
|
|
105
|
+
if err != nil {
|
|
106
|
+
return Client{}, err
|
|
107
|
+
}
|
|
108
|
+
defer f.Close()
|
|
109
|
+
h := sha256.New()
|
|
110
|
+
if _, err := io.Copy(h, io.LimitReader(f, (64<<20)+1)); err != nil {
|
|
111
|
+
return Client{}, err
|
|
112
|
+
}
|
|
113
|
+
i.PayloadDigest = hex.EncodeToString(h.Sum(nil))
|
|
114
|
+
if !i.Valid() {
|
|
115
|
+
return Client{}, errTrust
|
|
116
|
+
}
|
|
117
|
+
return NewClient(i), nil
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func (c Client) CheckStopped(ctx context.Context) error {
|
|
121
|
+
s := c.Status(ctx)
|
|
122
|
+
if s.Cleanup != "" || (s.State != "not-enabled" && s.State != "stopped" && s.State != "needs-approval") {
|
|
123
|
+
return errors.New("approved helper teardown required")
|
|
124
|
+
}
|
|
125
|
+
for _, file := range []string{"process.json", "helper.sock", "supervisor.sock"} {
|
|
126
|
+
if _, err := os.Lstat(filepath.Join(c.RunDir, file)); !errors.Is(err, fs.ErrNotExist) {
|
|
127
|
+
return errors.New("helper residue; approved teardown required")
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return nil
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var errTrust = errors.New("untrusted helper state")
|
|
134
|
+
|
|
135
|
+
func protected(path string, owner uint32, directory bool) error {
|
|
136
|
+
st, err := os.Lstat(path)
|
|
137
|
+
if err != nil {
|
|
138
|
+
return err
|
|
139
|
+
}
|
|
140
|
+
s, ok := st.Sys().(*syscall.Stat_t)
|
|
141
|
+
if !ok || s.Uid != owner || st.Mode().Perm()&0022 != 0 || (directory && !st.IsDir()) || (!directory && !st.Mode().IsRegular()) {
|
|
142
|
+
return errTrust
|
|
143
|
+
}
|
|
144
|
+
return nil
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
func readRecord(dir string, owner uint32) (Record, error) {
|
|
148
|
+
var r Record
|
|
149
|
+
if err := protected(dir, owner, true); err != nil {
|
|
150
|
+
return r, err
|
|
151
|
+
}
|
|
152
|
+
f, err := os.OpenFile(filepath.Join(dir, "approval.json"), os.O_RDONLY|syscall.O_NOFOLLOW, 0)
|
|
153
|
+
if err != nil {
|
|
154
|
+
return r, err
|
|
155
|
+
}
|
|
156
|
+
defer f.Close()
|
|
157
|
+
st, err := f.Stat()
|
|
158
|
+
if err != nil {
|
|
159
|
+
return r, err
|
|
160
|
+
}
|
|
161
|
+
s, ok := st.Sys().(*syscall.Stat_t)
|
|
162
|
+
if !ok || s.Uid != owner || st.Mode().Perm()&0022 != 0 || !st.Mode().IsRegular() || st.Size() > 4096 {
|
|
163
|
+
return r, errTrust
|
|
164
|
+
}
|
|
165
|
+
d := json.NewDecoder(io.LimitReader(f, 4097))
|
|
166
|
+
d.DisallowUnknownFields()
|
|
167
|
+
var decoded struct {
|
|
168
|
+
Schema int `json:"schema,omitempty"`
|
|
169
|
+
Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
|
|
170
|
+
Inventory Inventory `json:"inventory"`
|
|
171
|
+
Enabled *bool `json:"enabled"`
|
|
172
|
+
Residual bool `json:"residual,omitempty"`
|
|
173
|
+
}
|
|
174
|
+
if d.Decode(&decoded) != nil || d.Decode(new(any)) != io.EOF || !decoded.Inventory.Valid() || decoded.Enabled == nil || !decoded.Lifecycle.valid() || (decoded.Schema != 0 && decoded.Schema != 2) {
|
|
175
|
+
return r, errTrust
|
|
176
|
+
}
|
|
177
|
+
r = Record{Schema: decoded.Schema, Inventory: decoded.Inventory, Enabled: *decoded.Enabled, Residual: decoded.Residual, Lifecycle: decoded.Lifecycle}
|
|
178
|
+
return r, nil
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
func (c Client) Status(ctx context.Context) State {
|
|
182
|
+
result := func(state, reason string) State {
|
|
183
|
+
return State{State: state, Reason: reason, PackageRunning: "unknown", Scheduler: "not-probed"}
|
|
184
|
+
}
|
|
185
|
+
if c.Expected.Package == "" {
|
|
186
|
+
return result("not-enabled", "not-requested")
|
|
187
|
+
}
|
|
188
|
+
if !c.Expected.Valid() {
|
|
189
|
+
return result("incompatible", "invalid-inventory")
|
|
190
|
+
}
|
|
191
|
+
r, err := readRecord(c.StateDir, c.Owner)
|
|
192
|
+
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
|
193
|
+
return result("incompatible", "untrusted-approval")
|
|
194
|
+
}
|
|
195
|
+
if err == nil && !r.Enabled {
|
|
196
|
+
s := result("not-enabled", "disabled")
|
|
197
|
+
if r.Residual {
|
|
198
|
+
s.Cleanup = "required"
|
|
199
|
+
}
|
|
200
|
+
return s
|
|
201
|
+
}
|
|
202
|
+
if err == nil && r.Inventory != c.Expected {
|
|
203
|
+
return result("incompatible", "inventory-mismatch")
|
|
204
|
+
}
|
|
205
|
+
if err == nil && r.Residual {
|
|
206
|
+
s := result("failed", "incomplete-transition")
|
|
207
|
+
s.Cleanup = "required"
|
|
208
|
+
return s
|
|
209
|
+
}
|
|
210
|
+
if err == nil && r.Lifecycle != nil && r.Lifecycle.Phase != "running" {
|
|
211
|
+
if e := protected(c.RunDir, c.Owner, true); e != nil && !errors.Is(e, fs.ErrNotExist) {
|
|
212
|
+
return result("incompatible", "untrusted-runtime")
|
|
213
|
+
}
|
|
214
|
+
if r.Lifecycle.Completion != "" {
|
|
215
|
+
path := filepath.Join(c.StateDir, "completion-"+r.Lifecycle.Epoch+".json")
|
|
216
|
+
st, e := os.Lstat(path)
|
|
217
|
+
ok := e == nil && st.Mode().IsRegular() && st.Mode().Perm() == 0600
|
|
218
|
+
if ok {
|
|
219
|
+
s, valid := st.Sys().(*syscall.Stat_t)
|
|
220
|
+
ok = valid && s.Uid == c.Owner
|
|
221
|
+
}
|
|
222
|
+
if ok && uint32(os.Geteuid()) == c.Owner {
|
|
223
|
+
_, e = completionRecord(c, r)
|
|
224
|
+
ok = e == nil
|
|
225
|
+
}
|
|
226
|
+
if !ok {
|
|
227
|
+
s := result("failed", "invalid-completion")
|
|
228
|
+
s.Cleanup = "required"
|
|
229
|
+
return s
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if !runtimeAbsent(c) {
|
|
234
|
+
s := result("failed", "incomplete-transition")
|
|
235
|
+
s.Cleanup = "required"
|
|
236
|
+
return s
|
|
237
|
+
}
|
|
238
|
+
return result("stopped", "admin-recover-required")
|
|
239
|
+
}
|
|
240
|
+
// Conflict has precedence over missing approval. Even an unapproved leftover
|
|
241
|
+
// socket is probed before claiming that authorization alone can fix it.
|
|
242
|
+
if e := protected(c.RunDir, c.Owner, true); e != nil && !errors.Is(e, fs.ErrNotExist) {
|
|
243
|
+
return result("incompatible", "untrusted-runtime")
|
|
244
|
+
}
|
|
245
|
+
socket := filepath.Join(c.RunDir, "helper.sock")
|
|
246
|
+
st, e := os.Lstat(socket)
|
|
247
|
+
if e == nil {
|
|
248
|
+
s, ok := st.Sys().(*syscall.Stat_t)
|
|
249
|
+
if !ok || s.Uid != c.Owner || st.Mode()&os.ModeSocket == 0 || st.Mode().Perm()&0002 != 0 {
|
|
250
|
+
return result("incompatible", "untrusted-socket")
|
|
251
|
+
}
|
|
252
|
+
state, reason := c.probe(ctx, socket)
|
|
253
|
+
if state != "ready" {
|
|
254
|
+
s := result(state, reason)
|
|
255
|
+
if state == "pending" {
|
|
256
|
+
if err == nil && r.Lifecycle != nil && r.Lifecycle.Phase == "running" {
|
|
257
|
+
s.PackageRunning = "running"
|
|
258
|
+
return s
|
|
259
|
+
}
|
|
260
|
+
s.State, s.Reason = "failed", "health-refused"
|
|
261
|
+
}
|
|
262
|
+
if r.Lifecycle != nil {
|
|
263
|
+
if _, err := readProcess(c.RunDir, c.Owner); err == nil {
|
|
264
|
+
s.State = "failed"
|
|
265
|
+
s.Cleanup = "required"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if reason == "lifecycle-fenced" {
|
|
269
|
+
s.Cleanup = "required"
|
|
270
|
+
}
|
|
271
|
+
return s
|
|
272
|
+
}
|
|
273
|
+
} else if !errors.Is(e, fs.ErrNotExist) {
|
|
274
|
+
return result("failed", "runtime-unreadable")
|
|
275
|
+
}
|
|
276
|
+
if err != nil {
|
|
277
|
+
return result("needs-approval", "approval-missing")
|
|
278
|
+
}
|
|
279
|
+
if e != nil {
|
|
280
|
+
return result("stopped", "runtime-missing")
|
|
281
|
+
}
|
|
282
|
+
s := result("ready", "live-handshake")
|
|
283
|
+
if r.Lifecycle != nil {
|
|
284
|
+
s.PackageRunning = "running"
|
|
285
|
+
}
|
|
286
|
+
return s
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
func (c Client) probe(ctx context.Context, socket string) (string, string) {
|
|
290
|
+
deadline := time.Now().Add(time.Second)
|
|
291
|
+
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
|
|
292
|
+
deadline = d
|
|
293
|
+
}
|
|
294
|
+
dialer := net.Dialer{Deadline: deadline}
|
|
295
|
+
conn, err := dialer.DialContext(ctx, "unix", socket)
|
|
296
|
+
if err != nil {
|
|
297
|
+
if errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, fs.ErrNotExist) {
|
|
298
|
+
return "stopped", "runtime-not-listening"
|
|
299
|
+
}
|
|
300
|
+
return "failed", "probe-failed"
|
|
301
|
+
}
|
|
302
|
+
defer conn.Close()
|
|
303
|
+
if c.Peer == nil || c.Peer(conn.(*net.UnixConn)) != nil {
|
|
304
|
+
return "incompatible", "untrusted-peer"
|
|
305
|
+
}
|
|
306
|
+
conn.SetDeadline(deadline)
|
|
307
|
+
var nonce [32]byte
|
|
308
|
+
if _, err := rand.Read(nonce[:]); err != nil {
|
|
309
|
+
return "failed", "probe-failed"
|
|
310
|
+
}
|
|
311
|
+
req := Request{c.Expected, "health", hex.EncodeToString(nonce[:])}
|
|
312
|
+
if json.NewEncoder(conn).Encode(req) != nil {
|
|
313
|
+
return "failed", "probe-failed"
|
|
314
|
+
}
|
|
315
|
+
var res Response
|
|
316
|
+
d := json.NewDecoder(io.LimitReader(conn, 4097))
|
|
317
|
+
d.DisallowUnknownFields()
|
|
318
|
+
if d.Decode(&res) != nil {
|
|
319
|
+
return "failed", "invalid-handshake"
|
|
320
|
+
}
|
|
321
|
+
if res.Nonce != req.Nonce || res.Inventory != c.Expected || res.Error == "incompatible" {
|
|
322
|
+
return "incompatible", "handshake-mismatch"
|
|
323
|
+
}
|
|
324
|
+
if !res.OK && res.Error == "reload-revalidating" {
|
|
325
|
+
return "pending", "reload-revalidating"
|
|
326
|
+
}
|
|
327
|
+
if !res.OK && res.Error == "fenced" {
|
|
328
|
+
return "failed", "lifecycle-fenced"
|
|
329
|
+
}
|
|
330
|
+
if !res.OK || res.Error != "" {
|
|
331
|
+
return "failed", "health-refused"
|
|
332
|
+
}
|
|
333
|
+
return "ready", "live-handshake"
|
|
334
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"net"
|
|
7
|
+
"os"
|
|
8
|
+
"path/filepath"
|
|
9
|
+
"strings"
|
|
10
|
+
"testing"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func fixture(t *testing.T) Client {
|
|
14
|
+
t.Helper()
|
|
15
|
+
i := Inventory{Package: "Fixture", Version: "1.0.0-0001", Protocol: 1, PayloadDigest: strings.Repeat("a", 64), RegistryDigest: strings.Repeat("b", 64)}
|
|
16
|
+
run, err := os.MkdirTemp("/tmp", "m1a-")
|
|
17
|
+
if err != nil {
|
|
18
|
+
t.Fatal(err)
|
|
19
|
+
}
|
|
20
|
+
t.Cleanup(func() { os.RemoveAll(run) })
|
|
21
|
+
return Client{Expected: i, StateDir: t.TempDir(), RunDir: run, Owner: uint32(os.Getuid()), Peer: func(*net.UnixConn) error { return nil }}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func record(t *testing.T, c Client, r Record) {
|
|
25
|
+
t.Helper()
|
|
26
|
+
b, _ := json.Marshal(r)
|
|
27
|
+
if err := os.WriteFile(filepath.Join(c.StateDir, "approval.json"), b, 0644); err != nil {
|
|
28
|
+
t.Fatal(err)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func live(t *testing.T, c Client, i Inventory, reply func(Request) Response) {
|
|
33
|
+
t.Helper()
|
|
34
|
+
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: filepath.Join(c.RunDir, "helper.sock"), Net: "unix"})
|
|
35
|
+
if err != nil {
|
|
36
|
+
t.Fatal(err)
|
|
37
|
+
}
|
|
38
|
+
t.Cleanup(func() { l.Close() })
|
|
39
|
+
go func() {
|
|
40
|
+
for {
|
|
41
|
+
conn, err := l.AcceptUnix()
|
|
42
|
+
if err != nil {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
go func() {
|
|
46
|
+
defer conn.Close()
|
|
47
|
+
var req Request
|
|
48
|
+
if json.NewDecoder(conn).Decode(&req) != nil {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
r := Respond(i, false, req)
|
|
52
|
+
if reply != nil {
|
|
53
|
+
r = reply(req)
|
|
54
|
+
}
|
|
55
|
+
json.NewEncoder(conn).Encode(r)
|
|
56
|
+
}()
|
|
57
|
+
}
|
|
58
|
+
}()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func TestSixStatesAndPriority(t *testing.T) {
|
|
62
|
+
c := fixture(t)
|
|
63
|
+
check := func(want string) {
|
|
64
|
+
t.Helper()
|
|
65
|
+
s := c.Status(context.Background())
|
|
66
|
+
if s.State != want {
|
|
67
|
+
t.Fatalf("want %s, got %+v", want, s)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
c.Expected = Inventory{}
|
|
71
|
+
check("not-enabled")
|
|
72
|
+
c.Expected = fixture(t).Expected
|
|
73
|
+
check("needs-approval")
|
|
74
|
+
record(t, c, Record{Inventory: c.Expected, Enabled: true})
|
|
75
|
+
check("stopped")
|
|
76
|
+
live(t, c, c.Expected, nil)
|
|
77
|
+
check("ready")
|
|
78
|
+
old := c.Expected
|
|
79
|
+
old.Protocol++
|
|
80
|
+
record(t, c, Record{Inventory: old, Enabled: true})
|
|
81
|
+
check("incompatible")
|
|
82
|
+
record(t, c, Record{Inventory: old, Enabled: false})
|
|
83
|
+
check("not-enabled")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func TestLiveProbeCannotBeReplacedByApprovalOrHistoricalOutput(t *testing.T) {
|
|
87
|
+
c := fixture(t)
|
|
88
|
+
record(t, c, Record{Inventory: c.Expected, Enabled: true})
|
|
89
|
+
if err := os.WriteFile(filepath.Join(c.RunDir, "helper.sock"), []byte("ready"), 0644); err != nil {
|
|
90
|
+
t.Fatal(err)
|
|
91
|
+
}
|
|
92
|
+
if got := c.Status(context.Background()).State; got != "incompatible" {
|
|
93
|
+
t.Fatal(got)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
func TestHandshakeFailuresAreRedacted(t *testing.T) {
|
|
98
|
+
for _, kind := range []string{"nonce", "protocol", "payload", "worker", "version", "peer"} {
|
|
99
|
+
t.Run(kind, func(t *testing.T) {
|
|
100
|
+
c := fixture(t)
|
|
101
|
+
record(t, c, Record{Inventory: c.Expected, Enabled: true})
|
|
102
|
+
live(t, c, c.Expected, func(req Request) Response {
|
|
103
|
+
r := Respond(c.Expected, false, req)
|
|
104
|
+
switch kind {
|
|
105
|
+
case "nonce":
|
|
106
|
+
r.Nonce = "replay"
|
|
107
|
+
case "protocol":
|
|
108
|
+
r.Inventory.Protocol++
|
|
109
|
+
case "payload":
|
|
110
|
+
r.Inventory.PayloadDigest = "foreign"
|
|
111
|
+
case "worker":
|
|
112
|
+
r.Inventory.RegistryDigest = "foreign"
|
|
113
|
+
case "version":
|
|
114
|
+
r.Inventory.Version = "old"
|
|
115
|
+
}
|
|
116
|
+
return r
|
|
117
|
+
})
|
|
118
|
+
if kind == "peer" {
|
|
119
|
+
c.Peer = func(*net.UnixConn) error { return os.ErrPermission }
|
|
120
|
+
}
|
|
121
|
+
s := c.Status(context.Background())
|
|
122
|
+
if s.State != "incompatible" {
|
|
123
|
+
t.Fatalf("%+v", s)
|
|
124
|
+
}
|
|
125
|
+
b, _ := json.Marshal(s)
|
|
126
|
+
if strings.Contains(string(b), c.StateDir) || strings.Contains(string(b), "foreign") {
|
|
127
|
+
t.Fatal(string(b))
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
c := fixture(t)
|
|
132
|
+
record(t, c, Record{Inventory: c.Expected, Enabled: true})
|
|
133
|
+
live(t, c, c.Expected, func(req Request) Response { return Response{Inventory: c.Expected, Nonce: req.Nonce, Error: "failed"} })
|
|
134
|
+
if c.Status(context.Background()).State != "failed" {
|
|
135
|
+
t.Fatal("health failure must be failed")
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
func TestUntrustedPersistentStateFailsClosed(t *testing.T) {
|
|
140
|
+
for _, kind := range []string{"writable", "symlink", "malformed"} {
|
|
141
|
+
t.Run(kind, func(t *testing.T) {
|
|
142
|
+
c := fixture(t)
|
|
143
|
+
record(t, c, Record{Inventory: c.Expected, Enabled: true})
|
|
144
|
+
p := filepath.Join(c.StateDir, "approval.json")
|
|
145
|
+
switch kind {
|
|
146
|
+
case "writable":
|
|
147
|
+
os.Chmod(p, 0666)
|
|
148
|
+
case "symlink":
|
|
149
|
+
os.Rename(p, p+".real")
|
|
150
|
+
os.Symlink(p+".real", p)
|
|
151
|
+
case "malformed":
|
|
152
|
+
os.WriteFile(p, []byte(`{"enabled":false}`), 0644)
|
|
153
|
+
}
|
|
154
|
+
if c.Status(context.Background()).State != "incompatible" {
|
|
155
|
+
t.Fatal("untrusted state accepted")
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func TestOldHelperRejectsNewInventoryAndAllUnimplementedWork(t *testing.T) {
|
|
162
|
+
i := fixture(t).Expected
|
|
163
|
+
for _, field := range []string{"protocol", "payload", "workers", "version", "package"} {
|
|
164
|
+
new := i
|
|
165
|
+
switch field {
|
|
166
|
+
case "protocol":
|
|
167
|
+
new.Protocol++
|
|
168
|
+
case "payload":
|
|
169
|
+
new.PayloadDigest = strings.Repeat("c", 64)
|
|
170
|
+
case "workers":
|
|
171
|
+
new.RegistryDigest = strings.Repeat("c", 64)
|
|
172
|
+
case "version":
|
|
173
|
+
new.Version = "2.0.0-0001"
|
|
174
|
+
case "package":
|
|
175
|
+
new.Package = "Other"
|
|
176
|
+
}
|
|
177
|
+
r := Respond(i, false, Request{Inventory: new, Op: "work", Nonce: "test"})
|
|
178
|
+
if r.Error != "incompatible" || r.OK {
|
|
179
|
+
t.Fatalf("%s: %+v", field, r)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if r := Respond(i, true, Request{Inventory: i, Op: "health"}); r.OK || r.Error != "disabled" {
|
|
183
|
+
t.Fatal(r)
|
|
184
|
+
}
|
|
185
|
+
if r := Respond(i, false, Request{Inventory: i, Op: "work"}); r.OK || r.Error != "unsupported" {
|
|
186
|
+
t.Fatal(r)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
func TestMissingEnableFieldIsNotARevocationRecord(t *testing.T) {
|
|
191
|
+
c := fixture(t)
|
|
192
|
+
b, _ := json.Marshal(map[string]any{"inventory": c.Expected})
|
|
193
|
+
os.WriteFile(filepath.Join(c.StateDir, "approval.json"), b, 0644)
|
|
194
|
+
if c.Status(context.Background()).State != "incompatible" {
|
|
195
|
+
t.Fatal("incomplete approval treated as trusted disable")
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
func TestProcessRecordIsNotReadableByOrdinaryOSUsers(t *testing.T) {
|
|
200
|
+
c, _ := controlFixture(t)
|
|
201
|
+
s, err := os.Stat(filepath.Join(c.RunDir, "process.json"))
|
|
202
|
+
if err != nil || s.Mode().Perm() != 0600 {
|
|
203
|
+
t.Fatalf("process record permissions: %v %v", s, err)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
func TestS8InventoryHealthRejectsUnknownProtocol(t *testing.T) {
|
|
208
|
+
c := fixture(t)
|
|
209
|
+
for _, protocol := range []int{1, 2} {
|
|
210
|
+
i := c.Expected
|
|
211
|
+
i.Protocol = protocol
|
|
212
|
+
if !i.Valid() || !Respond(i, false, Request{Inventory: i, Op: "health", Nonce: strings.Repeat("c", 64)}).OK {
|
|
213
|
+
t.Fatal("supported protocol", protocol)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
for _, protocol := range []int{0, 3, 99} {
|
|
217
|
+
i := c.Expected
|
|
218
|
+
i.Protocol = protocol
|
|
219
|
+
res := Respond(i, false, Request{Inventory: i, Op: "health", Nonce: strings.Repeat("c", 64)})
|
|
220
|
+
if i.Valid() || res.OK || res.Error != "incompatible" {
|
|
221
|
+
t.Fatal("unknown protocol accepted", protocol, res)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
func TestPendingHealthRequiresTrustedRunningApproval(t *testing.T) {
|
|
227
|
+
for _, kind := range []string{"running", "missing", "legacy", "disabled", "residual", "fenced", "nonce", "inventory", "contradictory"} {
|
|
228
|
+
t.Run(kind, func(t *testing.T) {
|
|
229
|
+
c := fixture(t)
|
|
230
|
+
r := Record{Inventory: c.Expected, Enabled: true, Lifecycle: testLifecycle("running")}
|
|
231
|
+
switch kind {
|
|
232
|
+
case "legacy":
|
|
233
|
+
r.Lifecycle = nil
|
|
234
|
+
case "disabled":
|
|
235
|
+
r.Enabled = false
|
|
236
|
+
case "residual":
|
|
237
|
+
r.Residual = true
|
|
238
|
+
case "fenced":
|
|
239
|
+
r.Lifecycle.Phase = "fenced"
|
|
240
|
+
}
|
|
241
|
+
if kind != "missing" {
|
|
242
|
+
record(t, c, r)
|
|
243
|
+
}
|
|
244
|
+
live(t, c, c.Expected, func(req Request) Response {
|
|
245
|
+
res := Response{Inventory: c.Expected, Nonce: req.Nonce, Error: "reload-revalidating"}
|
|
246
|
+
switch kind {
|
|
247
|
+
case "nonce":
|
|
248
|
+
res.Nonce = "replay"
|
|
249
|
+
case "inventory":
|
|
250
|
+
res.Inventory.Protocol++
|
|
251
|
+
case "contradictory":
|
|
252
|
+
res.OK = true
|
|
253
|
+
}
|
|
254
|
+
return res
|
|
255
|
+
})
|
|
256
|
+
got := c.Status(context.Background())
|
|
257
|
+
if kind == "running" {
|
|
258
|
+
if got.State != "pending" || got.Reason != "reload-revalidating" || got.Cleanup != "" || got.PackageRunning != "running" {
|
|
259
|
+
t.Fatalf("%+v", got)
|
|
260
|
+
}
|
|
261
|
+
if c.CheckStopped(context.Background()) == nil {
|
|
262
|
+
t.Fatal("pending accepted as stopped")
|
|
263
|
+
}
|
|
264
|
+
} else if got.State == "pending" || got.State == "ready" {
|
|
265
|
+
t.Fatalf("untrusted pending: %+v", got)
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
func TestS1RInventoryModeIsProtocolTwoOnly(t *testing.T) {
|
|
272
|
+
i := Inventory{Package: "Fixture", Version: "1.0.0-0001", Protocol: 2, PayloadDigest: strings.Repeat("a", 64), RegistryDigest: strings.Repeat("b", 64)}
|
|
273
|
+
for _, mode := range []string{"", "unavailable", "relaxed"} {
|
|
274
|
+
i.DataAccess = mode
|
|
275
|
+
if !i.Valid() {
|
|
276
|
+
t.Fatal("known mode refused", mode)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
i.DataAccess = "active"
|
|
280
|
+
if i.Valid() {
|
|
281
|
+
t.Fatal("unknown mode accepted")
|
|
282
|
+
}
|
|
283
|
+
i.DataAccess = "relaxed"
|
|
284
|
+
i.Protocol = 1
|
|
285
|
+
if i.Valid() {
|
|
286
|
+
t.Fatal("protocol 1 accepted relaxed")
|
|
287
|
+
}
|
|
288
|
+
}
|