@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,303 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"os"
|
|
7
|
+
"os/exec"
|
|
8
|
+
"slices"
|
|
9
|
+
"strings"
|
|
10
|
+
"syscall"
|
|
11
|
+
"testing"
|
|
12
|
+
|
|
13
|
+
"golang.org/x/sys/unix"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
func TestS1RKernelPermissionMatrix(t *testing.T) {
|
|
17
|
+
if os.Geteuid() != 0 {
|
|
18
|
+
t.Skip("disposable root VM only")
|
|
19
|
+
}
|
|
20
|
+
for _, c := range []struct {
|
|
21
|
+
name, scenario string
|
|
22
|
+
uid, gid uint32
|
|
23
|
+
groups []uint32
|
|
24
|
+
}{
|
|
25
|
+
{"alice-own", "alice/allow", s1rAlice, s1rAliceGID, []uint32{}},
|
|
26
|
+
{"bob-own", "bob/allow", s1rBob, s1rBobGID, []uint32{}},
|
|
27
|
+
{"alice-denied-bob", "bob/deny", s1rAlice, s1rAliceGID, []uint32{}},
|
|
28
|
+
{"bob-denied-alice", "alice/deny", s1rBob, s1rBobGID, []uint32{}},
|
|
29
|
+
{"supplementary-only", "supplementary/allow", s1rAlice, s1rAliceGID, []uint32{s1rExtra, s1rShared}},
|
|
30
|
+
{"supplementary-omitted", "supplementary/deny", s1rAlice, s1rAliceGID, []uint32{}},
|
|
31
|
+
{"primary-group-only", "supplementary/allow", s1rAlice, s1rShared, []uint32{}},
|
|
32
|
+
{"acl-named-user", "acl-allow/allow", s1rAlice, s1rAliceGID, []uint32{}},
|
|
33
|
+
{"acl-other-user", "acl-allow/deny", s1rBob, s1rBobGID, []uint32{}},
|
|
34
|
+
{"acl-directory-mask", "acl-mask/deny", s1rAlice, s1rAliceGID, []uint32{}},
|
|
35
|
+
{"acl-file-mask", "acl-file-mask/file-mask", s1rAlice, s1rAliceGID, []uint32{}},
|
|
36
|
+
{"acl-named-group", "acl-group/allow", s1rAlice, s1rAliceGID, []uint32{s1rShared}},
|
|
37
|
+
{"acl-named-group-omitted", "acl-group/deny", s1rAlice, s1rAliceGID, []uint32{}},
|
|
38
|
+
{"acl-group-mask-read-only", "acl-group-mask/read-only", s1rAlice, s1rAliceGID, []uint32{s1rShared}},
|
|
39
|
+
{"default-acl-writer", "inherit/allow", s1rAlice, s1rAliceGID, []uint32{}},
|
|
40
|
+
{"default-acl-reader", "inherit/read-only", s1rBob, s1rBobGID, []uint32{}},
|
|
41
|
+
{"readonly-directory", "readonly/read-only", s1rAlice, s1rAliceGID, []uint32{}},
|
|
42
|
+
} {
|
|
43
|
+
t.Run(c.name, func(t *testing.T) {
|
|
44
|
+
s1rRunActor(t, s1rActorSpec{UID: c.uid, GID: c.gid, Groups: c.groups, Root: s1rFixture(t), Scenario: c.scenario})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
func s1rAssertCredentials(t *testing.T, spec s1rActorSpec) {
|
|
50
|
+
t.Helper()
|
|
51
|
+
u, e, s := unix.Getresuid()
|
|
52
|
+
g, eg, sg := unix.Getresgid()
|
|
53
|
+
if u != int(spec.UID) || e != u || s != u || g != int(spec.GID) || eg != g || sg != g {
|
|
54
|
+
t.Fatalf("UID/GID triplets: %d/%d/%d %d/%d/%d", u, e, s, g, eg, sg)
|
|
55
|
+
}
|
|
56
|
+
groups, err := syscall.Getgroups()
|
|
57
|
+
s1rMust(t, err)
|
|
58
|
+
want := make([]int, len(spec.Groups))
|
|
59
|
+
for i, v := range spec.Groups {
|
|
60
|
+
want[i] = int(v)
|
|
61
|
+
}
|
|
62
|
+
slices.Sort(groups)
|
|
63
|
+
slices.Sort(want)
|
|
64
|
+
if !slices.Equal(groups, want) {
|
|
65
|
+
t.Fatalf("setgroups got %v want %v", groups, want)
|
|
66
|
+
}
|
|
67
|
+
header := unix.CapUserHeader{Version: unix.LINUX_CAPABILITY_VERSION_3}
|
|
68
|
+
var caps [2]unix.CapUserData
|
|
69
|
+
s1rMust(t, unix.Capget(&header, &caps[0]))
|
|
70
|
+
if caps != ([2]unix.CapUserData{}) {
|
|
71
|
+
t.Fatalf("retained capabilities: %+v", caps)
|
|
72
|
+
}
|
|
73
|
+
nnp, err := unix.PrctlRetInt(unix.PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0)
|
|
74
|
+
s1rMust(t, err)
|
|
75
|
+
if nnp != 1 {
|
|
76
|
+
t.Fatal("no_new_privs", nnp)
|
|
77
|
+
}
|
|
78
|
+
keep, err := unix.PrctlRetInt(unix.PR_GET_KEEPCAPS, 0, 0, 0, 0)
|
|
79
|
+
s1rMust(t, err)
|
|
80
|
+
if keep != 0 {
|
|
81
|
+
t.Fatal("keepcaps", keep)
|
|
82
|
+
}
|
|
83
|
+
for _, attempt := range []struct {
|
|
84
|
+
name string
|
|
85
|
+
run func() error
|
|
86
|
+
}{
|
|
87
|
+
{"setuid-root", func() error { return syscall.Setuid(0) }},
|
|
88
|
+
{"setresuid-root", func() error { return syscall.Setresuid(0, 0, 0) }},
|
|
89
|
+
{"setgid-root", func() error { return syscall.Setgid(0) }},
|
|
90
|
+
{"setresgid-root", func() error { return syscall.Setresgid(0, 0, 0) }},
|
|
91
|
+
{"setgroups-root", func() error { return syscall.Setgroups([]int{0}) }},
|
|
92
|
+
{"cap-dac-override", func() error {
|
|
93
|
+
c := [2]unix.CapUserData{{Effective: 2, Permitted: 2}}
|
|
94
|
+
return unix.Capset(&header, &c[0])
|
|
95
|
+
}},
|
|
96
|
+
} {
|
|
97
|
+
if err := attempt.run(); err != unix.EPERM {
|
|
98
|
+
t.Fatalf("privilege regain %s: %v", attempt.name, err)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
u, e, s = unix.Getresuid()
|
|
102
|
+
g, eg, sg = unix.Getresgid()
|
|
103
|
+
if u != int(spec.UID) || e != u || s != u || g != int(spec.GID) || eg != g || sg != g {
|
|
104
|
+
t.Fatal("regain changed credentials")
|
|
105
|
+
}
|
|
106
|
+
t.Logf("credentials UID=%d/%d/%d GID=%d/%d/%d groups=%v caps=0 NNP=1; six regain attempts=EPERM", u, e, s, g, eg, sg, groups)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
func s1rActorMatrix(t *testing.T, spec s1rActorSpec) {
|
|
110
|
+
parts := strings.Split(spec.Scenario, "/")
|
|
111
|
+
if parts[0] == "races" {
|
|
112
|
+
s1rActorRaces(t, spec, parts[1])
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
if parts[0] == "inherited" {
|
|
116
|
+
s1rCheckInherited(t, spec)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
root := spec.Root + "/" + parts[0]
|
|
120
|
+
mode := parts[1]
|
|
121
|
+
for _, op := range []string{"stat", "list", "read", "stream", "create", "write", "publish"} {
|
|
122
|
+
t.Run(op, func(t *testing.T) {
|
|
123
|
+
allow := mode == "allow" || (mode == "read-only" && slices.Contains([]string{"stat", "list", "read", "stream"}, op)) || (mode == "file-mask" && slices.Contains([]string{"list", "create", "write", "publish"}, op))
|
|
124
|
+
pin, code := pinReadOnlyRoot(root)
|
|
125
|
+
if code != "" {
|
|
126
|
+
if allow || code != ErrDenied {
|
|
127
|
+
t.Fatal("root search", code, "allow", allow)
|
|
128
|
+
}
|
|
129
|
+
t.Log("kernel denies root search")
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
defer pin.Close()
|
|
133
|
+
ctx := context.Background()
|
|
134
|
+
var result readOnlyResult
|
|
135
|
+
var data []byte
|
|
136
|
+
switch op {
|
|
137
|
+
case "stat", "list", "read":
|
|
138
|
+
work := readWork(pin, "file")
|
|
139
|
+
if op == "stat" {
|
|
140
|
+
work.Action = ActionStat
|
|
141
|
+
work.MaxBytes = 0
|
|
142
|
+
}
|
|
143
|
+
if op == "list" {
|
|
144
|
+
work.Action = ActionList
|
|
145
|
+
work.Segments = []string{}
|
|
146
|
+
work.MaxBytes = 0
|
|
147
|
+
work.Limit = 20
|
|
148
|
+
}
|
|
149
|
+
result, data = executeReadOnly(ctx, pin, work, fixtureReadOnlyACL{})
|
|
150
|
+
code = result.Code
|
|
151
|
+
if allow {
|
|
152
|
+
if op == "read" && string(data) != "canary:"+parts[0] {
|
|
153
|
+
t.Fatal("read canary", string(data))
|
|
154
|
+
}
|
|
155
|
+
if op == "stat" && result.Entry == nil {
|
|
156
|
+
t.Fatal("missing stat")
|
|
157
|
+
}
|
|
158
|
+
if op == "list" {
|
|
159
|
+
found := false
|
|
160
|
+
if result.List != nil {
|
|
161
|
+
for _, e := range result.List.Entries {
|
|
162
|
+
if e.Name == "file" {
|
|
163
|
+
found = true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if found != (mode != "file-mask") {
|
|
168
|
+
t.Fatal("list filtered file", result)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} else if len(data) > 0 || result.Entry != nil || result.List != nil {
|
|
172
|
+
t.Fatal("denial leaked bytes/metadata", result)
|
|
173
|
+
}
|
|
174
|
+
case "stream":
|
|
175
|
+
work := readWork(pin, "file")
|
|
176
|
+
work.Action = ActionReadStream
|
|
177
|
+
x, r := openActorReadTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
178
|
+
code = r.Code
|
|
179
|
+
if x != nil {
|
|
180
|
+
defer x.Close()
|
|
181
|
+
for x.remaining > 0 {
|
|
182
|
+
n := uint32(3)
|
|
183
|
+
if uint64(n) > x.remaining {
|
|
184
|
+
n = uint32(x.remaining)
|
|
185
|
+
}
|
|
186
|
+
b, c := x.ReadChunk(ctx, n)
|
|
187
|
+
if c != "" {
|
|
188
|
+
code = c
|
|
189
|
+
break
|
|
190
|
+
}
|
|
191
|
+
data = append(data, b...)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if allow && string(data) != "canary:"+parts[0] {
|
|
195
|
+
t.Fatal("stream canary", string(data))
|
|
196
|
+
}
|
|
197
|
+
if !allow && (x != nil || len(data) > 0 || r.Bytes != 0) {
|
|
198
|
+
t.Fatal("denied stream", r)
|
|
199
|
+
}
|
|
200
|
+
default:
|
|
201
|
+
staged := op == "publish"
|
|
202
|
+
work := writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"new-" + op}, MaxBytes: 3}
|
|
203
|
+
if staged {
|
|
204
|
+
work.Action = ActionWriteStream
|
|
205
|
+
work.Staged = true
|
|
206
|
+
}
|
|
207
|
+
x, c := openActorWriteTransfer(ctx, pin, work, fixtureReadOnlyACL{})
|
|
208
|
+
code = c
|
|
209
|
+
if x != nil {
|
|
210
|
+
defer x.Close()
|
|
211
|
+
}
|
|
212
|
+
if code == "" {
|
|
213
|
+
if op == "create" {
|
|
214
|
+
if !x.Receipt().Created || x.Receipt().BytesWritten != 0 {
|
|
215
|
+
t.Fatal(x.Receipt())
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
r, c := x.WriteChunk(ctx, []byte("abc"))
|
|
219
|
+
code = c
|
|
220
|
+
if c == "" {
|
|
221
|
+
r, code = x.Commit(ctx)
|
|
222
|
+
}
|
|
223
|
+
if allow && (!r.Committed || !r.Published || r.BytesWritten != 3) {
|
|
224
|
+
t.Fatal("write receipt", r, code)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if !allow {
|
|
229
|
+
if _, err := os.Stat(root + "/new-" + op); err == nil {
|
|
230
|
+
t.Fatal("denied write created destination")
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if allow && code != "" || !allow && code != ErrDenied {
|
|
235
|
+
t.Fatalf("%s mode=%s expected allow=%v got=%s", op, mode, allow, code)
|
|
236
|
+
}
|
|
237
|
+
t.Logf("%s allow=%v code=%q", op, allow, code)
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
func s1rCheckInherited(t *testing.T, spec s1rActorSpec) {
|
|
243
|
+
root := spec.Root + "/inherit"
|
|
244
|
+
pin, code := pinReadOnlyRoot(root)
|
|
245
|
+
if code != "" {
|
|
246
|
+
t.Fatal(code)
|
|
247
|
+
}
|
|
248
|
+
defer pin.Close()
|
|
249
|
+
for _, name := range []string{"new-create", "new-write", "new-publish"} {
|
|
250
|
+
result, data := executeReadOnly(context.Background(), pin, readWork(pin, name), fixtureReadOnlyACL{})
|
|
251
|
+
want := "abc"
|
|
252
|
+
if name == "new-create" {
|
|
253
|
+
want = ""
|
|
254
|
+
}
|
|
255
|
+
if result.Code != "" || string(data) != want {
|
|
256
|
+
t.Fatal("inherited read", name, result, string(data))
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if _, code := openActorWriteTransfer(context.Background(), pin, writeWork{RootPath: root, Action: ActionCreate, Segments: []string{"bob-must-not-create"}, MaxBytes: 1}, fixtureReadOnlyACL{}); code != ErrDenied {
|
|
260
|
+
t.Fatal("inherited directory write", code)
|
|
261
|
+
}
|
|
262
|
+
t.Log("Bob reads Alice's created/written/published files via inherited ACL; cannot create")
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
func TestS1RDefaultACLInheritance(t *testing.T) {
|
|
266
|
+
if os.Geteuid() != 0 {
|
|
267
|
+
t.Skip("disposable root VM only")
|
|
268
|
+
}
|
|
269
|
+
root := s1rFixture(t)
|
|
270
|
+
s1rRunActor(t, s1rActorSpec{UID: s1rAlice, GID: s1rAliceGID, Groups: []uint32{}, Root: root, Scenario: "inherit/allow"})
|
|
271
|
+
for _, name := range []string{"new-create", "new-write", "new-publish"} {
|
|
272
|
+
b, err := exec.Command("/usr/bin/getfacl", "-cpn", root+"/inherit/"+name).CombinedOutput()
|
|
273
|
+
s1rMust(t, err)
|
|
274
|
+
if !strings.Contains(string(b), "user:23002:r-x") || !strings.Contains(string(b), "mask::rw-") {
|
|
275
|
+
t.Fatalf("missing inherited ACL: %s\n%s", name, b)
|
|
276
|
+
}
|
|
277
|
+
t.Logf("%s inherited ACL:\n%s", name, b)
|
|
278
|
+
}
|
|
279
|
+
s1rRunActor(t, s1rActorSpec{UID: s1rBob, GID: s1rBobGID, Groups: []uint32{}, Root: root, Scenario: "inherited/check"})
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
func TestS1RSymlinkAndRenameRaces(t *testing.T) {
|
|
283
|
+
if os.Geteuid() != 0 {
|
|
284
|
+
t.Skip("disposable root VM only")
|
|
285
|
+
}
|
|
286
|
+
for _, kind := range []string{"symlink", "stat-rename", "list-rename", "read-rename", "stream-rename", "create-rename", "publish-rename", "publish-symlink", "publish-permission-loss", "open-fd-write-permission-loss"} {
|
|
287
|
+
t.Run(kind, func(t *testing.T) {
|
|
288
|
+
s1rRunActor(t, s1rActorSpec{UID: s1rAlice, GID: s1rAliceGID, Groups: []uint32{}, Root: s1rFixture(t), Scenario: "races/" + kind})
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
func TestS1RActorProcess(t *testing.T) {
|
|
294
|
+
raw := os.Getenv("S1R_ACTOR_SPEC")
|
|
295
|
+
if raw == "" {
|
|
296
|
+
t.Skip("isolated actor subprocess only")
|
|
297
|
+
}
|
|
298
|
+
var spec s1rActorSpec
|
|
299
|
+
s1rMust(t, json.Unmarshal([]byte(raw), &spec))
|
|
300
|
+
s1rDropActor(t, spec)
|
|
301
|
+
s1rAssertCredentials(t, spec)
|
|
302
|
+
s1rActorMatrix(t, spec)
|
|
303
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
// Disposable Linux VM fixtures only. No account lookup or ACL adapter is
|
|
4
|
+
// installed into the shipped helper, and no business FD is opened by the parent.
|
|
5
|
+
import (
|
|
6
|
+
"bytes"
|
|
7
|
+
"context"
|
|
8
|
+
"encoding/json"
|
|
9
|
+
"fmt"
|
|
10
|
+
"os"
|
|
11
|
+
"os/exec"
|
|
12
|
+
"runtime"
|
|
13
|
+
"strings"
|
|
14
|
+
"syscall"
|
|
15
|
+
"testing"
|
|
16
|
+
"time"
|
|
17
|
+
|
|
18
|
+
"golang.org/x/sys/unix"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const (
|
|
22
|
+
s1rAlice = 23001
|
|
23
|
+
s1rBob = 23002
|
|
24
|
+
s1rAliceGID = 24001
|
|
25
|
+
s1rBobGID = 24002
|
|
26
|
+
s1rShared = 24003
|
|
27
|
+
s1rExtra = 24004
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
func s1rMust(t *testing.T, err error) {
|
|
31
|
+
t.Helper()
|
|
32
|
+
if err != nil {
|
|
33
|
+
t.Fatal(err)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func s1rACL(t *testing.T, path, acl string) {
|
|
38
|
+
t.Helper()
|
|
39
|
+
b, err := exec.Command("/usr/bin/setfacl", "-m", acl, path).CombinedOutput()
|
|
40
|
+
if err != nil {
|
|
41
|
+
t.Fatalf("setfacl %s: %v %s", path, err, b)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func s1rFixture(t *testing.T) string {
|
|
46
|
+
t.Helper()
|
|
47
|
+
root, err := os.MkdirTemp("/tmp", "s1r-vm-")
|
|
48
|
+
s1rMust(t, err)
|
|
49
|
+
t.Cleanup(func() { s1rMust(t, os.RemoveAll(root)) })
|
|
50
|
+
s1rMust(t, os.Chmod(root, 0755))
|
|
51
|
+
for _, name := range []string{"alice", "bob", "supplementary", "acl-allow", "acl-mask", "acl-file-mask", "acl-group", "acl-group-mask", "inherit", "readonly", "race"} {
|
|
52
|
+
dir := root + "/" + name
|
|
53
|
+
s1rMust(t, os.Mkdir(dir, 0700))
|
|
54
|
+
s1rMust(t, os.WriteFile(dir+"/file", []byte("canary:"+name), 0600))
|
|
55
|
+
}
|
|
56
|
+
for _, p := range []struct {
|
|
57
|
+
name string
|
|
58
|
+
uid, gid int
|
|
59
|
+
}{{"alice", s1rAlice, s1rAliceGID}, {"bob", s1rBob, s1rBobGID}, {"race", s1rAlice, s1rAliceGID}} {
|
|
60
|
+
for _, path := range []string{root + "/" + p.name, root + "/" + p.name + "/file"} {
|
|
61
|
+
s1rMust(t, os.Chown(path, p.uid, p.gid))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for _, path := range []string{root + "/supplementary", root + "/supplementary/file"} {
|
|
65
|
+
s1rMust(t, os.Chown(path, 0, s1rShared))
|
|
66
|
+
}
|
|
67
|
+
s1rMust(t, unix.Chmod(root+"/supplementary", 02770))
|
|
68
|
+
s1rMust(t, os.Chmod(root+"/supplementary/file", 0660))
|
|
69
|
+
for _, name := range []string{"acl-allow", "acl-file-mask", "inherit"} {
|
|
70
|
+
s1rACL(t, root+"/"+name, fmt.Sprintf("u:%d:rwx,m::rwx", s1rAlice))
|
|
71
|
+
s1rACL(t, root+"/"+name+"/file", fmt.Sprintf("u:%d:rw-,m::rw-", s1rAlice))
|
|
72
|
+
}
|
|
73
|
+
s1rACL(t, root+"/acl-mask", fmt.Sprintf("u:%d:rwx,m::---", s1rAlice))
|
|
74
|
+
s1rACL(t, root+"/acl-mask/file", fmt.Sprintf("u:%d:rw-,m::---", s1rAlice))
|
|
75
|
+
s1rACL(t, root+"/acl-file-mask/file", "m::---")
|
|
76
|
+
for _, name := range []string{"acl-group", "acl-group-mask"} {
|
|
77
|
+
s1rACL(t, root+"/"+name, fmt.Sprintf("g:%d:rwx,m::rwx", s1rShared))
|
|
78
|
+
s1rACL(t, root+"/"+name+"/file", fmt.Sprintf("g:%d:rw-,m::rw-", s1rShared))
|
|
79
|
+
}
|
|
80
|
+
s1rACL(t, root+"/acl-group-mask", "m::r-x")
|
|
81
|
+
s1rACL(t, root+"/acl-group-mask/file", "m::r--")
|
|
82
|
+
s1rACL(t, root+"/inherit", fmt.Sprintf("u:%d:r-x,d:u::rwx,d:u:%d:rwx,d:u:%d:r-x,d:g::---,d:m::rwx,d:o::---", s1rBob, s1rAlice, s1rBob))
|
|
83
|
+
s1rACL(t, root+"/inherit/file", fmt.Sprintf("u:%d:r--,m::rw-", s1rBob))
|
|
84
|
+
s1rMust(t, os.Chmod(root+"/readonly", 0555))
|
|
85
|
+
s1rMust(t, os.Chmod(root+"/readonly/file", 0444))
|
|
86
|
+
return root
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type s1rActorSpec struct {
|
|
90
|
+
UID, GID uint32
|
|
91
|
+
Groups []uint32
|
|
92
|
+
Root, Scenario string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Run a fresh test process as root, invoke the REAL permanent drop routine, and
|
|
96
|
+
// proxy ONLY mount metadata using the production packet/FD routines. The parent
|
|
97
|
+
// pins the child's proc directory before permitting its credential transition.
|
|
98
|
+
func s1rRunActor(t *testing.T, spec s1rActorSpec) {
|
|
99
|
+
t.Helper()
|
|
100
|
+
pair, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET|syscall.SOCK_CLOEXEC, 0)
|
|
101
|
+
s1rMust(t, err)
|
|
102
|
+
left := os.NewFile(uintptr(pair[0]), "s1r-parent")
|
|
103
|
+
right := os.NewFile(uintptr(pair[1]), "s1r-child")
|
|
104
|
+
defer left.Close()
|
|
105
|
+
defer right.Close()
|
|
106
|
+
control, err := operationSocket(left)
|
|
107
|
+
s1rMust(t, err)
|
|
108
|
+
defer control.Close()
|
|
109
|
+
s1rMust(t, enableCredentials(control))
|
|
110
|
+
exe, err := os.Executable()
|
|
111
|
+
s1rMust(t, err)
|
|
112
|
+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
113
|
+
defer cancel()
|
|
114
|
+
cmd := exec.CommandContext(ctx, exe, "-test.run=^TestS1RActorProcess$", "-test.v")
|
|
115
|
+
b, err := json.Marshal(spec)
|
|
116
|
+
s1rMust(t, err)
|
|
117
|
+
cmd.Env = append(os.Environ(), "S1R_ACTOR_SPEC="+string(b))
|
|
118
|
+
cmd.ExtraFiles = []*os.File{right}
|
|
119
|
+
// Deliberately inherit unrelated/root/supplementary groups. The production
|
|
120
|
+
// Setgroups call must replace these, including when the requested set is empty.
|
|
121
|
+
cmd.SysProcAttr = &syscall.SysProcAttr{Credential: &syscall.Credential{Uid: 0, Gid: 0, Groups: []uint32{0, s1rShared, 24005}}}
|
|
122
|
+
var out bytes.Buffer
|
|
123
|
+
cmd.Stdout = &out
|
|
124
|
+
cmd.Stderr = &out
|
|
125
|
+
s1rMust(t, cmd.Start())
|
|
126
|
+
defer func() {
|
|
127
|
+
if cmd.ProcessState == nil {
|
|
128
|
+
cmd.Process.Kill()
|
|
129
|
+
cmd.Wait()
|
|
130
|
+
}
|
|
131
|
+
}()
|
|
132
|
+
info, err := openOperationFDInfo(cmd.Process.Pid)
|
|
133
|
+
s1rMust(t, err)
|
|
134
|
+
defer info.Close()
|
|
135
|
+
s1rMust(t, writeOperationPacket(control, true))
|
|
136
|
+
done := make(chan error, 1)
|
|
137
|
+
go func() {
|
|
138
|
+
var sequence uint64
|
|
139
|
+
for {
|
|
140
|
+
var packet readOnlyPacket
|
|
141
|
+
cred, err := readOperationPacketBound(control, &packet, MaxControlBytes, 30*time.Second)
|
|
142
|
+
if err != nil {
|
|
143
|
+
done <- nil
|
|
144
|
+
return
|
|
145
|
+
} // process exit closes the private socket
|
|
146
|
+
if cred == nil || int(cred.Pid) != cmd.Process.Pid || cred.Uid != spec.UID || cred.Gid != spec.GID || packet.Token != strings.Repeat("a", 64) || packet.MountFD == nil || packet.MountSequence != sequence+1 {
|
|
147
|
+
done <- fmt.Errorf("invalid actor mount query")
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
sequence++
|
|
151
|
+
id, code := operationFDInfoMount(info, *packet.MountFD)
|
|
152
|
+
if err := writeOperationPacket(control, readOnlyMountReply{Token: packet.Token, Sequence: sequence, Mount: id, Code: code}); err != nil {
|
|
153
|
+
done <- err
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}()
|
|
158
|
+
err = cmd.Wait()
|
|
159
|
+
control.Close()
|
|
160
|
+
proxyErr := <-done
|
|
161
|
+
if err != nil || proxyErr != nil {
|
|
162
|
+
t.Fatalf("actor %s: %v proxy=%v\n%s", spec.Scenario, err, proxyErr, out.String())
|
|
163
|
+
}
|
|
164
|
+
t.Log(out.String())
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func s1rDropActor(t *testing.T, spec s1rActorSpec) {
|
|
168
|
+
t.Helper()
|
|
169
|
+
runtime.LockOSThread() // like operationChildLinux; subprocess exits when finished
|
|
170
|
+
f := os.NewFile(3, "s1r-control")
|
|
171
|
+
defer f.Close()
|
|
172
|
+
control, err := operationSocket(f)
|
|
173
|
+
s1rMust(t, err)
|
|
174
|
+
t.Cleanup(func() { control.Close() })
|
|
175
|
+
var ready bool
|
|
176
|
+
_, err = readOperationPacketBound(control, &ready, MaxHealthBytes, 5*time.Second)
|
|
177
|
+
s1rMust(t, err)
|
|
178
|
+
if !ready {
|
|
179
|
+
t.Fatal("parent did not pin proc witness")
|
|
180
|
+
}
|
|
181
|
+
boot := operationBootstrap{UID: spec.UID, GID: spec.GID, Groups: spec.Groups, Token: strings.Repeat("a", 64)}
|
|
182
|
+
s1rMust(t, dropOperationCredentials(os.Getppid(), boot))
|
|
183
|
+
operationMountIDFallback = operationMountIDProxy(control, boot)
|
|
184
|
+
}
|