@synopackageland/cli 0.4.0 → 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 +37 -0
- package/dist/build-spk/generator.js +3 -0
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +9 -2
- package/dist/error-registry.js +20 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.js +20 -12
- package/dist/standalone/build.js +3 -1
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +1 -1
- package/dist/standalone/dsm-window.js +50 -10
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +2 -12
- package/dist/standalone/helper.js +8 -7
- 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/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +2 -0
- package/dist/standalone/inspect-spk.js +49 -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 +2 -0
- package/dist/standalone/manifest.js +4 -1
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.js +9 -0
- package/dist/standalone/root-window.d.ts +4 -3
- package/dist/standalone/root-window.js +17 -5
- package/dist/standalone/spk.d.ts +4 -3
- package/dist/standalone/spk.js +20 -33
- 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/native-go/README.md +57 -1
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/go.mod +4 -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/registry.go +14 -4
- package/dist/templates/native-go/backend/internal/api/server.go +4 -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/routes.go +11 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
- 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 +226 -21
- package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
- 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/process_linux.go +11 -1
- 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 +44 -3
- package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
- package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
- 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 +187 -16
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- 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/ui/app.js +8 -1
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-vue/README.md +115 -1
- package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
- 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 +17 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- 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 -1
- package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
- package/package.json +3 -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/native-go/README.md +57 -1
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/go.mod +4 -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/registry.go +14 -4
- package/templates/native-go/backend/internal/api/server.go +4 -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/routes.go +11 -0
- package/templates/native-go/backend/internal/app/routes_test.go +10 -5
- 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 +226 -21
- package/templates/native-go/backend/internal/helper/control_test.go +10 -2
- 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/process_linux.go +11 -1
- 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 +44 -3
- package/templates/native-go/backend/internal/helper/status.go +74 -11
- package/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/templates/native-go/backend/internal/helper/supervision.go +28 -5
- 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 +187 -16
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- 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/ui/app.js +8 -1
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-vue/README.md +115 -1
- package/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/templates/native-go-vue/frontend/src/main.ts +4 -1
- 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 +17 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- 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 -1
- package/templates/native-go-vue/frontend/vite.config.ts +6 -4
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"os"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func s1rActorRaces(t *testing.T, spec s1rActorSpec, kind string) {
|
|
11
|
+
root := spec.Root + "/race"
|
|
12
|
+
pin, code := pinReadOnlyRoot(root)
|
|
13
|
+
if code != "" {
|
|
14
|
+
t.Fatal(code)
|
|
15
|
+
}
|
|
16
|
+
defer pin.Close()
|
|
17
|
+
ctx := context.Background()
|
|
18
|
+
switch kind {
|
|
19
|
+
case "symlink":
|
|
20
|
+
for _, link := range []struct{ name, target string }{{"inside-link", "file"}, {"outside-link", "../bob/file"}, {"dir-link", "../bob"}} {
|
|
21
|
+
s1rMust(t, os.Symlink(link.target, root+"/"+link.name))
|
|
22
|
+
}
|
|
23
|
+
for _, action := range []Action{ActionStat, ActionRead, ActionList, ActionReadStream} {
|
|
24
|
+
segments := []string{"outside-link"}
|
|
25
|
+
if action == ActionList {
|
|
26
|
+
segments = []string{"dir-link"}
|
|
27
|
+
}
|
|
28
|
+
work := readWork(pin, segments...)
|
|
29
|
+
work.Action = action
|
|
30
|
+
if action == ActionList {
|
|
31
|
+
work.MaxBytes = 0
|
|
32
|
+
work.Limit = 20
|
|
33
|
+
}
|
|
34
|
+
if action == ActionStat {
|
|
35
|
+
work.MaxBytes = 0
|
|
36
|
+
}
|
|
37
|
+
if action == ActionReadStream {
|
|
38
|
+
x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
39
|
+
if x != nil {
|
|
40
|
+
x.Close()
|
|
41
|
+
}
|
|
42
|
+
if r.Code != ErrDenied || r.Bytes != 0 {
|
|
43
|
+
t.Fatal("symlink stream", r)
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
r, b := executeReadOnly(ctx, pin, work, fixtureReadOnlyACL{})
|
|
47
|
+
if r.Code != ErrDenied || len(b) > 0 || r.Entry != nil || r.List != nil {
|
|
48
|
+
t.Fatal("symlink metadata/read", action, r)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
r, b := executeReadOnly(ctx, pin, readWork(pin, "inside-link"), fixtureReadOnlyACL{})
|
|
53
|
+
if r.Code != ErrDenied || len(b) > 0 {
|
|
54
|
+
t.Fatal("internal symlink followed", r)
|
|
55
|
+
}
|
|
56
|
+
r, _ = executeReadOnly(ctx, pin, readOnlyWork{RootPath: root, Action: ActionList, Segments: []string{}, Limit: 20}, fixtureReadOnlyACL{})
|
|
57
|
+
if r.Code != "" || r.List == nil || len(r.List.Entries) != 1 || r.List.Entries[0].Name != "file" {
|
|
58
|
+
t.Fatal("symlink names leaked by list", r)
|
|
59
|
+
}
|
|
60
|
+
for _, segments := range [][]string{{"outside-link"}, {"dir-link", "new"}} {
|
|
61
|
+
x, c := openActorWriteTransfer(ctx, pin, writeWork{RootPath: root, Action: ActionCreate, Segments: segments, MaxBytes: 3}, fixtureReadOnlyACL{})
|
|
62
|
+
if x != nil {
|
|
63
|
+
x.Close()
|
|
64
|
+
}
|
|
65
|
+
if c != ErrDenied {
|
|
66
|
+
t.Fatal("symlink create", c)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
t.Log("stat/list/read/stream/create reject symlinks; list filters symlink names")
|
|
70
|
+
case "stat-rename", "list-rename", "read-rename":
|
|
71
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
72
|
+
s1rMust(t, os.WriteFile(root+"/sub/file", []byte("original"), 0600))
|
|
73
|
+
mutated := false
|
|
74
|
+
acl := fixtureReadOnlyACL{hook: func() {
|
|
75
|
+
if mutated {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
mutated = true
|
|
79
|
+
s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
|
|
80
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
81
|
+
s1rMust(t, os.WriteFile(root+"/sub/file", []byte("foreign"), 0600))
|
|
82
|
+
}}
|
|
83
|
+
work := readWork(pin, "sub", "file")
|
|
84
|
+
if kind == "stat-rename" {
|
|
85
|
+
work.Action = ActionStat
|
|
86
|
+
work.MaxBytes = 0
|
|
87
|
+
}
|
|
88
|
+
if kind == "list-rename" {
|
|
89
|
+
work.Action = ActionList
|
|
90
|
+
work.MaxBytes = 0
|
|
91
|
+
work.Segments = []string{"sub"}
|
|
92
|
+
work.Limit = 20
|
|
93
|
+
}
|
|
94
|
+
r, b := executeReadOnly(ctx, pin, work, acl)
|
|
95
|
+
if r.Code != ErrStale || len(b) != 0 || r.Entry != nil || r.List != nil {
|
|
96
|
+
t.Fatal("renamed ancestry released bytes", r, string(b))
|
|
97
|
+
}
|
|
98
|
+
t.Log(kind + ": replacement after resolver open refuses bytes and metadata with stale")
|
|
99
|
+
case "stream-rename":
|
|
100
|
+
work := readWork(pin, "file")
|
|
101
|
+
work.Action = ActionReadStream
|
|
102
|
+
x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
103
|
+
if r.Code != "" {
|
|
104
|
+
t.Fatal(r)
|
|
105
|
+
}
|
|
106
|
+
defer x.Close()
|
|
107
|
+
b, c := x.ReadChunk(ctx, 3)
|
|
108
|
+
if c != "" || string(b) != "can" {
|
|
109
|
+
t.Fatal(c, string(b))
|
|
110
|
+
}
|
|
111
|
+
s1rMust(t, os.Rename(root+"/file", root+"/old"))
|
|
112
|
+
s1rMust(t, os.Symlink("../bob/file", root+"/file"))
|
|
113
|
+
b, c = x.ReadChunk(ctx, 3)
|
|
114
|
+
if c != ErrDenied || len(b) != 0 {
|
|
115
|
+
t.Fatal("stream followed replacement", c, string(b))
|
|
116
|
+
}
|
|
117
|
+
t.Log("first fixed-FD stream chunk succeeds; symlink replacement refuses next chunk")
|
|
118
|
+
case "create-rename", "publish-rename", "publish-symlink":
|
|
119
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
120
|
+
staged := kind != "create-rename"
|
|
121
|
+
work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"sub", "result"}, MaxBytes: 6}
|
|
122
|
+
if staged {
|
|
123
|
+
work.Action = ActionWriteStream
|
|
124
|
+
work.Staged = true
|
|
125
|
+
}
|
|
126
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
127
|
+
if c != "" {
|
|
128
|
+
t.Fatal(c)
|
|
129
|
+
}
|
|
130
|
+
defer x.Close()
|
|
131
|
+
receipt, c := x.WriteChunk(ctx, []byte("abc"))
|
|
132
|
+
if c != "" || receipt.BytesWritten != 3 {
|
|
133
|
+
t.Fatal(receipt, c)
|
|
134
|
+
}
|
|
135
|
+
if kind == "publish-symlink" {
|
|
136
|
+
s1rMust(t, os.Symlink("../file", root+"/sub/result"))
|
|
137
|
+
receipt, c = x.Commit(ctx)
|
|
138
|
+
if c != ErrDenied || receipt.Published || receipt.Committed {
|
|
139
|
+
t.Fatal("publish replaced symlink", receipt, c)
|
|
140
|
+
}
|
|
141
|
+
target, e := os.Readlink(root + "/sub/result")
|
|
142
|
+
s1rMust(t, e)
|
|
143
|
+
if target != "../file" {
|
|
144
|
+
t.Fatal(target)
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
s1rMust(t, os.Rename(root+"/sub", root+"/moved"))
|
|
148
|
+
s1rMust(t, os.Mkdir(root+"/sub", 0700))
|
|
149
|
+
s1rMust(t, os.WriteFile(root+"/sub/result", []byte("foreign"), 0600))
|
|
150
|
+
if staged {
|
|
151
|
+
receipt, c = x.Commit(ctx)
|
|
152
|
+
if c != ErrStale || receipt.Published {
|
|
153
|
+
t.Fatal("publish after rename", receipt, c)
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
receipt, c = x.WriteChunk(ctx, []byte("def"))
|
|
157
|
+
if c != ErrPartial || receipt.BytesWritten != 3 {
|
|
158
|
+
t.Fatal("write after rename", receipt, c)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
b, e := os.ReadFile(root + "/sub/result")
|
|
162
|
+
s1rMust(t, e)
|
|
163
|
+
if string(b) != "foreign" {
|
|
164
|
+
t.Fatal("foreign destination overwritten", string(b))
|
|
165
|
+
}
|
|
166
|
+
if staged {
|
|
167
|
+
if _, e := os.Stat(root + "/moved/result"); !os.IsNotExist(e) {
|
|
168
|
+
t.Fatal("anonymous stage became visible", e)
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
b, e = os.ReadFile(root + "/moved/result")
|
|
172
|
+
s1rMust(t, e)
|
|
173
|
+
if string(b) != "abc" {
|
|
174
|
+
t.Fatal("partial bytes changed", string(b))
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
t.Logf("%s: refusal=%s receipt=%+v; foreign destination preserved", kind, c, receipt)
|
|
179
|
+
case "publish-permission-loss":
|
|
180
|
+
work := writeWork{RootPath: root, Action: ActionWriteStream, Segments: []string{"result"}, MaxBytes: 3, Staged: true}
|
|
181
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
182
|
+
if c != "" {
|
|
183
|
+
t.Fatal(c)
|
|
184
|
+
}
|
|
185
|
+
defer x.Close()
|
|
186
|
+
_, c = x.WriteChunk(ctx, []byte("abc"))
|
|
187
|
+
if c != "" {
|
|
188
|
+
t.Fatal(c)
|
|
189
|
+
}
|
|
190
|
+
s1rMust(t, os.Chmod(root, 0500))
|
|
191
|
+
defer os.Chmod(root, 0700)
|
|
192
|
+
r, c := x.Commit(ctx)
|
|
193
|
+
// Current S7 maps linkat EACCES to unsupported; require the exact behavior,
|
|
194
|
+
// report it, and preserve the fail-closed publish gate.
|
|
195
|
+
if c != ErrUnsupported || r.Published || r.Committed || r.BytesWritten != 3 {
|
|
196
|
+
t.Fatal("publish after parent chmod", r, c)
|
|
197
|
+
}
|
|
198
|
+
if _, e := os.Stat(root + "/result"); !os.IsNotExist(e) {
|
|
199
|
+
t.Fatal("publish wrote forbidden directory", e)
|
|
200
|
+
}
|
|
201
|
+
t.Log("parent write permission removed: kernel denies linkat; receipt retains staged bytes, published=false")
|
|
202
|
+
case "open-fd-write-permission-loss":
|
|
203
|
+
work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"result"}, MaxBytes: 6}
|
|
204
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
205
|
+
if c != "" {
|
|
206
|
+
t.Fatal(c)
|
|
207
|
+
}
|
|
208
|
+
defer x.Close()
|
|
209
|
+
r, c := x.WriteChunk(ctx, []byte("abc"))
|
|
210
|
+
if c != "" {
|
|
211
|
+
t.Fatal(c)
|
|
212
|
+
}
|
|
213
|
+
s1rMust(t, x.file.Chmod(0000))
|
|
214
|
+
defer x.file.Chmod(0600)
|
|
215
|
+
r, c = x.WriteChunk(ctx, []byte("def"))
|
|
216
|
+
if c != "" || r.BytesWritten != 6 {
|
|
217
|
+
t.Fatal("Linux open-FD semantics", r, c)
|
|
218
|
+
}
|
|
219
|
+
r, c = x.Commit(ctx)
|
|
220
|
+
if c != "" || !r.Committed {
|
|
221
|
+
t.Fatal(r, c)
|
|
222
|
+
}
|
|
223
|
+
b, e := os.ReadFile(root + "/result")
|
|
224
|
+
if !os.IsPermission(e) || len(b) != 0 {
|
|
225
|
+
t.Fatal("new open bypassed chmod", e, string(b))
|
|
226
|
+
}
|
|
227
|
+
t.Log("chmod 000 denies a new open; previously opened writer FD still writes/commits under Linux semantics")
|
|
228
|
+
default:
|
|
229
|
+
t.Fatal("unknown race", strings.TrimSpace(kind))
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"testing"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func TestS1RFixtureContract(t *testing.T) {
|
|
9
|
+
if os.Geteuid() != 0 {
|
|
10
|
+
t.Skip("disposable root VM only")
|
|
11
|
+
}
|
|
12
|
+
root := s1rFixture(t)
|
|
13
|
+
for _, name := range []string{"alice", "bob", "supplementary", "acl-allow", "acl-mask", "acl-file-mask", "inherit", "readonly", "race"} {
|
|
14
|
+
if _, err := os.Stat(root + "/" + name + "/file"); err != nil {
|
|
15
|
+
t.Fatal(name, err)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
package helper
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"crypto/rand"
|
|
5
|
+
"encoding/hex"
|
|
4
6
|
"encoding/json"
|
|
5
7
|
"io"
|
|
6
8
|
"net"
|
|
@@ -13,7 +15,7 @@ import (
|
|
|
13
15
|
|
|
14
16
|
func serveLinux(c Client) error {
|
|
15
17
|
r, err := readRecord(c.StateDir, 0)
|
|
16
|
-
if err != nil || !r.Enabled || r.Inventory != c.Expected {
|
|
18
|
+
if err != nil || !r.Enabled || r.Inventory != c.Expected || r.Lifecycle == nil || r.Lifecycle.Phase != "running" {
|
|
17
19
|
return errTrust
|
|
18
20
|
}
|
|
19
21
|
// Only the supervisor writes process.json.
|
|
@@ -76,8 +78,47 @@ func serveLinux(c Client) error {
|
|
|
76
78
|
return
|
|
77
79
|
}
|
|
78
80
|
r, err := readRecord(c.StateDir, 0)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
readiness := "fenced"
|
|
82
|
+
if err == nil && r.Enabled && r.Inventory == c.Expected && r.Lifecycle != nil && r.Lifecycle.Phase == "running" {
|
|
83
|
+
readiness = parentReadiness(c)
|
|
84
|
+
}
|
|
85
|
+
res := Respond(c.Expected, readiness != "ready", req)
|
|
86
|
+
if readiness != "ready" {
|
|
87
|
+
res.Error = readiness
|
|
88
|
+
}
|
|
89
|
+
json.NewEncoder(conn).Encode(res)
|
|
81
90
|
}()
|
|
82
91
|
}
|
|
83
92
|
}
|
|
93
|
+
|
|
94
|
+
// No lifecycle mutations: only the exact owned child can request admission.
|
|
95
|
+
func parentReadiness(c Client) string {
|
|
96
|
+
p, err := readProcess(c.RunDir, 0)
|
|
97
|
+
if err != nil || p.PID != os.Getppid() {
|
|
98
|
+
return "fenced"
|
|
99
|
+
}
|
|
100
|
+
actual, err := inspectSupervisor(p.PID, c.Expected)
|
|
101
|
+
if err != nil || actual != p {
|
|
102
|
+
return "fenced"
|
|
103
|
+
}
|
|
104
|
+
conn, err := net.DialTimeout("unix", filepath.Join(c.RunDir, "supervisor.sock"), 100*time.Millisecond)
|
|
105
|
+
if err != nil {
|
|
106
|
+
return "fenced"
|
|
107
|
+
}
|
|
108
|
+
defer conn.Close()
|
|
109
|
+
peer, err := peerCredentials(conn.(*net.UnixConn))
|
|
110
|
+
if err != nil || peer.Uid != 0 || int(peer.Pid) != p.PID {
|
|
111
|
+
return "fenced"
|
|
112
|
+
}
|
|
113
|
+
conn.SetDeadline(time.Now().Add(200 * time.Millisecond))
|
|
114
|
+
var nonce [32]byte
|
|
115
|
+
if _, err := rand.Read(nonce[:]); err != nil {
|
|
116
|
+
return "fenced"
|
|
117
|
+
}
|
|
118
|
+
req := supervisorRequest{Process: p, Op: "admit", Nonce: hex.EncodeToString(nonce[:])}
|
|
119
|
+
if json.NewEncoder(conn).Encode(req) != nil {
|
|
120
|
+
return "fenced"
|
|
121
|
+
}
|
|
122
|
+
res, err := decodeSupervisorReply(conn, c.Expected, req.Nonce)
|
|
123
|
+
return supervisorReadiness(res, err)
|
|
124
|
+
}
|
|
@@ -25,6 +25,7 @@ type Inventory struct {
|
|
|
25
25
|
Protocol int `json:"protocol"`
|
|
26
26
|
PayloadDigest string `json:"payloadDigest"`
|
|
27
27
|
RegistryDigest string `json:"registryDigest"`
|
|
28
|
+
DataAccess string `json:"dataAccess,omitempty"`
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
var digestPattern = regexp.MustCompile(`^[a-f0-9]{64}$`)
|
|
@@ -32,13 +33,16 @@ var packagePattern = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]{1,63}$`)
|
|
|
32
33
|
var versionPattern = regexp.MustCompile(`^\d+(\.\d+){0,3}-\d{4}$`)
|
|
33
34
|
|
|
34
35
|
func (i Inventory) Valid() bool {
|
|
35
|
-
|
|
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)
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
type Record struct {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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"`
|
|
42
46
|
}
|
|
43
47
|
type Request struct {
|
|
44
48
|
Inventory Inventory `json:"inventory"`
|
|
@@ -161,14 +165,16 @@ func readRecord(dir string, owner uint32) (Record, error) {
|
|
|
161
165
|
d := json.NewDecoder(io.LimitReader(f, 4097))
|
|
162
166
|
d.DisallowUnknownFields()
|
|
163
167
|
var decoded struct {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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"`
|
|
167
173
|
}
|
|
168
|
-
if d.Decode(&decoded) != nil || d.Decode(new(any)) != io.EOF || !decoded.Inventory.Valid() || decoded.Enabled == nil {
|
|
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) {
|
|
169
175
|
return r, errTrust
|
|
170
176
|
}
|
|
171
|
-
r = Record{Inventory: decoded.Inventory, Enabled: *decoded.Enabled, Residual: decoded.Residual}
|
|
177
|
+
r = Record{Schema: decoded.Schema, Inventory: decoded.Inventory, Enabled: *decoded.Enabled, Residual: decoded.Residual, Lifecycle: decoded.Lifecycle}
|
|
172
178
|
return r, nil
|
|
173
179
|
}
|
|
174
180
|
|
|
@@ -201,6 +207,36 @@ func (c Client) Status(ctx context.Context) State {
|
|
|
201
207
|
s.Cleanup = "required"
|
|
202
208
|
return s
|
|
203
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
|
+
}
|
|
204
240
|
// Conflict has precedence over missing approval. Even an unapproved leftover
|
|
205
241
|
// socket is probed before claiming that authorization alone can fix it.
|
|
206
242
|
if e := protected(c.RunDir, c.Owner, true); e != nil && !errors.Is(e, fs.ErrNotExist) {
|
|
@@ -215,7 +251,24 @@ func (c Client) Status(ctx context.Context) State {
|
|
|
215
251
|
}
|
|
216
252
|
state, reason := c.probe(ctx, socket)
|
|
217
253
|
if state != "ready" {
|
|
218
|
-
|
|
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
|
|
219
272
|
}
|
|
220
273
|
} else if !errors.Is(e, fs.ErrNotExist) {
|
|
221
274
|
return result("failed", "runtime-unreadable")
|
|
@@ -226,7 +279,11 @@ func (c Client) Status(ctx context.Context) State {
|
|
|
226
279
|
if e != nil {
|
|
227
280
|
return result("stopped", "runtime-missing")
|
|
228
281
|
}
|
|
229
|
-
|
|
282
|
+
s := result("ready", "live-handshake")
|
|
283
|
+
if r.Lifecycle != nil {
|
|
284
|
+
s.PackageRunning = "running"
|
|
285
|
+
}
|
|
286
|
+
return s
|
|
230
287
|
}
|
|
231
288
|
|
|
232
289
|
func (c Client) probe(ctx context.Context, socket string) (string, string) {
|
|
@@ -264,6 +321,12 @@ func (c Client) probe(ctx context.Context, socket string) (string, string) {
|
|
|
264
321
|
if res.Nonce != req.Nonce || res.Inventory != c.Expected || res.Error == "incompatible" {
|
|
265
322
|
return "incompatible", "handshake-mismatch"
|
|
266
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
|
+
}
|
|
267
330
|
if !res.OK || res.Error != "" {
|
|
268
331
|
return "failed", "health-refused"
|
|
269
332
|
}
|
|
@@ -203,3 +203,86 @@ func TestProcessRecordIsNotReadableByOrdinaryOSUsers(t *testing.T) {
|
|
|
203
203
|
t.Fatalf("process record permissions: %v %v", s, err)
|
|
204
204
|
}
|
|
205
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
|
+
}
|
|
@@ -70,15 +70,38 @@ func stopChild(ctx context.Context, child supervisedChild, grace time.Duration)
|
|
|
70
70
|
// Read to actual connection EOF. A LimitReader's synthetic EOF at the size
|
|
71
71
|
// cap can never certify supervisor exit, so reaching that cap is a refusal.
|
|
72
72
|
func readSupervisorReply(reader io.Reader, want Inventory, nonce string) error {
|
|
73
|
-
|
|
74
|
-
if err != nil ||
|
|
73
|
+
res, err := decodeSupervisorReply(reader, want, nonce)
|
|
74
|
+
if err != nil || !res.OK || res.Error != "" {
|
|
75
75
|
return errTrust
|
|
76
76
|
}
|
|
77
|
+
return nil
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Parsing authenticates the entire bounded reply; readiness and stop ACKs
|
|
81
|
+
// retain separate acceptance rules. No refusal can certify supervisor exit.
|
|
82
|
+
func decodeSupervisorReply(reader io.Reader, want Inventory, nonce string) (Response, error) {
|
|
77
83
|
var res Response
|
|
84
|
+
b, err := io.ReadAll(io.LimitReader(reader, 4097))
|
|
85
|
+
if err != nil || len(b) > 4096 {
|
|
86
|
+
return res, errTrust
|
|
87
|
+
}
|
|
78
88
|
d := json.NewDecoder(bytes.NewReader(b))
|
|
79
89
|
d.DisallowUnknownFields()
|
|
80
|
-
if d.Decode(&res) != nil || d.Decode(new(any)) != io.EOF ||
|
|
81
|
-
return errTrust
|
|
90
|
+
if d.Decode(&res) != nil || d.Decode(new(any)) != io.EOF || res.Inventory != want || res.Nonce != nonce {
|
|
91
|
+
return Response{}, errTrust
|
|
82
92
|
}
|
|
83
|
-
return nil
|
|
93
|
+
return res, nil
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// A pending health refusal cannot be used as a successful admission or stop ACK.
|
|
97
|
+
func supervisorReadiness(res Response, err error) string {
|
|
98
|
+
if err == nil {
|
|
99
|
+
if res.OK && res.Error == "" {
|
|
100
|
+
return "ready"
|
|
101
|
+
}
|
|
102
|
+
if !res.OK && res.Error == "reload-revalidating" {
|
|
103
|
+
return res.Error
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return "fenced"
|
|
84
107
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bufio"
|
|
5
|
+
"bytes"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"io"
|
|
8
|
+
"net"
|
|
9
|
+
"time"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
type supervisorRequest struct {
|
|
13
|
+
Process Process `json:"process"`
|
|
14
|
+
Op string `json:"op"`
|
|
15
|
+
Nonce string `json:"nonce"`
|
|
16
|
+
Data json.RawMessage `json:"data,omitempty"`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Legacy M1 requests do not half-close; grant controls MUST half-close. Count
|
|
20
|
+
// the entire v2 frame (including whitespace), reject duplicates and trailing
|
|
21
|
+
// frames, and bound both time and memory. The outer process binds this socket.
|
|
22
|
+
func decodeSupervisorRequest(reader io.Reader) (supervisorRequest, Code) {
|
|
23
|
+
var req supervisorRequest
|
|
24
|
+
limited := &io.LimitedReader{R: reader, N: MaxControlBytes + 1}
|
|
25
|
+
d := json.NewDecoder(limited)
|
|
26
|
+
var raw json.RawMessage
|
|
27
|
+
if d.Decode(&raw) != nil {
|
|
28
|
+
return req, ErrInvalid
|
|
29
|
+
}
|
|
30
|
+
if code := decodeDataObject(bytes.NewReader(raw), &req, MaxControlBytes); code != "" {
|
|
31
|
+
return req, code
|
|
32
|
+
}
|
|
33
|
+
if req.Op == "grants" {
|
|
34
|
+
rest, err := io.ReadAll(io.MultiReader(d.Buffered(), limited))
|
|
35
|
+
if err != nil {
|
|
36
|
+
return req, ErrInvalid
|
|
37
|
+
}
|
|
38
|
+
if limited.N <= 0 {
|
|
39
|
+
return req, ErrLimit
|
|
40
|
+
}
|
|
41
|
+
if len(bytes.TrimSpace(rest)) != 0 {
|
|
42
|
+
return req, ErrInvalid
|
|
43
|
+
}
|
|
44
|
+
} else if d.InputOffset() > 4096 || len(req.Data) > 0 {
|
|
45
|
+
return req, ErrInvalid
|
|
46
|
+
}
|
|
47
|
+
if !allReferences(req.Nonce) || (req.Op != "admit" && req.Op != "stop" && req.Op != "grants") {
|
|
48
|
+
return req, ErrInvalid
|
|
49
|
+
}
|
|
50
|
+
return req, ""
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const supervisorAttestationWait = time.Second
|
|
54
|
+
const supervisorFrameBudget = 100 * time.Millisecond
|
|
55
|
+
|
|
56
|
+
// The caller sends no frame bytes until its full post-connect hash succeeds.
|
|
57
|
+
// Separate the bounded wait for that computation from the fixed frame budget.
|
|
58
|
+
func receiveSupervisorRequest(conn net.Conn) (supervisorRequest, Code) {
|
|
59
|
+
firstDeadline := time.Now().Add(supervisorAttestationWait)
|
|
60
|
+
if err := conn.SetReadDeadline(firstDeadline); err != nil {
|
|
61
|
+
return supervisorRequest{}, ErrInvalid
|
|
62
|
+
}
|
|
63
|
+
reader := bufio.NewReader(conn)
|
|
64
|
+
if _, err := reader.Peek(1); err != nil || !time.Now().Before(firstDeadline) {
|
|
65
|
+
return supervisorRequest{}, ErrInvalid
|
|
66
|
+
}
|
|
67
|
+
frameDeadline := time.Now().Add(supervisorFrameBudget)
|
|
68
|
+
if err := conn.SetDeadline(frameDeadline); err != nil {
|
|
69
|
+
return supervisorRequest{}, ErrInvalid
|
|
70
|
+
}
|
|
71
|
+
req, code := decodeSupervisorRequest(reader)
|
|
72
|
+
if !time.Now().Before(frameDeadline) {
|
|
73
|
+
return supervisorRequest{}, ErrInvalid
|
|
74
|
+
}
|
|
75
|
+
return req, code
|
|
76
|
+
}
|