@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,121 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"fmt"
|
|
7
|
+
"os"
|
|
8
|
+
"os/exec"
|
|
9
|
+
"strconv"
|
|
10
|
+
"strings"
|
|
11
|
+
"syscall"
|
|
12
|
+
"testing"
|
|
13
|
+
"time"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
// The NIC-free VM points this at the actual unpacked, generated arm64 SPK CGI.
|
|
17
|
+
// The VM's DSM authenticate.cgi oracle is a fixture, never a shipped adapter.
|
|
18
|
+
func TestS8FinalCGIArtifactRefusal(t *testing.T) {
|
|
19
|
+
binary := os.Getenv("M2_S8_CGI_ARTIFACT")
|
|
20
|
+
if binary == "" {
|
|
21
|
+
t.Skip("requires final generated SPK in disposable Linux VM")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
helperBinary := os.Getenv("M2_S8_HELPER_ARTIFACT")
|
|
25
|
+
if helperBinary != "" {
|
|
26
|
+
run := func(action string) {
|
|
27
|
+
t.Helper()
|
|
28
|
+
if b, err := exec.Command(helperBinary, action).CombinedOutput(); err != nil {
|
|
29
|
+
t.Fatalf("%s: %s %v", action, b, err)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
state := func(want string) {
|
|
33
|
+
t.Helper()
|
|
34
|
+
for n := 0; n < 100; n++ {
|
|
35
|
+
b, err := exec.Command(helperBinary, "diagnose").Output()
|
|
36
|
+
var out map[string]any
|
|
37
|
+
json.Unmarshal(b, &out)
|
|
38
|
+
if err == nil && out["state"] == want {
|
|
39
|
+
t.Log("final generated helper state", want)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
time.Sleep(20 * time.Millisecond)
|
|
43
|
+
}
|
|
44
|
+
t.Fatal("helper state did not become", want)
|
|
45
|
+
}
|
|
46
|
+
run("enable")
|
|
47
|
+
state("ready")
|
|
48
|
+
t.Cleanup(func() { exec.Command(helperBinary, "disable").Run() })
|
|
49
|
+
hook := os.Getenv("M2_S8_PREUPGRADE_HOOK")
|
|
50
|
+
if hook != "" {
|
|
51
|
+
if exec.Command("/bin/sh", hook).Run() == nil {
|
|
52
|
+
t.Fatal("generated preupgrade admitted a ready helper")
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
defer func() {
|
|
56
|
+
run("teardown")
|
|
57
|
+
state("stopped")
|
|
58
|
+
if hook != "" {
|
|
59
|
+
if b, err := exec.Command("/bin/sh", hook).CombinedOutput(); err != nil {
|
|
60
|
+
t.Fatal("generated preupgrade after teardown", string(b), err)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
run("recover")
|
|
64
|
+
state("ready")
|
|
65
|
+
run("disable")
|
|
66
|
+
state("not-enabled")
|
|
67
|
+
if exec.Command(helperBinary, "recover").Run() == nil {
|
|
68
|
+
t.Fatal("disabled helper recovered without approval")
|
|
69
|
+
}
|
|
70
|
+
}()
|
|
71
|
+
}
|
|
72
|
+
methods := []string{"nas.discovery", "nas.grants.prepare", "nas.grants.confirm", "nas.grants.list", "nas.files.stat", "nas.files.list", "nas.files.read", "nas.files.read-stream", "nas.files.create", "nas.files.write-stream", "nas.files.publish", "nas.unknown", "nas.files.read.binary"}
|
|
73
|
+
for _, user := range []string{"normal1", "normal2", "admin", "", "expired"} {
|
|
74
|
+
for _, method := range methods {
|
|
75
|
+
params := `{"user":"admin","path":"/volume1/secret"}`
|
|
76
|
+
if method == "nas.files.read.binary" {
|
|
77
|
+
params = sampleParams[method]
|
|
78
|
+
}
|
|
79
|
+
body := fmt.Sprintf(`{"method":%q,"params":%s}`, method, params)
|
|
80
|
+
cmd := exec.Command(binary)
|
|
81
|
+
if uidText := os.Getenv("M2_S8_CGI_PACKAGE_UID"); uidText != "" {
|
|
82
|
+
uid, err := strconv.ParseUint(uidText, 10, 32)
|
|
83
|
+
if err != nil {
|
|
84
|
+
t.Fatal(err)
|
|
85
|
+
}
|
|
86
|
+
cmd.SysProcAttr = &syscall.SysProcAttr{Credential: &syscall.Credential{Uid: uint32(uid), Gid: uint32(uid)}}
|
|
87
|
+
}
|
|
88
|
+
cmd.Env = []string{"GATEWAY_INTERFACE=CGI/1.1", "REQUEST_METHOD=POST", "SERVER_PROTOCOL=HTTP/1.1", "SERVER_NAME=localhost", "SERVER_PORT=80", "SCRIPT_NAME=/api.cgi", "CONTENT_TYPE=application/json", fmt.Sprintf("CONTENT_LENGTH=%d", len(body)), "REMOTE_ADDR=127.0.0.1"}
|
|
89
|
+
if user != "" {
|
|
90
|
+
cmd.Env = append(cmd.Env, "HTTP_COOKIE=fixture="+user)
|
|
91
|
+
}
|
|
92
|
+
cmd.Stdin = strings.NewReader(body)
|
|
93
|
+
b, err := cmd.Output()
|
|
94
|
+
if err != nil {
|
|
95
|
+
t.Fatal(method, err)
|
|
96
|
+
}
|
|
97
|
+
parts := bytes.SplitN(b, []byte("\r\n\r\n"), 2)
|
|
98
|
+
if len(parts) != 2 {
|
|
99
|
+
t.Fatal("not CGI", string(b))
|
|
100
|
+
}
|
|
101
|
+
var result map[string]any
|
|
102
|
+
if err = json.Unmarshal(parts[1], &result); err != nil {
|
|
103
|
+
t.Fatal(err, string(b))
|
|
104
|
+
}
|
|
105
|
+
want := "unknown_method"
|
|
106
|
+
if method == "nas.files.read.binary" {
|
|
107
|
+
want = "unsupported"
|
|
108
|
+
}
|
|
109
|
+
if user == "" || user == "expired" {
|
|
110
|
+
want = "session_required"
|
|
111
|
+
}
|
|
112
|
+
e, ok := result["error"].(map[string]any)
|
|
113
|
+
if !ok || e["code"] != want || result["success"] != false || result["data"] != nil {
|
|
114
|
+
t.Fatalf("%s %s: %s", user, method, parts[1])
|
|
115
|
+
}
|
|
116
|
+
if bytes.Contains(b, []byte("volume1")) || bytes.Contains(b, []byte("fixture=")) {
|
|
117
|
+
t.Fatal("metadata leaked")
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package app
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"os"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
|
|
9
|
+
"dsmapp/internal/helper"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// These are unavailable wire methods, not public grant/file routes. CGI names
|
|
13
|
+
// are never used as S1 actors. Test both administrators and ordinary sessions.
|
|
14
|
+
func TestS8NASWireRefusalHasNoDataEffects(t *testing.T) {
|
|
15
|
+
methods := []string{"nas.discovery", "nas.grants.prepare", "nas.grants.confirm", "nas.grants.list", "nas.files.stat", "nas.files.list", "nas.files.read", "nas.files.read-stream", "nas.files.create", "nas.files.write-stream", "nas.files.publish", "nas.future-method"}
|
|
16
|
+
for _, auth := range []stubAuth{alice, bob, nobody} {
|
|
17
|
+
cfg := testConfig(t)
|
|
18
|
+
cfg.HelperInventory = helper.Inventory{Package: cfg.PackageID, Version: cfg.Version, Protocol: 2, PayloadDigest: strings.Repeat("a", 64), RegistryDigest: strings.Repeat("b", 64)}
|
|
19
|
+
for _, method := range methods {
|
|
20
|
+
code, out := call(t, cfg, auth, method, `{"user":"admin","path":"/volume1/private","nativeProof":true}`)
|
|
21
|
+
want := "unknown_method"
|
|
22
|
+
if auth.err != nil {
|
|
23
|
+
want = "session_required"
|
|
24
|
+
}
|
|
25
|
+
if code != want || out["success"] != false || out["data"] != nil {
|
|
26
|
+
t.Fatalf("%s: %s %v", method, code, out)
|
|
27
|
+
}
|
|
28
|
+
b, _ := json.Marshal(out)
|
|
29
|
+
if strings.Contains(string(b), "volume1") || strings.Contains(string(b), "nativeProof") {
|
|
30
|
+
t.Fatal("request metadata leaked", string(b))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
code, out := call(t, cfg, auth, "nas.files.read.binary", sampleParams["nas.files.read.binary"])
|
|
34
|
+
want := "unsupported"
|
|
35
|
+
if auth.err != nil {
|
|
36
|
+
want = "session_required"
|
|
37
|
+
}
|
|
38
|
+
if code != want || out["data"] != nil {
|
|
39
|
+
t.Fatal(code, out)
|
|
40
|
+
}
|
|
41
|
+
entries, err := os.ReadDir(cfg.DataDir)
|
|
42
|
+
if err != nil || len(entries) != 0 {
|
|
43
|
+
t.Fatal("NAS refusal changed package data", entries, err)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -9,6 +9,7 @@ import (
|
|
|
9
9
|
"encoding/json"
|
|
10
10
|
"errors"
|
|
11
11
|
"io/fs"
|
|
12
|
+
"net/http"
|
|
12
13
|
"os"
|
|
13
14
|
"path/filepath"
|
|
14
15
|
"runtime"
|
|
@@ -24,6 +25,8 @@ type Config struct {
|
|
|
24
25
|
PackageID string
|
|
25
26
|
Version string
|
|
26
27
|
HelperInventory helper.Inventory
|
|
28
|
+
// Staged trusted adapter. Nil refuses; no production data transport is installed.
|
|
29
|
+
NASBinaryRead api.BinaryReadHandler
|
|
27
30
|
// DataDir is the package's persistent, package-owned directory
|
|
28
31
|
// (/var/packages/<package>/var). It survives upgrades.
|
|
29
32
|
DataDir string
|
|
@@ -32,6 +35,7 @@ type Config struct {
|
|
|
32
35
|
func Routes(cfg Config) []api.Route {
|
|
33
36
|
routes := []api.Route{
|
|
34
37
|
api.User("integration.status", cfg.integrationStatus),
|
|
38
|
+
api.BoundedRead(cfg.binaryRead),
|
|
35
39
|
api.User("app.status", cfg.status),
|
|
36
40
|
api.User("greeting.get", cfg.getGreeting),
|
|
37
41
|
api.Admin("greeting.set", cfg.setGreeting),
|
|
@@ -125,3 +129,10 @@ func writeFileAtomic(path string, data []byte) error {
|
|
|
125
129
|
}
|
|
126
130
|
return os.Rename(tmp.Name(), path)
|
|
127
131
|
}
|
|
132
|
+
|
|
133
|
+
func (cfg Config) binaryRead(ctx context.Context, c api.Caller, r *http.Request, p json.RawMessage) (api.BinaryRead, error) {
|
|
134
|
+
if cfg.NASBinaryRead == nil {
|
|
135
|
+
return api.BinaryRead{}, &api.Error{Code: "unsupported", Message: "NAS binary read is unavailable"}
|
|
136
|
+
}
|
|
137
|
+
return cfg.NASBinaryRead(ctx, c, r, p)
|
|
138
|
+
}
|
|
@@ -57,10 +57,11 @@ var (
|
|
|
57
57
|
// sampleParams holds valid params for every route, so the denial test below
|
|
58
58
|
// proves the refusal came from the policy and not from bad input.
|
|
59
59
|
var sampleParams = map[string]string{
|
|
60
|
-
"integration.status":
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"greeting.
|
|
60
|
+
"integration.status": `{}`,
|
|
61
|
+
"nas.files.read.binary": `{"operationId":"` + strings.Repeat("a", 64) + `","epoch":"` + strings.Repeat("b", 64) + `","token":"` + strings.Repeat("c", 64) + `"}`,
|
|
62
|
+
"app.status": `{}`,
|
|
63
|
+
"greeting.get": `{}`,
|
|
64
|
+
"greeting.set": `{"text":"Hi"}`,
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
func TestIntegrationStatusIsReadableByOrdinaryUsers(t *testing.T) {
|
|
@@ -117,7 +118,11 @@ func TestEveryAdminRouteRefusesOrdinaryUsersAndChangesNothing(t *testing.T) {
|
|
|
117
118
|
func TestEveryRouteSucceedsForAnAdmin(t *testing.T) {
|
|
118
119
|
for _, r := range Routes(testConfig(t)) {
|
|
119
120
|
code, out := call(t, testConfig(t), alice, r.Method(), sampleParams[r.Method()])
|
|
120
|
-
|
|
121
|
+
want := ""
|
|
122
|
+
if r.Method() == "nas.files.read.binary" {
|
|
123
|
+
want = "unsupported"
|
|
124
|
+
}
|
|
125
|
+
if code != want {
|
|
121
126
|
t.Errorf("%s: %q %v", r.Method(), code, out)
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
package dsmprobe
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"context"
|
|
6
|
+
"crypto/sha256"
|
|
7
|
+
"debug/elf"
|
|
8
|
+
"encoding/hex"
|
|
9
|
+
"encoding/json"
|
|
10
|
+
"errors"
|
|
11
|
+
"fmt"
|
|
12
|
+
"io"
|
|
13
|
+
"os"
|
|
14
|
+
"path/filepath"
|
|
15
|
+
"runtime"
|
|
16
|
+
"slices"
|
|
17
|
+
"strconv"
|
|
18
|
+
"strings"
|
|
19
|
+
"unsafe"
|
|
20
|
+
|
|
21
|
+
"golang.org/x/sys/unix"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// root is test-only filesystem injection. The executable exposes no path/root
|
|
25
|
+
// option or environment override. It reads no shadow, native DB, or data file.
|
|
26
|
+
type collector struct{ root string }
|
|
27
|
+
|
|
28
|
+
func (c *collector) path(p string) string {
|
|
29
|
+
if c.root != "" {
|
|
30
|
+
return c.root + p
|
|
31
|
+
}
|
|
32
|
+
return p
|
|
33
|
+
}
|
|
34
|
+
func openObserved(path string, flags int) (*os.File, error) {
|
|
35
|
+
if !filepath.IsAbs(path) || filepath.Clean(path) != path {
|
|
36
|
+
return nil, ErrInvalid
|
|
37
|
+
}
|
|
38
|
+
fd, e := unix.Open("/", unix.O_PATH|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
|
|
39
|
+
if e != nil {
|
|
40
|
+
return nil, e
|
|
41
|
+
}
|
|
42
|
+
parts := strings.Split(path[1:], "/")
|
|
43
|
+
for i, p := range parts {
|
|
44
|
+
f := unix.O_PATH | unix.O_DIRECTORY
|
|
45
|
+
if i == len(parts)-1 {
|
|
46
|
+
f = flags
|
|
47
|
+
}
|
|
48
|
+
next, e := unix.Openat(fd, p, f|unix.O_NOFOLLOW|unix.O_CLOEXEC|unix.O_NONBLOCK, 0)
|
|
49
|
+
unix.Close(fd)
|
|
50
|
+
if e != nil {
|
|
51
|
+
return nil, e
|
|
52
|
+
}
|
|
53
|
+
fd = next
|
|
54
|
+
}
|
|
55
|
+
return os.NewFile(uintptr(fd), "observation"), nil
|
|
56
|
+
}
|
|
57
|
+
func (c *collector) read(ctx context.Context, path string, maximum int) ([]byte, error) {
|
|
58
|
+
if ctx.Err() != nil {
|
|
59
|
+
return nil, ctx.Err()
|
|
60
|
+
}
|
|
61
|
+
f, e := openObserved(c.path(path), unix.O_RDONLY)
|
|
62
|
+
if e != nil {
|
|
63
|
+
return nil, e
|
|
64
|
+
}
|
|
65
|
+
defer f.Close()
|
|
66
|
+
var st unix.Stat_t
|
|
67
|
+
if unix.Fstat(int(f.Fd()), &st) != nil || st.Mode&unix.S_IFMT != unix.S_IFREG || st.Size > int64(maximum) {
|
|
68
|
+
return nil, ErrInvalid
|
|
69
|
+
}
|
|
70
|
+
out, e := io.ReadAll(io.LimitReader(f, int64(maximum+1)))
|
|
71
|
+
if len(out) > maximum {
|
|
72
|
+
return nil, ErrInvalid
|
|
73
|
+
}
|
|
74
|
+
if ctx.Err() != nil {
|
|
75
|
+
return nil, ctx.Err()
|
|
76
|
+
}
|
|
77
|
+
return out, e
|
|
78
|
+
}
|
|
79
|
+
func hash(b []byte) string { h := sha256.Sum256(b); return hex.EncodeToString(h[:]) }
|
|
80
|
+
func version(b []byte) string {
|
|
81
|
+
values := map[string]string{}
|
|
82
|
+
for _, line := range strings.Split(string(b), "\n") {
|
|
83
|
+
k, v, ok := strings.Cut(line, "=")
|
|
84
|
+
if !ok {
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
87
|
+
if k != "productversion" && k != "buildnumber" {
|
|
88
|
+
continue
|
|
89
|
+
}
|
|
90
|
+
if _, ok := values[k]; ok {
|
|
91
|
+
return ""
|
|
92
|
+
}
|
|
93
|
+
values[k] = strings.Trim(v, "\"")
|
|
94
|
+
}
|
|
95
|
+
if values["productversion"] == "" || values["buildnumber"] == "" {
|
|
96
|
+
return ""
|
|
97
|
+
}
|
|
98
|
+
return values["productversion"] + "-" + values["buildnumber"]
|
|
99
|
+
}
|
|
100
|
+
func (c *collector) runtime(ctx context.Context) (Runtime, error) {
|
|
101
|
+
r := Runtime{Architecture: runtime.GOARCH, Libraries: []LibraryEvidence{}}
|
|
102
|
+
var u unix.Utsname
|
|
103
|
+
if unix.Uname(&u) != nil {
|
|
104
|
+
return r, ErrInvalid
|
|
105
|
+
}
|
|
106
|
+
r.Kernel = unix.ByteSliceToString(u.Release[:])
|
|
107
|
+
b, e := c.read(ctx, "/etc.defaults/VERSION", 4096)
|
|
108
|
+
if e == nil {
|
|
109
|
+
r.DSMBuild = version(b)
|
|
110
|
+
r.VersionDigest = hash(b)
|
|
111
|
+
}
|
|
112
|
+
boot, e := c.read(ctx, "/proc/sys/kernel/random/boot_id", 128)
|
|
113
|
+
if e == nil && len(strings.TrimSpace(string(boot))) == 36 {
|
|
114
|
+
r.BootRef = hash(bytes.TrimSpace(boot))
|
|
115
|
+
}
|
|
116
|
+
modules, _ := c.read(ctx, "/proc/modules", 1<<20)
|
|
117
|
+
for _, line := range strings.Split(string(modules), "\n") {
|
|
118
|
+
if strings.HasPrefix(line, "synoacl_vfs ") {
|
|
119
|
+
r.ACLModule = true
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for _, name := range []string{"libsynoacl.so", "libsynosdk.so.7", "libsynolocalaccount.so.7"} {
|
|
123
|
+
b, e := c.read(ctx, "/usr/lib/"+name, 32<<20)
|
|
124
|
+
if e != nil {
|
|
125
|
+
continue
|
|
126
|
+
}
|
|
127
|
+
evidence := LibraryEvidence{Name: name, SHA256: hash(b), Exports: []string{}}
|
|
128
|
+
image, e := elf.NewFile(bytes.NewReader(b))
|
|
129
|
+
if e != nil {
|
|
130
|
+
r.Libraries = append(r.Libraries, evidence)
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
133
|
+
symbols, _ := image.DynamicSymbols()
|
|
134
|
+
image.Close()
|
|
135
|
+
for _, s := range symbols {
|
|
136
|
+
switch s.Name {
|
|
137
|
+
case "SYNOACLPermCheck", "SYNOACLIsSupport", "SYNOUserGetLocal", "SYNOServiceUserHomeStatusGet", "SYNOShareGet", "SYNOShareUGPrivGetLocalInt":
|
|
138
|
+
if s.Section != elf.SHN_UNDEF {
|
|
139
|
+
evidence.Exports = append(evidence.Exports, s.Name)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
slices.Sort(evidence.Exports)
|
|
144
|
+
r.Libraries = append(r.Libraries, evidence)
|
|
145
|
+
}
|
|
146
|
+
// Deterministic fingerprint binds actual bytes and kernel/build/architecture;
|
|
147
|
+
// it is an observation, NOT a source-to-build or native semantics certificate.
|
|
148
|
+
seed, _ := json.Marshal(struct {
|
|
149
|
+
Architecture, DSMBuild, Kernel, VersionDigest string
|
|
150
|
+
Libraries []LibraryEvidence
|
|
151
|
+
ACLModule bool
|
|
152
|
+
}{r.Architecture, r.DSMBuild, r.Kernel, r.VersionDigest, r.Libraries, r.ACLModule})
|
|
153
|
+
r.Fingerprint = hash(seed)
|
|
154
|
+
if ctx.Err() != nil {
|
|
155
|
+
return r, ctx.Err()
|
|
156
|
+
}
|
|
157
|
+
return r, nil
|
|
158
|
+
}
|
|
159
|
+
func identity() Identity {
|
|
160
|
+
groups, _ := os.Getgroups()
|
|
161
|
+
g := make([]uint32, 0, len(groups))
|
|
162
|
+
for _, v := range groups {
|
|
163
|
+
g = append(g, uint32(v))
|
|
164
|
+
}
|
|
165
|
+
slices.Sort(g)
|
|
166
|
+
g = slices.Compact(g)
|
|
167
|
+
n, e := unix.PrctlRetInt(unix.PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0)
|
|
168
|
+
d, de := unix.PrctlRetInt(unix.PR_GET_DUMPABLE, 0, 0, 0, 0)
|
|
169
|
+
return Identity{UID: uint32(os.Geteuid()), GID: uint32(os.Getegid()), Groups: g, NoNewPrivs: e == nil && n == 1, NonDumpable: de == nil && d == 0}
|
|
170
|
+
}
|
|
171
|
+
func (c *collector) account(ctx context.Context, r Request) (Account, error) {
|
|
172
|
+
b, e := c.read(ctx, "/etc/passwd", 128<<10)
|
|
173
|
+
if e != nil {
|
|
174
|
+
return Account{}, e
|
|
175
|
+
}
|
|
176
|
+
var found *Account
|
|
177
|
+
for _, line := range strings.Split(string(b), "\n") {
|
|
178
|
+
fields := strings.Split(line, ":")
|
|
179
|
+
if len(fields) != 7 || fields[0] != r.Username {
|
|
180
|
+
continue
|
|
181
|
+
}
|
|
182
|
+
if found != nil {
|
|
183
|
+
return Account{}, ErrInvalid
|
|
184
|
+
}
|
|
185
|
+
uid, e := strconv.ParseUint(fields[2], 10, 32)
|
|
186
|
+
if e != nil {
|
|
187
|
+
return Account{}, ErrInvalid
|
|
188
|
+
}
|
|
189
|
+
gid, e := strconv.ParseUint(fields[3], 10, 32)
|
|
190
|
+
if e != nil {
|
|
191
|
+
return Account{}, ErrInvalid
|
|
192
|
+
}
|
|
193
|
+
found = &Account{Username: r.Username, UID: uint32(uid), GID: uint32(gid), Home: fields[5], Groups: []uint32{}}
|
|
194
|
+
}
|
|
195
|
+
if found == nil {
|
|
196
|
+
return Account{}, os.ErrNotExist
|
|
197
|
+
}
|
|
198
|
+
if found.UID != r.UID || found.GID != r.GID || found.Home != "/var/services/homes/"+r.Username {
|
|
199
|
+
return Account{}, ErrInvalid
|
|
200
|
+
}
|
|
201
|
+
// passwd is metadata only. Enabled/local/group/service/share native proofs
|
|
202
|
+
// remain false; no UID/name fingerprint is advertised as incarnation.
|
|
203
|
+
return *found, nil
|
|
204
|
+
}
|
|
205
|
+
func (c *collector) home(ctx context.Context, r Request) (Home, *os.File, error) {
|
|
206
|
+
var h Home
|
|
207
|
+
if ctx.Err() != nil {
|
|
208
|
+
return h, nil, ctx.Err()
|
|
209
|
+
}
|
|
210
|
+
link := c.path("/var/services/homes")
|
|
211
|
+
before, e := os.Lstat(link)
|
|
212
|
+
if e != nil || before.Mode()&os.ModeSymlink == 0 {
|
|
213
|
+
return h, nil, ErrInvalid
|
|
214
|
+
}
|
|
215
|
+
target, e := os.Readlink(link)
|
|
216
|
+
if e != nil || !filepath.IsAbs(target) || filepath.Clean(target) != target || !strings.HasPrefix(target, "/volume") || !strings.HasSuffix(target, "/homes") {
|
|
217
|
+
return h, nil, ErrInvalid
|
|
218
|
+
}
|
|
219
|
+
h.HomesPath = target
|
|
220
|
+
f, e := openObserved(c.path(target+"/"+r.Username), unix.O_PATH|unix.O_DIRECTORY)
|
|
221
|
+
if e != nil {
|
|
222
|
+
return h, nil, e
|
|
223
|
+
}
|
|
224
|
+
var st unix.Stat_t
|
|
225
|
+
if unix.Fstat(int(f.Fd()), &st) != nil || st.Mode&unix.S_IFMT != unix.S_IFDIR {
|
|
226
|
+
f.Close()
|
|
227
|
+
return h, nil, ErrInvalid
|
|
228
|
+
}
|
|
229
|
+
after, e := os.Lstat(link)
|
|
230
|
+
again, re := os.Readlink(link)
|
|
231
|
+
if e != nil || re != nil || !os.SameFile(before, after) || target != again {
|
|
232
|
+
f.Close()
|
|
233
|
+
return h, nil, ErrInvalid
|
|
234
|
+
}
|
|
235
|
+
h.Existing = true
|
|
236
|
+
h.Device = uint64(st.Dev)
|
|
237
|
+
h.Inode = st.Ino
|
|
238
|
+
h.Owner = st.Uid
|
|
239
|
+
return h, f, nil
|
|
240
|
+
}
|
|
241
|
+
func sampleACL(ctx context.Context, r Request, out Response, fd int) ACLSample {
|
|
242
|
+
sample := ACLSample{Mask: 0x105, SupportErrno: []uint32{}}
|
|
243
|
+
// Exact source-reviewed candidate only, explicitly requested for evidence.
|
|
244
|
+
// Never feed this result into bridge certification or a production Allow.
|
|
245
|
+
if ctx.Err() != nil || runtime.GOARCH != "amd64" || out.Runtime.DSMBuild != "7.4-90069" || out.Runtime.Kernel != "4.4.302+" || !out.Runtime.ACLModule || len(out.Runtime.Libraries) != 3 || r.ExpectedRuntime != out.Runtime.Fingerprint || out.Identity.UID != r.UID || out.Identity.GID != r.GID || !slices.Equal(out.Identity.Groups, r.Groups) || !out.Identity.NoNewPrivs || !out.Identity.NonDumpable || out.Home.Owner != r.UID {
|
|
246
|
+
return sample
|
|
247
|
+
}
|
|
248
|
+
ru, eu, su := unix.Getresuid()
|
|
249
|
+
rg, eg, sg := unix.Getresgid()
|
|
250
|
+
if ru != int(r.UID) || eu != ru || su != ru || rg != int(r.GID) || eg != rg || sg != rg {
|
|
251
|
+
return sample
|
|
252
|
+
}
|
|
253
|
+
var caps [2]unix.CapUserData
|
|
254
|
+
head := unix.CapUserHeader{Version: unix.LINUX_CAPABILITY_VERSION_3}
|
|
255
|
+
if unix.Capget(&head, &caps[0]) != nil || caps[0] != (unix.CapUserData{}) || caps[1] != (unix.CapUserData{}) {
|
|
256
|
+
return sample
|
|
257
|
+
}
|
|
258
|
+
var before unix.Stat_t
|
|
259
|
+
if unix.Fstat(fd, &before) != nil {
|
|
260
|
+
return sample
|
|
261
|
+
}
|
|
262
|
+
alias, e := unix.BytePtrFromString(fmt.Sprintf("/proc/self/fd/%d", fd))
|
|
263
|
+
if e != nil {
|
|
264
|
+
return sample
|
|
265
|
+
}
|
|
266
|
+
defer runtime.KeepAlive(alias)
|
|
267
|
+
sample.Attempted = true
|
|
268
|
+
for _, tag := range []uintptr{1, 2} {
|
|
269
|
+
result, _, errno := unix.Syscall(813, uintptr(unsafe.Pointer(alias)), uintptr(fd), tag)
|
|
270
|
+
sample.SupportErrno = append(sample.SupportErrno, uint32(errno))
|
|
271
|
+
if tag == 1 {
|
|
272
|
+
sample.FilesystemSupport = int64(result)
|
|
273
|
+
} else {
|
|
274
|
+
sample.ObjectSupport = int64(result)
|
|
275
|
+
}
|
|
276
|
+
if errno != 0 || result != 1 {
|
|
277
|
+
return sample
|
|
278
|
+
}
|
|
279
|
+
if ctx.Err() != nil {
|
|
280
|
+
return sample
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
result, _, errno := unix.Syscall(812, uintptr(unsafe.Pointer(alias)), uintptr(sample.Mask), 0)
|
|
284
|
+
sample.CheckResult = int64(result)
|
|
285
|
+
sample.CheckErrno = uint32(errno)
|
|
286
|
+
runtime.KeepAlive(alias)
|
|
287
|
+
var after unix.Stat_t
|
|
288
|
+
if unix.Fstat(fd, &after) != nil || before.Dev != after.Dev || before.Ino != after.Ino || before.Uid != after.Uid || before.Mode != after.Mode {
|
|
289
|
+
sample.CheckErrno = uint32(unix.ESTALE)
|
|
290
|
+
}
|
|
291
|
+
return sample
|
|
292
|
+
}
|
|
293
|
+
func (c *collector) collect(ctx context.Context, r Request) (Response, error) {
|
|
294
|
+
out := Response{Version: Protocol, Nonce: r.Nonce, Status: "unsupported", Identity: identity(), Account: Account{Groups: []uint32{}}, ACL: ACLSample{SupportErrno: []uint32{}}}
|
|
295
|
+
if r.Validate() != nil {
|
|
296
|
+
return out, ErrInvalid
|
|
297
|
+
}
|
|
298
|
+
rt, e := c.runtime(ctx)
|
|
299
|
+
out.Runtime = rt
|
|
300
|
+
if e != nil {
|
|
301
|
+
return out, e
|
|
302
|
+
}
|
|
303
|
+
if rt.DSMBuild != "" && rt.BootRef != "" {
|
|
304
|
+
out.Status = "ok"
|
|
305
|
+
}
|
|
306
|
+
if r.Kind == "runtime" {
|
|
307
|
+
return out, nil
|
|
308
|
+
}
|
|
309
|
+
a, e := c.account(ctx, r)
|
|
310
|
+
out.Account = a
|
|
311
|
+
if e != nil {
|
|
312
|
+
return out, e
|
|
313
|
+
}
|
|
314
|
+
h, f, e := c.home(ctx, r)
|
|
315
|
+
out.Home = h
|
|
316
|
+
out.Share = Share{Name: "homes", Path: h.HomesPath}
|
|
317
|
+
if e != nil {
|
|
318
|
+
return out, e
|
|
319
|
+
}
|
|
320
|
+
defer f.Close()
|
|
321
|
+
if r.Kind == "acl" {
|
|
322
|
+
out.ACL = sampleACL(ctx, r, out, int(f.Fd()))
|
|
323
|
+
}
|
|
324
|
+
if ctx.Err() != nil {
|
|
325
|
+
return out, ctx.Err()
|
|
326
|
+
}
|
|
327
|
+
return out, nil
|
|
328
|
+
}
|
|
329
|
+
func Collect(ctx context.Context, r Request) (Response, error) {
|
|
330
|
+
out, e := (&collector{}).collect(ctx, r)
|
|
331
|
+
if e != nil && !errors.Is(e, context.Canceled) && !errors.Is(e, context.DeadlineExceeded) {
|
|
332
|
+
out.Status = "unsupported"
|
|
333
|
+
}
|
|
334
|
+
return out, e
|
|
335
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package dsmprobe
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func TestCollectorMetadataNeverCertifiesNativePolicyOrCreatesHome(t *testing.T) {
|
|
12
|
+
root := t.TempDir()
|
|
13
|
+
for _, p := range []string{"etc.defaults", "etc", "proc/sys/kernel/random", "volume1/homes", "var/services"} {
|
|
14
|
+
if e := os.MkdirAll(filepath.Join(root, p), 0755); e != nil {
|
|
15
|
+
t.Fatal(e)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
os.WriteFile(root+"/etc/passwd", []byte("normal3:x:1217:100::/var/services/homes/normal3:/sbin/nologin\n"), 0644)
|
|
19
|
+
os.WriteFile(root+"/etc.defaults/VERSION", []byte("productversion=\"7.4\"\nbuildnumber=\"90069\"\n"), 0644)
|
|
20
|
+
os.WriteFile(root+"/proc/sys/kernel/random/boot_id", []byte("11111111-2222-3333-4444-555555555555\n"), 0644)
|
|
21
|
+
os.Symlink("/volume1/homes", root+"/var/services/homes")
|
|
22
|
+
r := Request{Version: 1, Nonce: strings.Repeat("a", 64), Username: "normal3", UID: 1217, GID: 100, Groups: []uint32{100}, Kind: "metadata"}
|
|
23
|
+
c := collector{root: root}
|
|
24
|
+
out, e := c.collect(context.Background(), r)
|
|
25
|
+
if !os.IsNotExist(e) || out.Account.UID != 1217 || out.Account.Home != "/var/services/homes/normal3" {
|
|
26
|
+
t.Fatal(e, out)
|
|
27
|
+
}
|
|
28
|
+
if out.Account.NativeKnown || out.Account.GroupsKnown || out.Home.StatusKnown || out.Share.NativeKnown || out.Share.PermissionKnown || out.ACL.Certified || out.ACL.Attempted {
|
|
29
|
+
t.Fatal("metadata became authority")
|
|
30
|
+
}
|
|
31
|
+
if _, e := os.Stat(root + "/volume1/homes/normal3"); !os.IsNotExist(e) {
|
|
32
|
+
t.Fatal("missing home created")
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
func TestCollectorACLRefusesDifferentActorAndFingerprint(t *testing.T) {
|
|
36
|
+
r := Request{Version: 1, Nonce: strings.Repeat("a", 64), Username: "normal3", UID: 1217, GID: 100, Groups: []uint32{100}, Kind: "acl", ExpectedRuntime: strings.Repeat("b", 64)}
|
|
37
|
+
out, _ := (&collector{}).collect(context.Background(), r)
|
|
38
|
+
if out.ACL.Attempted || out.ACL.Certified {
|
|
39
|
+
t.Fatal("unproven ABI or actor reached raw syscall")
|
|
40
|
+
}
|
|
41
|
+
}
|