@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,124 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/binary"
|
|
7
|
+
"encoding/json"
|
|
8
|
+
"errors"
|
|
9
|
+
"github.com/godbus/dbus/v5"
|
|
10
|
+
"io"
|
|
11
|
+
"strings"
|
|
12
|
+
"testing"
|
|
13
|
+
"time"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
func diagnosticObserver(t *testing.T) *unitObserver {
|
|
17
|
+
t.Helper()
|
|
18
|
+
o := &unitObserver{owner: ":1.1", unit: "pkgctl-root.service", path: systemdUnitPath("pkgctl-root.service"), gate: newAdmission(testBinding())}
|
|
19
|
+
if err := o.observeValues(testBinding(), activeUnitValues(o), 0, time.Now()); err != nil {
|
|
20
|
+
t.Fatal(err)
|
|
21
|
+
}
|
|
22
|
+
return o
|
|
23
|
+
}
|
|
24
|
+
func TestLinuxObserverSignalSubReasons(t *testing.T) {
|
|
25
|
+
cases := []struct {
|
|
26
|
+
detail, name string
|
|
27
|
+
body []interface{}
|
|
28
|
+
path dbus.ObjectPath
|
|
29
|
+
sender string
|
|
30
|
+
}{
|
|
31
|
+
{"reload-shape", managerInterface + ".Reloading", nil, "/org/freedesktop/systemd1", ":1.1"},
|
|
32
|
+
{"reload-type", managerInterface + ".Reloading", []interface{}{"secret"}, "/org/freedesktop/systemd1", ":1.1"},
|
|
33
|
+
{"unit-removed-shape", managerInterface + ".UnitRemoved", []interface{}{"pkgctl-root.service"}, "/org/freedesktop/systemd1", ":1.1"},
|
|
34
|
+
{"properties-map", propertiesInterface + ".PropertiesChanged", []interface{}{unitInterface, "secret", []string{}}, systemdUnitPath("pkgctl-root.service"), ":1.1"},
|
|
35
|
+
{"property-invalidated-InvocationID", propertiesInterface + ".PropertiesChanged", []interface{}{unitInterface, map[string]dbus.Variant{}, []string{"InvocationID", "secret"}}, systemdUnitPath("pkgctl-root.service"), ":1.1"},
|
|
36
|
+
{"properties-invalidated-type", propertiesInterface + ".PropertiesChanged", []interface{}{unitInterface, map[string]dbus.Variant{}, "secret"}, systemdUnitPath("pkgctl-root.service"), ":1.1"},
|
|
37
|
+
{"owner-signal", "org.freedesktop.DBus.NameOwnerChanged", []interface{}{systemdName, ":1.1", ":1.2"}, "/org/freedesktop/DBus", "org.freedesktop.DBus"},
|
|
38
|
+
{"property-ActiveState", propertiesInterface + ".PropertiesChanged", []interface{}{unitInterface, map[string]dbus.Variant{"ActiveState": dbus.MakeVariant("inactive")}, []string{}}, systemdUnitPath("pkgctl-root.service"), ":1.1"},
|
|
39
|
+
}
|
|
40
|
+
for _, c := range cases {
|
|
41
|
+
t.Run(c.detail, func(t *testing.T) {
|
|
42
|
+
o := diagnosticObserver(t)
|
|
43
|
+
s := &dbus.Signal{Sender: c.sender, Name: c.name, Path: c.path, Body: c.body, Sequence: dbus.Sequence(99)}
|
|
44
|
+
o.DeliverSignal("", "", s)
|
|
45
|
+
d := o.gate.observerDiagnostic("")
|
|
46
|
+
if d.Fence.Detail != c.detail || d.Fence.Signal != c.name || d.Fence.Sender != c.sender || d.Fence.SignalSequence != 99 || d.Fence.At.IsZero() {
|
|
47
|
+
t.Fatalf("wrong diagnostic: %+v", d)
|
|
48
|
+
}
|
|
49
|
+
if strings.Contains(d.Fence.Detail, "secret") {
|
|
50
|
+
t.Fatal("body leaked")
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
o := diagnosticObserver(t)
|
|
55
|
+
o.Terminate()
|
|
56
|
+
if o.gate.observerDiagnostic("").Fence.Detail != "subscription-terminated" {
|
|
57
|
+
t.Fatal("terminate unclassified")
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
func TestLinuxObserverQueryErrorClassification(t *testing.T) {
|
|
61
|
+
for _, c := range []struct {
|
|
62
|
+
err error
|
|
63
|
+
want string
|
|
64
|
+
}{{context.Canceled, "canceled"}, {context.DeadlineExceeded, "deadline"}, {io.EOF, "eof"}, {errTrust, "trust"}, {dbus.Error{Name: "org.freedesktop.systemd1.NoSuchUnit", Body: []interface{}{"secret"}}, "dbus-no-unit"}, {errors.New("secret"), "other"}} {
|
|
65
|
+
o := diagnosticObserver(t)
|
|
66
|
+
err := o.reconcileSnapshot(context.Background(), func(context.Context) (Binding, map[string]dbus.Variant, error) {
|
|
67
|
+
return Binding{}, nil, &unitSnapshotError{reason: "observation-unavailable", cause: c.err, phase: "get-unit"}
|
|
68
|
+
})
|
|
69
|
+
d := o.gate.observerDiagnostic("")
|
|
70
|
+
if err == nil || d.Fence.Phase != "get-unit" || d.Fence.ErrorClass != c.want || d.Fence.Detail != "query-failed" {
|
|
71
|
+
t.Fatalf("classification %s: %+v %v", c.want, d, err)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
func TestLinuxObserverDeadlineAndInvalidSnapshot(t *testing.T) {
|
|
76
|
+
o := diagnosticObserver(t)
|
|
77
|
+
now := time.Now()
|
|
78
|
+
o.gate.requestUnitCheck(true, now)
|
|
79
|
+
o.gate.fenced(now.Add(unitReloadBudget))
|
|
80
|
+
if o.gate.observerDiagnostic("").Fence.Detail != "reload-deadline" {
|
|
81
|
+
t.Fatal("budget unclassified")
|
|
82
|
+
}
|
|
83
|
+
for _, key := range []string{"Id", "LoadState", "ActiveState", "SubState", "Job", "ActiveEnterTimestampMonotonic", "InvocationID"} {
|
|
84
|
+
o := diagnosticObserver(t)
|
|
85
|
+
v := activeUnitValues(o)
|
|
86
|
+
v[key] = dbus.MakeVariant("secret")
|
|
87
|
+
_ = o.observeValues(testBinding(), v, 0, time.Now())
|
|
88
|
+
d := o.gate.observerDiagnostic("")
|
|
89
|
+
if d.Fence.Detail != "snapshot-"+key || d.Fence.Phase != "validate-values" {
|
|
90
|
+
t.Fatalf("property %s: %+v", key, d.Fence)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
func TestLinuxObserverWireSerialAndPrivacy(t *testing.T) {
|
|
96
|
+
o := diagnosticObserver(t)
|
|
97
|
+
m := &dbus.Message{Type: dbus.TypeSignal, Headers: map[dbus.HeaderField]dbus.Variant{
|
|
98
|
+
dbus.FieldInterface: dbus.MakeVariant(managerInterface), dbus.FieldMember: dbus.MakeVariant("Reloading"), dbus.FieldSender: dbus.MakeVariant(o.owner), dbus.FieldPath: dbus.MakeVariant(dbus.ObjectPath("/org/freedesktop/systemd1")), dbus.FieldSignature: dbus.MakeVariant(dbus.SignatureOf(true))}, Body: []interface{}{true}}
|
|
99
|
+
var wire bytes.Buffer
|
|
100
|
+
if err := m.EncodeTo(&wire, binary.LittleEndian); err != nil {
|
|
101
|
+
t.Fatal(err)
|
|
102
|
+
}
|
|
103
|
+
b := wire.Bytes()
|
|
104
|
+
binary.LittleEndian.PutUint32(b[8:12], 321)
|
|
105
|
+
parsed, err := dbus.DecodeMessage(bytes.NewReader(b))
|
|
106
|
+
if err != nil {
|
|
107
|
+
t.Fatal(err)
|
|
108
|
+
}
|
|
109
|
+
o.incomingObserverMessage(parsed)
|
|
110
|
+
o.DeliverSignal("", "", &dbus.Signal{Name: managerInterface + ".Reloading", Sender: o.owner, Path: "/org/freedesktop/systemd1", Body: []interface{}{"secret-session-password-path"}, Sequence: dbus.Sequence(123)})
|
|
111
|
+
d := o.gate.observerDiagnostic("")
|
|
112
|
+
if d.Fence.WireSerial != 321 || d.Fence.SignalSequence != 123 {
|
|
113
|
+
t.Fatalf("wire/receive counters confused: %+v", d)
|
|
114
|
+
}
|
|
115
|
+
payload, _ := json.Marshal(d)
|
|
116
|
+
if bytes.Contains(payload, []byte("secret")) {
|
|
117
|
+
t.Fatal("body persisted")
|
|
118
|
+
}
|
|
119
|
+
for _, sender := range []string{"session-secret", ":" + strings.Repeat("1", 40), ":1.password"} {
|
|
120
|
+
if safeBusSender(sender) != "" {
|
|
121
|
+
t.Fatal("untrusted sender persisted")
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"sync"
|
|
9
|
+
"testing"
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func TestObserverDiagnosticFirstFenceAndBound(t *testing.T) {
|
|
14
|
+
g := newAdmission(testBinding())
|
|
15
|
+
for n := 0; n < observerEventLimit+20; n++ {
|
|
16
|
+
g.recordObserver(observerEvent{Kind: "query-ok", QuerySerial: uint64(n)})
|
|
17
|
+
}
|
|
18
|
+
g.fenceObserver("observation-unavailable", observerEvent{Kind: "fence", Detail: "query-failed", Phase: "get-unit", ErrorClass: "canceled"})
|
|
19
|
+
g.fenceObserver("bus-owner-changed", observerEvent{Kind: "fence", Detail: "owner-signal"})
|
|
20
|
+
d := g.observerDiagnostic(strings.Repeat("e", 64))
|
|
21
|
+
if d.Fence.Detail != "query-failed" || d.Fence.Phase != "get-unit" || d.Reason != "observation-unavailable" {
|
|
22
|
+
t.Fatalf("wrong first cause: %+v", d)
|
|
23
|
+
}
|
|
24
|
+
if len(d.Events) != observerEventLimit || d.Events[0].QuerySerial != 22 {
|
|
25
|
+
t.Fatalf("bad bounded order: %+v", d.Events)
|
|
26
|
+
}
|
|
27
|
+
d.Events[0].Kind = "mutated"
|
|
28
|
+
if g.observerDiagnostic(d.Epoch).Events[0].Kind == "mutated" {
|
|
29
|
+
t.Fatal("snapshot aliases ring")
|
|
30
|
+
}
|
|
31
|
+
b, err := json.Marshal(d)
|
|
32
|
+
if err != nil || len(b) > observerDiagnosticLimit {
|
|
33
|
+
t.Fatalf("size %d err %v", len(b), err)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
func TestObserverDiagnosticConcurrentAdmission(t *testing.T) {
|
|
37
|
+
g := newAdmission(testBinding())
|
|
38
|
+
var wg sync.WaitGroup
|
|
39
|
+
for n := 0; n < 8; n++ {
|
|
40
|
+
wg.Add(1)
|
|
41
|
+
go func() {
|
|
42
|
+
defer wg.Done()
|
|
43
|
+
for i := 0; i < 100; i++ {
|
|
44
|
+
g.recordObserver(observerEvent{Kind: "query-start"})
|
|
45
|
+
g.fenceObserver("observation-unavailable", observerEvent{Detail: "subscription-terminated"})
|
|
46
|
+
g.allow(time.Now())
|
|
47
|
+
g.observerDiagnostic(strings.Repeat("e", 64))
|
|
48
|
+
}
|
|
49
|
+
}()
|
|
50
|
+
}
|
|
51
|
+
wg.Wait()
|
|
52
|
+
if g.allow(time.Now()) || g.observerDiagnostic("").Fence.Detail != "subscription-terminated" {
|
|
53
|
+
t.Fatal("fence changed")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
func TestObserverDiagnosticPersistenceCannotBlockCompletion(t *testing.T) {
|
|
57
|
+
for _, unwritable := range []bool{false, true} {
|
|
58
|
+
t.Run(map[bool]string{false: "root-private", true: "write-failure"}[unwritable], func(t *testing.T) {
|
|
59
|
+
c := fixture(t)
|
|
60
|
+
b := testBinding()
|
|
61
|
+
l, err := newLifecycle(b)
|
|
62
|
+
if err != nil {
|
|
63
|
+
t.Fatal(err)
|
|
64
|
+
}
|
|
65
|
+
if err = writeProtected(c.StateDir, "approval.json", Record{Schema: 2, Inventory: c.Expected, Enabled: true, Lifecycle: l}); err != nil {
|
|
66
|
+
t.Fatal(err)
|
|
67
|
+
}
|
|
68
|
+
g := newAdmission(b)
|
|
69
|
+
g.fenceObserver("observation-unavailable", observerEvent{Detail: "verification-deadline"})
|
|
70
|
+
if unwritable {
|
|
71
|
+
if err = os.Mkdir(filepath.Join(c.StateDir, "observer-diagnostic.json"), 0700); err != nil {
|
|
72
|
+
t.Fatal(err)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
persistObserverDiagnostic(c, l.Epoch, g)
|
|
76
|
+
if err = fenceRecord(c, l.Epoch, g.reason(), g.observerDiagnostic(l.Epoch).Fence.Detail); err != nil {
|
|
77
|
+
t.Fatal(err)
|
|
78
|
+
}
|
|
79
|
+
p := Process{Inventory: c.Expected, Mode: "supervised", Boot: b.Boot, PID: 42, Start: "123", Inode: 9}
|
|
80
|
+
if err = completeRecord(c, l.Epoch, p); err != nil {
|
|
81
|
+
t.Fatal(err)
|
|
82
|
+
}
|
|
83
|
+
r, err := readRecord(c.StateDir, c.Owner)
|
|
84
|
+
if err != nil || r.Lifecycle.SubReason != "verification-deadline" || r.Lifecycle.Phase != "stopped" {
|
|
85
|
+
t.Fatalf("record %+v %v", r, err)
|
|
86
|
+
}
|
|
87
|
+
if _, err = completionRecord(c, r); err != nil {
|
|
88
|
+
t.Fatal(err)
|
|
89
|
+
}
|
|
90
|
+
if !unwritable {
|
|
91
|
+
st, err := os.Stat(filepath.Join(c.StateDir, "observer-diagnostic.json"))
|
|
92
|
+
if err != nil || st.Mode().Perm() != 0600 || st.Size() > observerDiagnosticLimit {
|
|
93
|
+
t.Fatalf("private file %v %v", st, err)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"io"
|
|
8
|
+
"net"
|
|
9
|
+
"os"
|
|
10
|
+
"runtime"
|
|
11
|
+
"strconv"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
// Root bootstrap accepts only an anonymous descriptor bound to its root parent.
|
|
16
|
+
// After permanent credential drop there is no root-side business filesystem I/O.
|
|
17
|
+
func operationChildLinux(c Client) error {
|
|
18
|
+
runtime.LockOSThread()
|
|
19
|
+
defer runtime.UnlockOSThread()
|
|
20
|
+
parent, err := strconv.Atoi(os.Getenv("SYNOPKGLAND_PARENT"))
|
|
21
|
+
if err != nil {
|
|
22
|
+
return errTrust
|
|
23
|
+
}
|
|
24
|
+
if err := armParentDeath(parent, setParentDeath, os.Getppid); err != nil {
|
|
25
|
+
return err
|
|
26
|
+
}
|
|
27
|
+
if _, err := inspectSupervisor(parent, c.Expected); err != nil {
|
|
28
|
+
return err
|
|
29
|
+
}
|
|
30
|
+
if err := inheritLifetime(c); err != nil {
|
|
31
|
+
return err
|
|
32
|
+
}
|
|
33
|
+
f := os.NewFile(4, "operation-control")
|
|
34
|
+
if f == nil {
|
|
35
|
+
return errTrust
|
|
36
|
+
}
|
|
37
|
+
defer f.Close()
|
|
38
|
+
control, err := operationSocket(f)
|
|
39
|
+
if err != nil {
|
|
40
|
+
return err
|
|
41
|
+
}
|
|
42
|
+
defer control.Close()
|
|
43
|
+
peer, err := peerCredentials(control)
|
|
44
|
+
if err != nil || int(peer.Pid) != parent || peer.Uid != 0 {
|
|
45
|
+
return errTrust
|
|
46
|
+
}
|
|
47
|
+
var boot operationBootstrap
|
|
48
|
+
if _, err := readOperationPacketBound(control, &boot, MaxControlBytes, 300*time.Millisecond); err != nil {
|
|
49
|
+
return err
|
|
50
|
+
}
|
|
51
|
+
r, err := readRecord(c.StateDir, 0)
|
|
52
|
+
if err != nil || r.Lifecycle == nil || boot.Binding.Inventory != c.Expected || boot.Binding.Epoch != r.Lifecycle.Epoch || !digestPattern.MatchString(boot.Token) || !digestPattern.MatchString(boot.Binding.OperationID) || boot.UID == 0 || boot.GID == 0 || boot.Groups == nil || len(boot.Groups) > 65536 {
|
|
53
|
+
return errTrust
|
|
54
|
+
}
|
|
55
|
+
if boot.ReadOnly != nil && (boot.ReadOnly.validate() != "" || !allReferences(boot.SubjectRef, boot.SessionRef)) {
|
|
56
|
+
return errTrust
|
|
57
|
+
}
|
|
58
|
+
if boot.Write != nil && (boot.ReadOnly != nil || boot.Write.validate() != "" || !allReferences(boot.SubjectRef, boot.SessionRef)) {
|
|
59
|
+
return errTrust
|
|
60
|
+
}
|
|
61
|
+
if err := dropOperationCredentials(parent, boot); err != nil {
|
|
62
|
+
return err
|
|
63
|
+
}
|
|
64
|
+
packetLimit := MaxHealthBytes
|
|
65
|
+
if boot.ReadOnly != nil || boot.Write != nil {
|
|
66
|
+
packetLimit = MaxControlBytes
|
|
67
|
+
}
|
|
68
|
+
if err := writeOperationPacketBound(control, boot, packetLimit); err != nil {
|
|
69
|
+
return err
|
|
70
|
+
}
|
|
71
|
+
if boot.Write != nil {
|
|
72
|
+
timeout := BoundedTimeout
|
|
73
|
+
if boot.Write.Staged {
|
|
74
|
+
timeout = StreamTotalTimeout
|
|
75
|
+
}
|
|
76
|
+
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
|
77
|
+
defer cancel()
|
|
78
|
+
return operationWriteChild(ctx, control, boot)
|
|
79
|
+
}
|
|
80
|
+
var source *actorReadTransfer
|
|
81
|
+
operationTimeout := BoundedTimeout
|
|
82
|
+
if boot.ReadOnly != nil && boot.ReadOnly.Action == ActionReadStream {
|
|
83
|
+
operationTimeout = StreamTotalTimeout
|
|
84
|
+
}
|
|
85
|
+
ctx, cancel := context.WithTimeout(context.Background(), operationTimeout)
|
|
86
|
+
defer cancel()
|
|
87
|
+
if boot.ReadOnly != nil {
|
|
88
|
+
witness := os.NewFile(6, "readonly-root-witness")
|
|
89
|
+
if witness == nil {
|
|
90
|
+
return errTrust
|
|
91
|
+
}
|
|
92
|
+
defer witness.Close()
|
|
93
|
+
operationMountIDFallback = operationMountIDProxy(control, boot)
|
|
94
|
+
pin := &pinnedReadOnlyRoot{path: boot.ReadOnly.RootPath, file: witness}
|
|
95
|
+
var result readOnlyResult
|
|
96
|
+
if boot.ReadOnly.Action == ActionRead || boot.ReadOnly.Action == ActionReadStream {
|
|
97
|
+
source, result = openActorReadTransfer(ctx, pin, *boot.ReadOnly, operationReadOnlyACL)
|
|
98
|
+
if source != nil {
|
|
99
|
+
defer source.Close()
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
result, _ = executeReadOnly(ctx, pin, *boot.ReadOnly, operationReadOnlyACL)
|
|
103
|
+
}
|
|
104
|
+
if err := writeOperationPacketBound(control, readOnlyPacket{Binding: boot.Binding, Token: boot.Token, Result: &result}, MaxControlBytes); err != nil {
|
|
105
|
+
return err
|
|
106
|
+
}
|
|
107
|
+
if result.Code != "" || result.Bytes == 0 {
|
|
108
|
+
return awaitReadOnlyFinish(control, boot.Token)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
output := os.NewFile(5, "operation-data")
|
|
112
|
+
if output == nil {
|
|
113
|
+
return errTrust
|
|
114
|
+
}
|
|
115
|
+
defer output.Close()
|
|
116
|
+
deadline, _ := ctx.Deadline()
|
|
117
|
+
ceiling := uint64(MaxBoundedBytes)
|
|
118
|
+
if boot.ReadOnly != nil {
|
|
119
|
+
ceiling = boot.ReadOnly.MaxBytes
|
|
120
|
+
}
|
|
121
|
+
var total, sequence uint64
|
|
122
|
+
for {
|
|
123
|
+
// Idle synthetic children are bounded by the future stream idle ceiling.
|
|
124
|
+
readDeadline := deadline
|
|
125
|
+
if boot.ReadOnly != nil && boot.ReadOnly.Action == ActionReadStream && time.Now().Add(StreamIdleTimeout).Before(readDeadline) {
|
|
126
|
+
readDeadline = time.Now().Add(StreamIdleTimeout)
|
|
127
|
+
}
|
|
128
|
+
control.SetReadDeadline(readDeadline)
|
|
129
|
+
raw := make([]byte, MaxHealthBytes+1)
|
|
130
|
+
n, err := control.Read(raw)
|
|
131
|
+
if err != nil {
|
|
132
|
+
return err
|
|
133
|
+
}
|
|
134
|
+
var lease operationLease
|
|
135
|
+
d := json.NewDecoder(bytes.NewReader(raw[:n]))
|
|
136
|
+
d.DisallowUnknownFields()
|
|
137
|
+
if n > MaxHealthBytes || d.Decode(&lease) != nil || d.Decode(new(any)) != io.EOF || lease.Token != boot.Token || lease.Sequence != sequence+1 || lease.Bytes == 0 || lease.Bytes > MaxChunkBytes || uint64(lease.Bytes) > ceiling || total > ceiling-uint64(lease.Bytes) {
|
|
138
|
+
return errTrust
|
|
139
|
+
}
|
|
140
|
+
sequence++
|
|
141
|
+
total += uint64(lease.Bytes)
|
|
142
|
+
if boot.ReadOnly != nil {
|
|
143
|
+
if source == nil || lease.ProofDeadline == 0 || lease.SubjectRef != boot.SubjectRef || lease.SessionRef != boot.SessionRef {
|
|
144
|
+
return errTrust
|
|
145
|
+
}
|
|
146
|
+
proofDeadline := time.Unix(0, lease.ProofDeadline)
|
|
147
|
+
if !time.Now().Before(proofDeadline) || time.Until(proofDeadline) > NativeProofFreshness {
|
|
148
|
+
return ErrStale
|
|
149
|
+
}
|
|
150
|
+
proofCtx, proofCancel := context.WithDeadline(ctx, proofDeadline)
|
|
151
|
+
data, code := source.ReadChunk(proofCtx, lease.Bytes)
|
|
152
|
+
proofCancel()
|
|
153
|
+
result := readOnlyResult{Code: code}
|
|
154
|
+
if code == "" {
|
|
155
|
+
result.Bytes = uint64(len(data))
|
|
156
|
+
}
|
|
157
|
+
if err := writeOperationPacketBound(control, readOnlyPacket{Binding: boot.Binding, Token: boot.Token, Result: &result, ChunkSequence: sequence}, MaxControlBytes); err != nil {
|
|
158
|
+
return err
|
|
159
|
+
}
|
|
160
|
+
if code != "" {
|
|
161
|
+
return code
|
|
162
|
+
}
|
|
163
|
+
if _, err := io.CopyN(output, bytes.NewReader(data), int64(lease.Bytes)); err != nil {
|
|
164
|
+
return err
|
|
165
|
+
}
|
|
166
|
+
if source.remaining == 0 {
|
|
167
|
+
return awaitReadOnlyFinish(control, boot.Token)
|
|
168
|
+
}
|
|
169
|
+
} else if _, err := io.CopyN(output, zeroReader{}, int64(lease.Bytes)); err != nil {
|
|
170
|
+
return err
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Unset until native share/home and object ACL obligations are proven on DSM.
|
|
176
|
+
var operationReadOnlyACL readOnlyACL
|
|
177
|
+
|
|
178
|
+
type zeroReader struct{}
|
|
179
|
+
|
|
180
|
+
func (zeroReader) Read(b []byte) (int, error) { clear(b); return len(b), nil }
|
|
181
|
+
|
|
182
|
+
// Keep the child and lifetime witness until the owner observes metadata/last
|
|
183
|
+
// relay completion. Exiting at the last pipe write would race S2 poll's Close.
|
|
184
|
+
func awaitReadOnlyFinish(control *net.UnixConn, token string) error {
|
|
185
|
+
var done operationReadOnlyFinish
|
|
186
|
+
if _, err := readOperationPacketBound(control, &done, MaxHealthBytes, BoundedTimeout); err != nil {
|
|
187
|
+
return err
|
|
188
|
+
}
|
|
189
|
+
if done.Token != token {
|
|
190
|
+
return errTrust
|
|
191
|
+
}
|
|
192
|
+
return nil
|
|
193
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"golang.org/x/sys/unix"
|
|
5
|
+
"os"
|
|
6
|
+
"slices"
|
|
7
|
+
"syscall"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// Runs on the pinned operation-child thread before any business filesystem I/O.
|
|
11
|
+
func dropOperationCredentials(parent int, boot operationBootstrap) error {
|
|
12
|
+
if err := unix.Prctl(unix.PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
|
|
13
|
+
return err
|
|
14
|
+
}
|
|
15
|
+
if err := unix.Prctl(unix.PR_SET_KEEPCAPS, 0, 0, 0, 0); err != nil {
|
|
16
|
+
return err
|
|
17
|
+
}
|
|
18
|
+
groups := make([]int, len(boot.Groups))
|
|
19
|
+
for n, g := range boot.Groups {
|
|
20
|
+
groups[n] = int(g)
|
|
21
|
+
}
|
|
22
|
+
if err := syscall.Setgroups(groups); err != nil {
|
|
23
|
+
return err
|
|
24
|
+
}
|
|
25
|
+
if err := syscall.Setresgid(int(boot.GID), int(boot.GID), int(boot.GID)); err != nil {
|
|
26
|
+
return err
|
|
27
|
+
}
|
|
28
|
+
if err := syscall.Setresuid(int(boot.UID), int(boot.UID), int(boot.UID)); err != nil {
|
|
29
|
+
return err
|
|
30
|
+
}
|
|
31
|
+
// Linux clears PDEATHSIG on credential changes. Re-arm while the creator
|
|
32
|
+
// thread is still pinned, then recheck parent on BOTH sides of prctl.
|
|
33
|
+
if err := armParentDeath(parent, setParentDeath, os.Getppid); err != nil {
|
|
34
|
+
return err
|
|
35
|
+
}
|
|
36
|
+
ru, eu, su := unix.Getresuid()
|
|
37
|
+
rg, eg, sg := unix.Getresgid()
|
|
38
|
+
current, err := syscall.Getgroups()
|
|
39
|
+
if err != nil || ru != int(boot.UID) || eu != ru || su != ru || rg != int(boot.GID) || eg != rg || sg != rg {
|
|
40
|
+
return errTrust
|
|
41
|
+
}
|
|
42
|
+
slices.Sort(current)
|
|
43
|
+
slices.Sort(groups)
|
|
44
|
+
if !slices.Equal(current, groups) {
|
|
45
|
+
return errTrust
|
|
46
|
+
}
|
|
47
|
+
var caps [2]unix.CapUserData
|
|
48
|
+
header := unix.CapUserHeader{Version: unix.LINUX_CAPABILITY_VERSION_3}
|
|
49
|
+
if err := unix.Capset(&header, &caps[0]); err != nil {
|
|
50
|
+
return err
|
|
51
|
+
}
|
|
52
|
+
if err := unix.Capget(&header, &caps[0]); err != nil || caps[0] != (unix.CapUserData{}) || caps[1] != (unix.CapUserData{}) {
|
|
53
|
+
return errTrust
|
|
54
|
+
}
|
|
55
|
+
return nil
|
|
56
|
+
}
|