@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,177 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"crypto/sha256"
|
|
6
|
+
"encoding/hex"
|
|
7
|
+
"errors"
|
|
8
|
+
"fmt"
|
|
9
|
+
"io"
|
|
10
|
+
"os"
|
|
11
|
+
"os/exec"
|
|
12
|
+
"path/filepath"
|
|
13
|
+
"runtime"
|
|
14
|
+
"strconv"
|
|
15
|
+
"strings"
|
|
16
|
+
"syscall"
|
|
17
|
+
"time"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
func executableDigest(path string) (string, error) {
|
|
21
|
+
f, err := os.Open(path)
|
|
22
|
+
if err != nil {
|
|
23
|
+
return "", err
|
|
24
|
+
}
|
|
25
|
+
defer f.Close()
|
|
26
|
+
st, err := f.Stat()
|
|
27
|
+
if err != nil {
|
|
28
|
+
return "", err
|
|
29
|
+
}
|
|
30
|
+
s, ok := st.Sys().(*syscall.Stat_t)
|
|
31
|
+
if !ok || s.Uid != 0 || st.Mode().Perm()&0022 != 0 || !st.Mode().IsRegular() || st.Size() > 64<<20 {
|
|
32
|
+
return "", errTrust
|
|
33
|
+
}
|
|
34
|
+
h := sha256.New()
|
|
35
|
+
if _, err := io.Copy(h, f); err != nil {
|
|
36
|
+
return "", err
|
|
37
|
+
}
|
|
38
|
+
return hex.EncodeToString(h.Sum(nil)), nil
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func inspectSupervisor(pid int, i Inventory) (Process, error) {
|
|
42
|
+
base := fmt.Sprintf("/proc/%d/", pid)
|
|
43
|
+
b, err := os.ReadFile("/proc/sys/kernel/random/boot_id")
|
|
44
|
+
if err != nil {
|
|
45
|
+
return Process{}, err
|
|
46
|
+
}
|
|
47
|
+
stat, err := os.ReadFile(base + "stat")
|
|
48
|
+
if err != nil {
|
|
49
|
+
return Process{}, err
|
|
50
|
+
}
|
|
51
|
+
end := strings.LastIndex(string(stat), ") ")
|
|
52
|
+
if end < 0 {
|
|
53
|
+
return Process{}, errTrust
|
|
54
|
+
}
|
|
55
|
+
fields := strings.Fields(string(stat)[end+2:])
|
|
56
|
+
if len(fields) < 20 {
|
|
57
|
+
return Process{}, errTrust
|
|
58
|
+
}
|
|
59
|
+
status, err := os.ReadFile(base + "status")
|
|
60
|
+
if err != nil {
|
|
61
|
+
return Process{}, err
|
|
62
|
+
}
|
|
63
|
+
root := false
|
|
64
|
+
for _, line := range strings.Split(string(status), "\n") {
|
|
65
|
+
if strings.HasPrefix(line, "Uid:") {
|
|
66
|
+
u := strings.Fields(line)
|
|
67
|
+
root = len(u) == 5 && u[1] == "0" && u[2] == "0" && u[3] == "0" && u[4] == "0"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if !root {
|
|
71
|
+
return Process{}, errTrust
|
|
72
|
+
}
|
|
73
|
+
cmd, err := os.ReadFile(base + "cmdline")
|
|
74
|
+
if err != nil {
|
|
75
|
+
return Process{}, err
|
|
76
|
+
}
|
|
77
|
+
wantExe := "/var/lib/synopkgland-" + i.Package + "/payload-" + i.PayloadDigest
|
|
78
|
+
if string(cmd) != wantExe+"\x00supervise\x00" {
|
|
79
|
+
return Process{}, errTrust
|
|
80
|
+
}
|
|
81
|
+
st, err := os.Stat(base + "exe")
|
|
82
|
+
if err != nil {
|
|
83
|
+
return Process{}, err
|
|
84
|
+
}
|
|
85
|
+
s := st.Sys().(*syscall.Stat_t)
|
|
86
|
+
digest, err := executableDigest(base + "exe")
|
|
87
|
+
if err != nil || digest != i.PayloadDigest {
|
|
88
|
+
return Process{}, errTrust
|
|
89
|
+
}
|
|
90
|
+
return Process{Inventory: i, Mode: "supervised", PID: pid, Boot: strings.TrimSpace(string(b)), Start: fields[19], Device: uint64(s.Dev), Inode: s.Ino}, nil
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type LinuxProcesses struct {
|
|
94
|
+
Client
|
|
95
|
+
Binary string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
func (p LinuxProcesses) Start(i Inventory) error {
|
|
99
|
+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
100
|
+
defer cancel()
|
|
101
|
+
if i != p.Expected {
|
|
102
|
+
return errTrust
|
|
103
|
+
}
|
|
104
|
+
if err := protected(p.RunDir, 0, true); err != nil {
|
|
105
|
+
return err
|
|
106
|
+
}
|
|
107
|
+
cmd := exec.Command(p.Binary, "supervise")
|
|
108
|
+
cmd.Env = []string{"PATH=/usr/sbin:/usr/bin:/sbin:/bin"}
|
|
109
|
+
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
|
110
|
+
if err := cmd.Start(); err != nil {
|
|
111
|
+
return err
|
|
112
|
+
}
|
|
113
|
+
go cmd.Wait()
|
|
114
|
+
if waitHealthy(ctx, func(ctx context.Context) bool {
|
|
115
|
+
state, _ := p.probe(ctx, filepath.Join(p.RunDir, "helper.sock"))
|
|
116
|
+
return state == "ready"
|
|
117
|
+
}) == nil {
|
|
118
|
+
return nil
|
|
119
|
+
}
|
|
120
|
+
return errors.New("helper start timeout; residual preserved")
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// RunLinux runs a fixed control action or the health-only server. Its caller
|
|
124
|
+
// must be the hash-verified, root-owned copy, never the SPK staging executable.
|
|
125
|
+
func RunLinux(base Inventory, action string) error {
|
|
126
|
+
if os.Geteuid() != 0 {
|
|
127
|
+
return errTrust
|
|
128
|
+
}
|
|
129
|
+
exe, err := os.Executable()
|
|
130
|
+
if err != nil {
|
|
131
|
+
return err
|
|
132
|
+
}
|
|
133
|
+
digest, err := executableDigest(exe)
|
|
134
|
+
if err != nil {
|
|
135
|
+
return err
|
|
136
|
+
}
|
|
137
|
+
base.PayloadDigest = digest
|
|
138
|
+
if !base.Valid() || exe != "/var/lib/synopkgland-"+base.Package+"/payload-"+digest {
|
|
139
|
+
return errTrust
|
|
140
|
+
}
|
|
141
|
+
c := NewClient(base)
|
|
142
|
+
if err := protected(c.StateDir, 0, true); err != nil {
|
|
143
|
+
return err
|
|
144
|
+
}
|
|
145
|
+
if err := protected(c.RunDir, 0, true); err != nil {
|
|
146
|
+
return err
|
|
147
|
+
}
|
|
148
|
+
switch action {
|
|
149
|
+
case "supervise":
|
|
150
|
+
return superviseLinux(c, exe)
|
|
151
|
+
case "operation-child":
|
|
152
|
+
return operationChildLinux(c)
|
|
153
|
+
case "serve-child":
|
|
154
|
+
parent, err := strconv.Atoi(os.Getenv("SYNOPKGLAND_PARENT"))
|
|
155
|
+
if err != nil {
|
|
156
|
+
return errTrust
|
|
157
|
+
}
|
|
158
|
+
runtime.LockOSThread()
|
|
159
|
+
defer runtime.UnlockOSThread()
|
|
160
|
+
if err := armParentDeath(parent, setParentDeath, os.Getppid); err != nil {
|
|
161
|
+
return err
|
|
162
|
+
}
|
|
163
|
+
if _, err := inspectSupervisor(parent, base); err != nil {
|
|
164
|
+
return err
|
|
165
|
+
}
|
|
166
|
+
if err := inheritLifetime(c); err != nil {
|
|
167
|
+
return err
|
|
168
|
+
}
|
|
169
|
+
return serveLinux(c)
|
|
170
|
+
}
|
|
171
|
+
return (Controller{Client: c, Processes: LinuxProcesses{Client: c, Binary: exe}, Observe: observeLinux, Boot: linuxBoot}).Control(context.Background(), action)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
func linuxBoot() (string, error) {
|
|
175
|
+
b, err := os.ReadFile("/proc/sys/kernel/random/boot_id")
|
|
176
|
+
return strings.TrimSpace(string(b)), err
|
|
177
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"os"
|
|
7
|
+
"path/filepath"
|
|
8
|
+
"strings"
|
|
9
|
+
"syscall"
|
|
10
|
+
"testing"
|
|
11
|
+
"time"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// An approval rename is visible before the publisher's directory fsync and
|
|
15
|
+
// policy.lock release. Reproduce that interval with real files and flock.
|
|
16
|
+
func heldCompletion(t *testing.T, c Controller, f *fakeProcesses) (<-chan error, func()) {
|
|
17
|
+
t.Helper()
|
|
18
|
+
published := make(chan error, 1)
|
|
19
|
+
var lock *os.File
|
|
20
|
+
f.stopHook = func(p Process) error {
|
|
21
|
+
var err error
|
|
22
|
+
lock, err = os.OpenFile(filepath.Join(c.StateDir, "policy.lock"), os.O_RDWR, 0)
|
|
23
|
+
if err == nil {
|
|
24
|
+
err = syscall.Flock(int(lock.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
|
|
25
|
+
}
|
|
26
|
+
if err == nil {
|
|
27
|
+
err = cleanRuntime(c.Client, true)
|
|
28
|
+
}
|
|
29
|
+
if err == nil {
|
|
30
|
+
var r Record
|
|
31
|
+
r, err = readRecord(c.StateDir, c.Owner)
|
|
32
|
+
if err == nil {
|
|
33
|
+
r.Lifecycle.Phase = "stopped"
|
|
34
|
+
err = storeCompletion(c.Client, &r, Completion{Epoch: r.Lifecycle.Epoch, Process: p})
|
|
35
|
+
if err == nil {
|
|
36
|
+
err = writeProtected(c.StateDir, "approval.json", r)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
published <- err
|
|
41
|
+
return errTrust // owner completed before the controller socket operation
|
|
42
|
+
}
|
|
43
|
+
release := func() {
|
|
44
|
+
if lock != nil {
|
|
45
|
+
syscall.Flock(int(lock.Fd()), syscall.LOCK_UN)
|
|
46
|
+
lock.Close()
|
|
47
|
+
lock = nil
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return published, release
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func TestControllerWaitsForCompletionPublisherUnlock(t *testing.T) {
|
|
54
|
+
for _, action := range []string{"teardown", "disable", "recover", "enable"} {
|
|
55
|
+
t.Run(action, func(t *testing.T) {
|
|
56
|
+
c, f := controlFixture(t)
|
|
57
|
+
published, release := heldCompletion(t, c, f)
|
|
58
|
+
defer release()
|
|
59
|
+
result := make(chan error, 1)
|
|
60
|
+
go func() { result <- c.Control(context.Background(), action) }()
|
|
61
|
+
if err := <-published; err != nil {
|
|
62
|
+
t.Fatal(err)
|
|
63
|
+
}
|
|
64
|
+
select {
|
|
65
|
+
case err := <-result:
|
|
66
|
+
t.Fatalf("returned before the completion publisher unlocked: %v", err)
|
|
67
|
+
case <-time.After(100 * time.Millisecond):
|
|
68
|
+
}
|
|
69
|
+
release()
|
|
70
|
+
select {
|
|
71
|
+
case err := <-result:
|
|
72
|
+
if err != nil {
|
|
73
|
+
t.Fatal("exact owner completion refused after unlock", err)
|
|
74
|
+
}
|
|
75
|
+
case <-time.After(2 * time.Second):
|
|
76
|
+
t.Fatal("controller did not finish after publisher unlock")
|
|
77
|
+
}
|
|
78
|
+
r, _ := readRecord(c.StateDir, c.Owner)
|
|
79
|
+
starts := 0
|
|
80
|
+
if action == "enable" || action == "recover" {
|
|
81
|
+
starts = 1
|
|
82
|
+
}
|
|
83
|
+
if r.Residual || r.Enabled != (action != "disable") || f.started != starts {
|
|
84
|
+
t.Fatal("incorrect post-teardown state", r, f.started)
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func TestControllerRevalidatesCompletionAfterPublisherUnlock(t *testing.T) {
|
|
91
|
+
for _, kind := range []string{"epoch", "inventory", "binding", "lease", "proof", "digest", "missing-commit", "missing-proof", "mode", "symlink", "runtime"} {
|
|
92
|
+
t.Run(kind, func(t *testing.T) {
|
|
93
|
+
c, f := controlFixture(t)
|
|
94
|
+
published, release := heldCompletion(t, c, f)
|
|
95
|
+
defer release()
|
|
96
|
+
result := make(chan error, 1)
|
|
97
|
+
go func() { result <- c.Control(context.Background(), "recover") }()
|
|
98
|
+
if err := <-published; err != nil {
|
|
99
|
+
t.Fatal(err)
|
|
100
|
+
}
|
|
101
|
+
select {
|
|
102
|
+
case err := <-result:
|
|
103
|
+
t.Fatalf("returned before revalidation: %v", err)
|
|
104
|
+
case <-time.After(100 * time.Millisecond):
|
|
105
|
+
}
|
|
106
|
+
r, _ := readRecord(c.StateDir, c.Owner)
|
|
107
|
+
switch kind {
|
|
108
|
+
case "epoch":
|
|
109
|
+
r.Lifecycle.Epoch = strings.Repeat("e", 64)
|
|
110
|
+
case "inventory":
|
|
111
|
+
r.Inventory.Version = "9.0.0-0001"
|
|
112
|
+
case "binding":
|
|
113
|
+
r.Lifecycle.Binding.Entered++
|
|
114
|
+
case "lease":
|
|
115
|
+
r.Lifecycle.Lease = &Lease{Device: 1, Inode: 9}
|
|
116
|
+
case "proof":
|
|
117
|
+
p := f.current
|
|
118
|
+
p.Start = "different-owned-process"
|
|
119
|
+
if err := storeCompletion(c.Client, &r, Completion{Epoch: r.Lifecycle.Epoch, Process: p}); err != nil {
|
|
120
|
+
t.Fatal(err)
|
|
121
|
+
}
|
|
122
|
+
case "digest":
|
|
123
|
+
r.Lifecycle.Completion = strings.Repeat("f", 64)
|
|
124
|
+
case "missing-commit":
|
|
125
|
+
r.Lifecycle.Completion = ""
|
|
126
|
+
case "missing-proof", "mode", "symlink":
|
|
127
|
+
path := filepath.Join(c.StateDir, "completion-"+r.Lifecycle.Epoch+".json")
|
|
128
|
+
var err error
|
|
129
|
+
if kind == "mode" {
|
|
130
|
+
err = os.Chmod(path, 0644)
|
|
131
|
+
} else {
|
|
132
|
+
err = os.Remove(path)
|
|
133
|
+
if err == nil && kind == "symlink" {
|
|
134
|
+
err = os.Symlink("approval.json", path)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if err != nil {
|
|
138
|
+
t.Fatal(err)
|
|
139
|
+
}
|
|
140
|
+
case "runtime":
|
|
141
|
+
if err := writeProcess(c.RunDir, f.current); err != nil {
|
|
142
|
+
t.Fatal(err)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if err := writeProtected(c.StateDir, "approval.json", r); err != nil {
|
|
146
|
+
t.Fatal(err)
|
|
147
|
+
}
|
|
148
|
+
before, _ := os.ReadFile(filepath.Join(c.StateDir, "approval.json"))
|
|
149
|
+
release()
|
|
150
|
+
if err := <-result; err == nil || f.started != 0 {
|
|
151
|
+
t.Fatal("changed completion accepted", err, f.started)
|
|
152
|
+
}
|
|
153
|
+
after, _ := os.ReadFile(filepath.Join(c.StateDir, "approval.json"))
|
|
154
|
+
if string(before) != string(after) {
|
|
155
|
+
t.Fatal("failure evidence overwritten")
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func TestControllerCompletionPublisherWaitIsBounded(t *testing.T) {
|
|
162
|
+
c, f := controlFixture(t)
|
|
163
|
+
published, release := heldCompletion(t, c, f)
|
|
164
|
+
defer release()
|
|
165
|
+
result := make(chan error, 1)
|
|
166
|
+
go func() { result <- c.Control(context.Background(), "teardown") }()
|
|
167
|
+
if err := <-published; err != nil {
|
|
168
|
+
t.Fatal(err)
|
|
169
|
+
}
|
|
170
|
+
select {
|
|
171
|
+
case err := <-result:
|
|
172
|
+
if !errors.Is(err, errBusy) {
|
|
173
|
+
t.Fatal("persistent publisher lock was accepted", err)
|
|
174
|
+
}
|
|
175
|
+
case <-time.After(2 * time.Second):
|
|
176
|
+
t.Fatal("unbounded publisher lock wait")
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"os"
|
|
8
|
+
"strconv"
|
|
9
|
+
"testing"
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func readStreamVMCreate(t *testing.T, p LinuxProcesses) Grant {
|
|
14
|
+
t.Helper()
|
|
15
|
+
res := grantVMCall(t, p, "prepare", grantPrepareArgs{grantRef('c'), ScopePersonal, []Action{ActionReadStream}})
|
|
16
|
+
if res.Code != "" || res.Intent == nil {
|
|
17
|
+
t.Fatal(res)
|
|
18
|
+
}
|
|
19
|
+
b, e := os.ReadFile(p.StateDir + "/grants.json")
|
|
20
|
+
if e != nil {
|
|
21
|
+
t.Fatal(e)
|
|
22
|
+
}
|
|
23
|
+
store, code := DecodeGrantStore(bytes.NewReader(b))
|
|
24
|
+
if code != "" {
|
|
25
|
+
t.Fatal(code)
|
|
26
|
+
}
|
|
27
|
+
res = grantVMCall(t, p, "confirm", grantConfirmArgs{res.Intent.ID, res.Intent.SummaryDigest, store.Revision})
|
|
28
|
+
if res.Code != "" || res.Grant == nil {
|
|
29
|
+
t.Fatal(res)
|
|
30
|
+
}
|
|
31
|
+
return *res.Grant
|
|
32
|
+
}
|
|
33
|
+
func readStreamVMWait(t *testing.T, fn func() bool) {
|
|
34
|
+
t.Helper()
|
|
35
|
+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
|
|
36
|
+
defer cancel()
|
|
37
|
+
if err := waitHealthy(ctx, func(context.Context) bool { return fn() }); err != nil {
|
|
38
|
+
t.Fatal(err)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
func TestLinuxReadStreamRealChildProofBackpressureAndQ(t *testing.T) {
|
|
42
|
+
for _, kind := range []string{"complete", "acl", "groups", "disconnect", "epoch", "backpressure"} {
|
|
43
|
+
t.Run(kind, func(t *testing.T) {
|
|
44
|
+
p := readOnlyVMFixture(t)
|
|
45
|
+
proc := startVMHelper(t, p)
|
|
46
|
+
g := readStreamVMCreate(t, p)
|
|
47
|
+
defer func() {
|
|
48
|
+
if e := (Controller{Client: p.Client, Processes: p, Observe: observeLinux}).Control(context.Background(), "teardown"); e != nil {
|
|
49
|
+
t.Error(e)
|
|
50
|
+
}
|
|
51
|
+
}()
|
|
52
|
+
expected := bytes.Repeat([]byte("s"), 2*MaxBoundedBytes)
|
|
53
|
+
if e := os.WriteFile("/tmp/m2-s5-operations/stream", expected, 0644); e != nil {
|
|
54
|
+
t.Fatal(e)
|
|
55
|
+
}
|
|
56
|
+
if kind == "backpressure" {
|
|
57
|
+
os.WriteFile(p.RunDir+"/fixture-readonly-block-output", nil, 0600)
|
|
58
|
+
}
|
|
59
|
+
if kind == "disconnect" {
|
|
60
|
+
os.WriteFile(p.RunDir+"/fixture-disconnect", nil, 0600)
|
|
61
|
+
}
|
|
62
|
+
r := readOnlyVMRequest(t, g, ActionReadStream, ReadArgs{Segments: []string{"stream"}, MaxBytes: MaxTransferBytes})
|
|
63
|
+
if res := grantVMCall(t, p, "operation.start", r); res.Code != "" {
|
|
64
|
+
t.Fatal(res)
|
|
65
|
+
}
|
|
66
|
+
metadata := grantVMMetadata(t, p, r)
|
|
67
|
+
if metadata.Code != "" || metadata.Bytes != uint64(len(expected)) {
|
|
68
|
+
t.Fatal(metadata)
|
|
69
|
+
}
|
|
70
|
+
chunk := r
|
|
71
|
+
chunk.Args, _ = json.Marshal(ReadArgs{Segments: []string{"stream"}, MaxBytes: MaxChunkBytes})
|
|
72
|
+
lease := func() Code {
|
|
73
|
+
chunk.Nonce = readOnlyVMRef(t)
|
|
74
|
+
chunk.Ticket = readOnlyVMRef(t)
|
|
75
|
+
return grantVMCall(t, p, "operation.chunk", chunk).Code
|
|
76
|
+
}
|
|
77
|
+
if code := lease(); code != "" {
|
|
78
|
+
t.Fatal(code)
|
|
79
|
+
}
|
|
80
|
+
if kind == "backpressure" {
|
|
81
|
+
if code := lease(); code != ErrBusy {
|
|
82
|
+
t.Fatal("slow client accepted second outstanding lease", code)
|
|
83
|
+
}
|
|
84
|
+
raw, _ := os.ReadFile(p.StateDir + "/grants.json")
|
|
85
|
+
store, _ := DecodeGrantStore(bytes.NewReader(raw))
|
|
86
|
+
res := grantVMCall(t, p, "revoke", grantRevokeArgs{g.ID, g.Revision, store.Revision})
|
|
87
|
+
if res.Code != "" || res.Revoke == nil || !res.Revoke.Drained {
|
|
88
|
+
t.Fatal(res)
|
|
89
|
+
}
|
|
90
|
+
raw, e := os.ReadFile(p.StateDir + "/grant-q-" + g.ID + ".json")
|
|
91
|
+
var q GrantQuiescence
|
|
92
|
+
if e != nil || json.Unmarshal(raw, &q) != nil || !completeQuiescence(q) || q.Cohort == nil || q.Cohort.AdmittedBytes != MaxChunkBytes {
|
|
93
|
+
t.Fatal(q, e)
|
|
94
|
+
}
|
|
95
|
+
if code := lease(); code == "" {
|
|
96
|
+
t.Fatal("lease after R/Q")
|
|
97
|
+
}
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
readStreamVMWait(t, func() bool {
|
|
101
|
+
b, _ := os.ReadFile(p.RunDir + "/fixture-progress")
|
|
102
|
+
n, _ := strconv.Atoi(string(b))
|
|
103
|
+
return n == MaxChunkBytes
|
|
104
|
+
})
|
|
105
|
+
switch kind {
|
|
106
|
+
case "acl":
|
|
107
|
+
os.WriteFile("/tmp/m2-s5-operations/deny-acl", nil, 0644)
|
|
108
|
+
case "groups":
|
|
109
|
+
os.WriteFile("/tmp/m2-s5-operations/group-change", nil, 0644)
|
|
110
|
+
case "epoch":
|
|
111
|
+
chunk.Epoch = grantRef('f')
|
|
112
|
+
}
|
|
113
|
+
if kind == "complete" {
|
|
114
|
+
for sent := MaxChunkBytes; sent < len(expected); {
|
|
115
|
+
code := lease()
|
|
116
|
+
if code == ErrBusy {
|
|
117
|
+
time.Sleep(time.Millisecond)
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
if code != "" {
|
|
121
|
+
t.Fatal(sent, code)
|
|
122
|
+
}
|
|
123
|
+
sent += MaxChunkBytes
|
|
124
|
+
}
|
|
125
|
+
} else if kind != "disconnect" {
|
|
126
|
+
code := lease()
|
|
127
|
+
if kind != "acl" && code == "" {
|
|
128
|
+
t.Fatal("changed binding admitted", kind)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if kind == "epoch" {
|
|
132
|
+
raw, _ := os.ReadFile(p.StateDir + "/grants.json")
|
|
133
|
+
store, _ := DecodeGrantStore(bytes.NewReader(raw))
|
|
134
|
+
res := grantVMCall(t, p, "revoke", grantRevokeArgs{g.ID, g.Revision, store.Revision})
|
|
135
|
+
if res.Code != "" || !res.Revoke.Drained {
|
|
136
|
+
t.Fatal(res)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
readStreamVMWait(t, func() bool {
|
|
140
|
+
_, e := os.Stat(p.RunDir + "/fixture-readonly-bytes")
|
|
141
|
+
return e == nil && len(processChildren(proc.PID)) == 1
|
|
142
|
+
})
|
|
143
|
+
b, e := os.ReadFile(p.RunDir + "/fixture-readonly-bytes")
|
|
144
|
+
if e != nil {
|
|
145
|
+
t.Fatal(e)
|
|
146
|
+
}
|
|
147
|
+
want := MaxChunkBytes
|
|
148
|
+
if kind == "complete" {
|
|
149
|
+
want = len(expected)
|
|
150
|
+
}
|
|
151
|
+
if len(b) != want || !bytes.Equal(b, expected[:want]) {
|
|
152
|
+
t.Fatal(kind, "unproved or truncated bytes", len(b), want)
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"time"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Stream is a staged fixed read action. It has no public socket/generator/CGI
|
|
9
|
+
// enablement until DSM FD ACL and end-to-end CGI proof pass.
|
|
10
|
+
const MaxStreamReplayEntries = MaxPackageOperations * (MaxTransferBytes/MaxChunkBytes + MaxReplayEntries)
|
|
11
|
+
|
|
12
|
+
func readDataCeiling(a Action) uint64 {
|
|
13
|
+
if a == ActionReadStream {
|
|
14
|
+
return MaxTransferBytes
|
|
15
|
+
}
|
|
16
|
+
return MaxBoundedBytes
|
|
17
|
+
}
|
|
18
|
+
func (op *cohortOperation) expired(now time.Time) bool {
|
|
19
|
+
if op.admittedAt.IsZero() {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
stream := op.work != nil && op.work.Action == ActionReadStream || op.writeWork != nil && op.writeWork.Action == ActionWriteStream
|
|
23
|
+
if !stream {
|
|
24
|
+
return now.Sub(op.admittedAt) >= BoundedTimeout
|
|
25
|
+
}
|
|
26
|
+
last := op.lastActivity
|
|
27
|
+
if last.IsZero() {
|
|
28
|
+
last = op.admittedAt
|
|
29
|
+
}
|
|
30
|
+
return now.Before(op.admittedAt) || now.Before(last) || now.Sub(op.admittedAt) >= StreamTotalTimeout || now.Sub(last) >= StreamIdleTimeout
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Internal child stream interface. Only a fixed actor-opened FD implementation
|
|
34
|
+
// is constructed by bootstrap. Caller transport supplies leases, never a source.
|
|
35
|
+
// A successful chunk includes fresh child FD ACL/object checks. Root separately
|
|
36
|
+
// binds subject/session/ticket/grant/revision/epoch under the S3 admission lock.
|
|
37
|
+
type readStreamSource interface {
|
|
38
|
+
ReadChunk(context.Context, uint32) ([]byte, Code)
|
|
39
|
+
Close()
|
|
40
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"golang.org/x/sys/unix"
|
|
6
|
+
"io"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Child-only FD source. Bounded reads retain S5's eager validation/buffer;
|
|
10
|
+
// streams retain the captured object and allocate at most one leased chunk.
|
|
11
|
+
// No caller path, range, URL, executable, or root-opened readable FD is accepted.
|
|
12
|
+
type actorReadTransfer struct {
|
|
13
|
+
ctx context.Context
|
|
14
|
+
object *readOnlyObject
|
|
15
|
+
work readOnlyWork
|
|
16
|
+
acl readOnlyACL
|
|
17
|
+
buffer []byte
|
|
18
|
+
remaining, offset uint64
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func openActorReadTransfer(ctx context.Context, pin *pinnedReadOnlyRoot, w readOnlyWork, acl readOnlyACL) (*actorReadTransfer, readOnlyResult) {
|
|
22
|
+
fail := func(c Code) (*actorReadTransfer, readOnlyResult) { return nil, readOnlyResult{Code: c} }
|
|
23
|
+
if code := w.validate(); code != "" {
|
|
24
|
+
return fail(code)
|
|
25
|
+
}
|
|
26
|
+
if w.Action != ActionRead && w.Action != ActionReadStream {
|
|
27
|
+
return fail(ErrUnsupported)
|
|
28
|
+
}
|
|
29
|
+
if acl == nil {
|
|
30
|
+
return fail(ErrUnsupported)
|
|
31
|
+
}
|
|
32
|
+
o, code := resolveReadOnly(ctx, pin, w)
|
|
33
|
+
if code != "" {
|
|
34
|
+
return fail(code)
|
|
35
|
+
}
|
|
36
|
+
ok := false
|
|
37
|
+
defer func() {
|
|
38
|
+
if !ok {
|
|
39
|
+
o.Close()
|
|
40
|
+
}
|
|
41
|
+
}()
|
|
42
|
+
if code := authorizeReadOnly(ctx, o, w, acl); code != "" {
|
|
43
|
+
return fail(code)
|
|
44
|
+
}
|
|
45
|
+
if o.before.Mode&unix.S_IFMT != unix.S_IFREG {
|
|
46
|
+
return fail(ErrDenied)
|
|
47
|
+
}
|
|
48
|
+
if o.before.Size < 0 || uint64(o.before.Size) > w.MaxBytes {
|
|
49
|
+
return fail(ErrLimit)
|
|
50
|
+
}
|
|
51
|
+
src := &actorReadTransfer{ctx: ctx, object: o, work: w, acl: acl, remaining: uint64(o.before.Size)}
|
|
52
|
+
if w.Action == ActionRead {
|
|
53
|
+
b, err := io.ReadAll(io.LimitReader(o.data, int64(w.MaxBytes)+1))
|
|
54
|
+
if err != nil {
|
|
55
|
+
return fail(readOnlyError(err))
|
|
56
|
+
}
|
|
57
|
+
if uint64(len(b)) > w.MaxBytes {
|
|
58
|
+
return fail(ErrLimit)
|
|
59
|
+
}
|
|
60
|
+
if uint64(len(b)) != src.remaining {
|
|
61
|
+
return fail(ErrStale)
|
|
62
|
+
}
|
|
63
|
+
src.buffer = b
|
|
64
|
+
}
|
|
65
|
+
if code := src.check(); code != "" {
|
|
66
|
+
return fail(code)
|
|
67
|
+
}
|
|
68
|
+
ok = true
|
|
69
|
+
return src, readOnlyResult{Bytes: src.remaining}
|
|
70
|
+
}
|
|
71
|
+
func (s *actorReadTransfer) check() Code {
|
|
72
|
+
if code := authorizeReadOnly(s.ctx, s.object, s.work, s.acl); code != "" {
|
|
73
|
+
return code
|
|
74
|
+
}
|
|
75
|
+
return readOnlyUnchanged(int(s.object.data.Fd()), s.object.before)
|
|
76
|
+
}
|
|
77
|
+
func (s *actorReadTransfer) Next(n uint32) ([]byte, Code) {
|
|
78
|
+
if n == 0 || n > MaxChunkBytes || uint64(n) > s.remaining {
|
|
79
|
+
return nil, ErrLimit
|
|
80
|
+
}
|
|
81
|
+
if code := s.check(); code != "" {
|
|
82
|
+
return nil, code
|
|
83
|
+
}
|
|
84
|
+
var b []byte
|
|
85
|
+
if s.work.Action == ActionRead {
|
|
86
|
+
b = s.buffer[s.offset : s.offset+uint64(n)]
|
|
87
|
+
} else {
|
|
88
|
+
b = make([]byte, n)
|
|
89
|
+
if _, err := io.ReadFull(s.object.data, b); err != nil {
|
|
90
|
+
return nil, ErrStale
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if code := s.check(); code != "" {
|
|
94
|
+
return nil, code
|
|
95
|
+
}
|
|
96
|
+
s.remaining -= uint64(n)
|
|
97
|
+
s.offset += uint64(n)
|
|
98
|
+
return b, ""
|
|
99
|
+
}
|
|
100
|
+
func (s *actorReadTransfer) Close() { s.object.Close(); s.buffer = nil }
|
|
101
|
+
|
|
102
|
+
var _ readStreamSource = (*actorReadTransfer)(nil)
|
|
103
|
+
|
|
104
|
+
func (s *actorReadTransfer) ReadChunk(ctx context.Context, n uint32) ([]byte, Code) {
|
|
105
|
+
original := s.ctx
|
|
106
|
+
s.ctx = ctx
|
|
107
|
+
defer func() { s.ctx = original }()
|
|
108
|
+
return s.Next(n)
|
|
109
|
+
}
|