@synopackageland/cli 0.4.1 → 0.5.0
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/README.md +7 -3
- package/dist/build-spk/delete-app-data.d.ts +27 -7
- package/dist/build-spk/delete-app-data.js +35 -34
- package/dist/build-spk/dsm-arch.d.ts +6 -1
- package/dist/build-spk/dsm-arch.js +25 -1
- package/dist/build-spk/dsm-version.d.ts +14 -0
- package/dist/build-spk/dsm-version.js +47 -0
- package/dist/build-spk/gateway.d.ts +31 -0
- package/dist/build-spk/gateway.js +55 -0
- package/dist/build-spk/generator.d.ts +5 -0
- package/dist/build-spk/generator.js +103 -107
- package/dist/build-spk/install-wizard.d.ts +20 -0
- package/dist/build-spk/install-wizard.js +76 -0
- package/dist/build-spk/native-lifecycle.d.ts +5 -0
- package/dist/build-spk/native-lifecycle.js +12 -2
- package/dist/build-spk/resource-worker.d.ts +9 -4
- package/dist/build-spk/resource-worker.js +15 -6
- package/dist/build-spk/share-combobox.d.ts +3 -0
- package/dist/build-spk/share-combobox.js +27 -0
- package/dist/build-spk/uninstall-wizard.d.ts +14 -0
- package/dist/build-spk/uninstall-wizard.js +33 -0
- package/dist/build-spk/wizard-i18n.d.ts +18 -0
- package/dist/build-spk/wizard-i18n.js +38 -0
- package/dist/build-spk/wizard-messages.d.ts +388 -0
- package/dist/build-spk/wizard-messages.js +387 -0
- package/dist/cli.js +130 -30
- package/dist/compose/analyze.d.ts +20 -0
- package/dist/compose/analyze.js +75 -11
- package/dist/contract/validate.js +33 -1
- package/dist/contract/web-launch.d.ts +22 -0
- package/dist/contract/web-launch.js +37 -0
- package/dist/deploy/deploy.d.ts +3 -0
- package/dist/deploy/deploy.js +11 -2
- package/dist/error-registry.js +60 -1
- package/dist/host/open-url.d.ts +2 -0
- package/dist/host/open-url.js +4 -1
- package/dist/images/pin.d.ts +52 -0
- package/dist/images/pin.js +249 -0
- package/dist/init.d.ts +27 -3
- package/dist/init.js +104 -15
- package/dist/inspect.d.ts +3 -0
- package/dist/inspect.js +15 -3
- package/dist/standalone/background.d.ts +21 -0
- package/dist/standalone/background.js +52 -0
- package/dist/standalone/binary.d.ts +1 -0
- package/dist/standalone/binary.js +1 -1
- package/dist/standalone/build.d.ts +2 -0
- package/dist/standalone/build.js +38 -6
- package/dist/standalone/dsm-window.js +2 -2
- package/dist/standalone/helper-inventory.d.ts +15 -0
- package/dist/standalone/helper-inventory.js +9 -0
- package/dist/standalone/helper.d.ts +1 -0
- package/dist/standalone/helper.js +28 -10
- package/dist/standalone/host-adapter.d.ts +1 -1
- package/dist/standalone/host-adapter.js +33 -15
- package/dist/standalone/host-file-navigation.d.ts +7 -0
- package/dist/standalone/host-file-navigation.js +172 -0
- package/dist/standalone/inspect-helper.js +9 -4
- package/dist/standalone/inspect-spk.d.ts +1 -1
- package/dist/standalone/inspect-spk.js +200 -7
- package/dist/standalone/job-diagnostics.d.ts +1 -0
- package/dist/standalone/job-diagnostics.js +49 -0
- package/dist/standalone/lifecycle.js +12 -2
- package/dist/standalone/manifest.d.ts +15 -2
- package/dist/standalone/manifest.js +37 -6
- package/dist/standalone/native-layout.d.ts +74 -0
- package/dist/standalone/native-layout.js +318 -0
- package/dist/standalone/resource.d.ts +11 -0
- package/dist/standalone/resource.js +13 -0
- package/dist/standalone/root-window.d.ts +3 -1
- package/dist/standalone/root-window.js +156 -38
- package/dist/standalone/shared-folder.d.ts +39 -0
- package/dist/standalone/shared-folder.js +141 -0
- package/dist/standalone/spk.d.ts +2 -0
- package/dist/standalone/spk.js +33 -3
- package/dist/standalone/worker-contract-json.d.ts +8 -0
- package/dist/standalone/worker-contract-json.js +141 -0
- package/dist/standalone/worker-contract.d.ts +189 -0
- package/dist/standalone/worker-contract.js +175 -0
- package/dist/standalone/worker-registry.d.ts +40 -0
- package/dist/standalone/worker-registry.js +167 -0
- package/dist/templates/_daemon/go.mod +2 -0
- package/dist/templates/_gateway/auth.go +101 -0
- package/dist/templates/_gateway/auth_test.go +216 -0
- package/dist/templates/_gateway/cgi.go +133 -0
- package/dist/templates/_gateway/cgi_test.go +156 -0
- package/dist/templates/_gateway/csrf.go +73 -0
- package/dist/templates/_gateway/csrf_test.go +155 -0
- package/dist/templates/_gateway/directory.go +108 -0
- package/dist/templates/_gateway/directory_test.go +202 -0
- package/dist/templates/_gateway/gateway.go +412 -0
- package/dist/templates/_gateway/gateway_test.go +676 -0
- package/dist/templates/_gateway/go.mod +3 -0
- package/dist/templates/_gateway/groups.go +66 -0
- package/dist/templates/_gateway/main.go +45 -0
- package/dist/templates/binary/synology-app.yaml +1 -1
- package/dist/templates/compose-import/compose.yaml +1 -1
- package/dist/templates/compose-import/synology-app.yaml +1 -1
- package/dist/templates/hello-files/compose.yaml +1 -1
- package/dist/templates/hello-files/synology-app.yaml +1 -1
- package/dist/templates/hello-web/compose.yaml +5 -2
- package/dist/templates/hello-web/synology-app.yaml +4 -1
- package/dist/templates/hello-web-page/compose.yaml +5 -2
- package/dist/templates/hello-web-page/synology-app.yaml +4 -1
- package/dist/templates/native-go/README.md +93 -4
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/dist/templates/native-go/backend/cmd/app/main.go +17 -0
- package/dist/templates/native-go/backend/cmd/app/sdk_main.go +60 -0
- package/dist/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +10 -1
- package/dist/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/dist/templates/native-go/backend/go.mod +5 -3
- package/dist/templates/native-go/backend/go.sum +4 -4
- package/dist/templates/native-go/backend/internal/api/registry.go +17 -6
- package/dist/templates/native-go/backend/internal/api/server.go +7 -1
- package/dist/templates/native-go/backend/internal/app/background.go +270 -0
- package/dist/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/dist/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/dist/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/dist/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/dist/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/dist/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/dist/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/dist/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +17 -3
- package/dist/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/dist/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/dist/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/dist/templates/native-go/backend/internal/app/sdk_routes.go +174 -0
- package/dist/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/dist/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/dist/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/dist/templates/native-go/backend/internal/background/access.go +57 -0
- package/dist/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/dist/templates/native-go/backend/internal/background/runner.go +185 -0
- package/dist/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/dist/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/dist/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/dist/templates/native-go/backend/internal/background/store.go +807 -0
- package/dist/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/dist/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/dist/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/dist/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/dist/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/dist/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/dist/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/dist/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/dist/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/dist/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/dist/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/dist/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/dist/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/dist/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/dist/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/dist/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/management.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/dist/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_server_linux.go +152 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/dist/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +22 -13
- package/dist/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/dist/templates/native-go/dsm-package.yaml +1 -1
- package/dist/templates/native-go-background/BACKGROUND.md +111 -0
- package/dist/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/dist/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/dist/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/dist/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/dist/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/dist/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/dist/templates/native-go-vue/README.md +38 -7
- package/dist/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/dist/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/dist/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/dist/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/dist/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/dist/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/dist/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/dist/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/dist/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/dist/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/dist/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/dist/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/dist/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/dist/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +2 -6
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/dist/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/dist/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/dist/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/dist/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/dist/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/dist/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/dist/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/dist/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/dist/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/dist/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/dist/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +2 -2
- package/dist/validate.js +6 -3
- package/package.json +1 -1
- package/schema/synology-app.schema.json +19 -0
- package/skills/reference/create.md +4 -0
- package/templates/_daemon/go.mod +2 -0
- package/templates/_gateway/auth.go +101 -0
- package/templates/_gateway/auth_test.go +216 -0
- package/templates/_gateway/cgi.go +133 -0
- package/templates/_gateway/cgi_test.go +156 -0
- package/templates/_gateway/csrf.go +73 -0
- package/templates/_gateway/csrf_test.go +155 -0
- package/templates/_gateway/directory.go +108 -0
- package/templates/_gateway/directory_test.go +202 -0
- package/templates/_gateway/gateway.go +412 -0
- package/templates/_gateway/gateway_test.go +676 -0
- package/templates/_gateway/go.mod +3 -0
- package/templates/_gateway/groups.go +66 -0
- package/templates/_gateway/main.go +45 -0
- package/templates/binary/synology-app.yaml +1 -1
- package/templates/compose-import/compose.yaml +1 -1
- package/templates/compose-import/synology-app.yaml +1 -1
- package/templates/hello-files/compose.yaml +1 -1
- package/templates/hello-files/synology-app.yaml +1 -1
- package/templates/hello-web/compose.yaml +5 -2
- package/templates/hello-web/synology-app.yaml +4 -1
- package/templates/hello-web-page/compose.yaml +5 -2
- package/templates/hello-web-page/synology-app.yaml +4 -1
- package/templates/native-go/README.md +93 -4
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +3 -1
- package/templates/native-go/backend/cmd/app/main.go +17 -0
- package/templates/native-go/backend/cmd/app/sdk_main.go +60 -0
- package/templates/native-go/backend/cmd/background-worker/main.go +38 -0
- package/templates/native-go/backend/cmd/helper/main.go +10 -1
- package/templates/native-go/backend/cmd/helper/sdk_registry.go +19 -0
- package/templates/native-go/backend/go.mod +5 -3
- package/templates/native-go/backend/go.sum +4 -4
- package/templates/native-go/backend/internal/api/registry.go +17 -6
- package/templates/native-go/backend/internal/api/server.go +7 -1
- package/templates/native-go/backend/internal/app/background.go +270 -0
- package/templates/native-go/backend/internal/app/background_none.go +8 -0
- package/templates/native-go/backend/internal/app/background_owner.go +59 -0
- package/templates/native-go/backend/internal/app/background_owner_test.go +145 -0
- package/templates/native-go/backend/internal/app/background_schedule.go +74 -0
- package/templates/native-go/backend/internal/app/background_schedule_test.go +62 -0
- package/templates/native-go/backend/internal/app/background_test.go +346 -0
- package/templates/native-go/backend/internal/app/integration_state.go +16 -0
- package/templates/native-go/backend/internal/app/migrations.go +41 -0
- package/templates/native-go/backend/internal/app/migrations_test.go +41 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +8 -0
- package/templates/native-go/backend/internal/app/routes.go +17 -3
- package/templates/native-go/backend/internal/app/routes_test.go +20 -3
- package/templates/native-go/backend/internal/app/sdk_jobs.go +70 -0
- package/templates/native-go/backend/internal/app/sdk_jobs_test.go +116 -0
- package/templates/native-go/backend/internal/app/sdk_routes.go +174 -0
- package/templates/native-go/backend/internal/app/session_files.go +15 -0
- package/templates/native-go/backend/internal/app/session_files_test.go +26 -0
- package/templates/native-go/backend/internal/app/shared_folder.go +144 -0
- package/templates/native-go/backend/internal/app/shared_folder_test.go +158 -0
- package/templates/native-go/backend/internal/background/access.go +57 -0
- package/templates/native-go/backend/internal/background/owner_test.go +126 -0
- package/templates/native-go/backend/internal/background/runner.go +185 -0
- package/templates/native-go/backend/internal/background/runner_test.go +209 -0
- package/templates/native-go/backend/internal/background/schedule.go +300 -0
- package/templates/native-go/backend/internal/background/schedule_test.go +335 -0
- package/templates/native-go/backend/internal/background/store.go +807 -0
- package/templates/native-go/backend/internal/background/store_test.go +407 -0
- package/templates/native-go/backend/internal/datamigrate/migrate.go +191 -0
- package/templates/native-go/backend/internal/datamigrate/migrate_test.go +177 -0
- package/templates/native-go/backend/internal/filestation/browse_test.go +67 -0
- package/templates/native-go/backend/internal/filestation/client.go +251 -0
- package/templates/native-go/backend/internal/filestation/client_test.go +155 -0
- package/templates/native-go/backend/internal/filestation/doc.go +4 -0
- package/templates/native-go/backend/internal/filestation/read_file_test.go +90 -0
- package/templates/native-go/backend/internal/filestation/repository.go +207 -0
- package/templates/native-go/backend/internal/filestation/repository_test.go +104 -0
- package/templates/native-go/backend/internal/filestation/sdk_session.go +241 -0
- package/templates/native-go/backend/internal/filestation/sdk_session_test.go +183 -0
- package/templates/native-go/backend/internal/filestation/service.go +254 -0
- package/templates/native-go/backend/internal/filestation/service_test.go +94 -0
- package/templates/native-go/backend/internal/filestation/session_semantics_test.go +383 -0
- package/templates/native-go/backend/internal/filestation/write.go +72 -0
- package/templates/native-go/backend/internal/filestation/write_test.go +123 -0
- package/templates/native-go/backend/internal/helper/background_proof.go +163 -0
- package/templates/native-go/backend/internal/helper/background_proof_contract.go +46 -0
- package/templates/native-go/backend/internal/helper/background_proof_test.go +161 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +3 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_authority.go +3 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +1 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +2 -1
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +4 -3
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +3 -0
- package/templates/native-go/backend/internal/helper/jobcontract/bindings.go +48 -0
- package/templates/native-go/backend/internal/helper/jobcontract/contract_test.go +436 -0
- package/templates/native-go/backend/internal/helper/jobcontract/decode.go +185 -0
- package/templates/native-go/backend/internal/helper/jobcontract/digest.go +55 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry.go +85 -0
- package/templates/native-go/backend/internal/helper/jobcontract/registry_test.go +73 -0
- package/templates/native-go/backend/internal/helper/jobcontract/result.go +53 -0
- package/templates/native-go/backend/internal/helper/jobcontract/stub.go +8 -0
- package/templates/native-go/backend/internal/helper/jobcontract/testdata/input-digests.json +127 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types.go +234 -0
- package/templates/native-go/backend/internal/helper/jobcontract/types_test.go +29 -0
- package/templates/native-go/backend/internal/helper/jobcontract/validate.go +462 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_linux_test.go +34 -0
- package/templates/native-go/backend/internal/helper/legacy_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/management.go +79 -0
- package/templates/native-go/backend/internal/helper/observation.go +42 -2
- package/templates/native-go/backend/internal/helper/observation_health_test.go +13 -1
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +56 -10
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +6 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_writer.go +40 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +3 -0
- package/templates/native-go/backend/internal/helper/query_deadline_linux_test.go +115 -0
- package/templates/native-go/backend/internal/helper/query_pending_diagnostic_test.go +254 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +3 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +23 -4
- package/templates/native-go/backend/internal/helper/sdk_assembly_linux.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_attach.go +83 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_contract.go +32 -0
- package/templates/native-go/backend/internal/helper/sdk_attach_test.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_authority_schema_test.go +6 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority.go +832 -0
- package/templates/native-go/backend/internal/helper/sdk_background_authority_test.go +714 -0
- package/templates/native-go/backend/internal/helper/sdk_background_invalidation.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_lease.go +218 -0
- package/templates/native-go/backend/internal/helper/sdk_background_snapshot.go +110 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_linux_test.go +261 -0
- package/templates/native-go/backend/internal/helper/sdk_background_store_test.go +58 -0
- package/templates/native-go/backend/internal/helper/sdk_bindings.go +60 -0
- package/templates/native-go/backend/internal/helper/sdk_data_contract.go +251 -0
- package/templates/native-go/backend/internal/helper/sdk_data_protocol.go +424 -0
- package/templates/native-go/backend/internal/helper/sdk_dispatch_absence_test.go +51 -0
- package/templates/native-go/backend/internal/helper/sdk_display.go +488 -0
- package/templates/native-go/backend/internal/helper/sdk_display_contract.go +121 -0
- package/templates/native-go/backend/internal/helper/sdk_display_test.go +459 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_authority.go +559 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_repository_linux.go +417 -0
- package/templates/native-go/backend/internal/helper/sdk_grant_snapshot.go +94 -0
- package/templates/native-go/backend/internal/helper/sdk_history.go +80 -0
- package/templates/native-go/backend/internal/helper/sdk_history_test.go +76 -0
- package/templates/native-go/backend/internal/helper/sdk_job.go +697 -0
- package/templates/native-go/backend/internal/helper/sdk_job_child_linux.go +309 -0
- package/templates/native-go/backend/internal/helper/sdk_job_contract.go +122 -0
- package/templates/native-go/backend/internal/helper/sdk_job_linux_test.go +159 -0
- package/templates/native-go/backend/internal/helper/sdk_job_process_linux.go +327 -0
- package/templates/native-go/backend/internal/helper/sdk_job_test.go +501 -0
- package/templates/native-go/backend/internal/helper/sdk_job_vm_linux_test.go +343 -0
- package/templates/native-go/backend/internal/helper/sdk_journal.go +77 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux.go +244 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_linux_test.go +295 -0
- package/templates/native-go/backend/internal/helper/sdk_journal_test.go +71 -0
- package/templates/native-go/backend/internal/helper/sdk_picker_test.go +50 -0
- package/templates/native-go/backend/internal/helper/sdk_process_linux.go +184 -0
- package/templates/native-go/backend/internal/helper/sdk_public_vm_linux_test.go +129 -0
- package/templates/native-go/backend/internal/helper/sdk_relaxed_invalidation.go +242 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc.go +299 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_contract.go +70 -0
- package/templates/native-go/backend/internal/helper/sdk_rpc_test.go +135 -0
- package/templates/native-go/backend/internal/helper/sdk_server_linux.go +152 -0
- package/templates/native-go/backend/internal/helper/sdk_session.go +677 -0
- package/templates/native-go/backend/internal/helper/sdk_session_contract.go +72 -0
- package/templates/native-go/backend/internal/helper/sdk_session_fence_test.go +215 -0
- package/templates/native-go/backend/internal/helper/sdk_session_test.go +475 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_frame.go +78 -0
- package/templates/native-go/backend/internal/helper/sdk_supervisor_linux.go +414 -0
- package/templates/native-go/backend/internal/helper/sdk_transport.go +79 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_linux.go +82 -0
- package/templates/native-go/backend/internal/helper/sdk_transport_test.go +64 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +3 -0
- package/templates/native-go/backend/internal/helper/stale_management_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/stale_management_test.go +122 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic.go +68 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_linux_test.go +126 -0
- package/templates/native-go/backend/internal/helper/startup_diagnostic_test.go +117 -0
- package/templates/native-go/backend/internal/helper/status.go +22 -13
- package/templates/native-go/backend/internal/helper/status_test.go +45 -0
- package/templates/native-go/backend/internal/helper/supervision.go +1 -1
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +3 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +6 -2
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +22 -4
- package/templates/native-go/backend/internal/helper/unit_linux.go +7 -3
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +5 -1
- package/templates/native-go/backend/internal/helper/write_files_linux.go +7 -4
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +26 -0
- package/templates/native-go/dsm-package.yaml +1 -1
- package/templates/native-go-background/BACKGROUND.md +111 -0
- package/templates/native-go-background/backend/internal/app/background_on.go +7 -0
- package/templates/native-go-background/backend/internal/app/background_routes_test.go +32 -0
- package/templates/native-go-background/frontend/src/background/BackgroundPanel.vue +178 -0
- package/templates/native-go-background/frontend/src/background/i18n/de.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/en.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/es.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/fr.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/it.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ja.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/ko.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-CN.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n/zh-TW.json +83 -0
- package/templates/native-go-background/frontend/src/background/i18n.ts +19 -0
- package/templates/native-go-background/frontend/src/background/picker-provider.ts +13 -0
- package/templates/native-go-background/frontend/test/background.test.ts +179 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +2 -2
- package/templates/native-go-integration/backend/internal/app/personal_test.go +37 -0
- package/templates/native-go-vue/README.md +38 -7
- package/templates/native-go-vue/frontend/DESIGN.md +15 -3
- package/templates/native-go-vue/frontend/README-JOBS.md +75 -0
- package/templates/native-go-vue/frontend/README-M2.md +64 -0
- package/templates/native-go-vue/frontend/package-lock.json +5 -4
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +39 -11
- package/templates/native-go-vue/frontend/src/M2App.vue +57 -0
- package/templates/native-go-vue/frontend/src/SDKApp.vue +203 -0
- package/templates/native-go-vue/frontend/src/jobs/InteractiveJobForm.vue +70 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsAdminPanel.vue +33 -0
- package/templates/native-go-vue/frontend/src/jobs/JobsPanel.vue +135 -0
- package/templates/native-go-vue/frontend/src/jobs/connected-provider.ts +179 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/de.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/en.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/es.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/fr.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/it.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ja.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/ko.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-CN.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n/zh-TW.json +62 -0
- package/templates/native-go-vue/frontend/src/jobs/i18n.ts +15 -0
- package/templates/native-go-vue/frontend/src/jobs/mock-provider.ts +67 -0
- package/templates/native-go-vue/frontend/src/jobs/provider.ts +60 -0
- package/templates/native-go-vue/frontend/src/jobs/validate.ts +44 -0
- package/templates/native-go-vue/frontend/src/m2-main.ts +21 -0
- package/templates/native-go-vue/frontend/src/m2-style.css +7 -0
- package/templates/native-go-vue/frontend/src/nas/M2Files.vue +94 -0
- package/templates/native-go-vue/frontend/src/nas/M2PathPicker.vue +70 -0
- package/templates/native-go-vue/frontend/src/nas/M2Settings.vue +69 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/de.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/en.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/es.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/fr.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/it.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ja.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/ko.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-CN.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/m2/zh-TW.json +56 -0
- package/templates/native-go-vue/frontend/src/nas/m2-contract.ts +33 -0
- package/templates/native-go-vue/frontend/src/nas/m2-i18n.ts +24 -0
- package/templates/native-go-vue/frontend/src/nas/m2-provider.ts +104 -0
- package/templates/native-go-vue/frontend/src/nas/use-m2-request.ts +18 -0
- package/templates/native-go-vue/frontend/src/sdk-main.ts +39 -0
- package/templates/native-go-vue/frontend/src/shell/AppShell.vue +48 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/de.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/en.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/es.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/fr.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/it.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ja.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/ko.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-CN.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n/zh-TW.json +10 -0
- package/templates/native-go-vue/frontend/src/shell/i18n.ts +17 -0
- package/templates/native-go-vue/frontend/src/shell/pages.ts +34 -0
- package/templates/native-go-vue/frontend/src/style.css +2 -6
- package/templates/native-go-vue/frontend/test/apps.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/jobs-connected.test.ts +163 -0
- package/templates/native-go-vue/frontend/test/jobs-preview.html +22 -0
- package/templates/native-go-vue/frontend/test/jobs.test.ts +176 -0
- package/templates/native-go-vue/frontend/test/m2-preview.html +27 -0
- package/templates/native-go-vue/frontend/test/m2-provider.test.ts +87 -0
- package/templates/native-go-vue/frontend/test/m2-ui.test.ts +209 -0
- package/templates/native-go-vue/frontend/test/native-controls.test.ts +27 -0
- package/templates/native-go-vue/frontend/test/picker-wire.test.ts +110 -0
- package/templates/native-go-vue/frontend/test/shell-preview.html +19 -0
- package/templates/native-go-vue/frontend/test/shell-sdk.test.ts +73 -0
- package/templates/native-go-vue/frontend/test/shell-ui.test.ts +114 -0
- package/templates/native-go-vue/frontend/test/shell.test.ts +45 -0
- package/templates/native-go-vue/frontend/vite.config.ts +2 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { inertWorkerRegistry } from "./helper-inventory.js";
|
|
5
|
+
import { WORKER_CONTRACT } from "./worker-contract.js";
|
|
6
|
+
import { fail, strictJSON } from "./worker-contract-json.js";
|
|
7
|
+
const actions = ["nas.files.list", "nas.files.stat", "nas.files.read", "nas.files.read-stream"];
|
|
8
|
+
const modes = ["interactive", "background"];
|
|
9
|
+
const checkpoints = ["before-step", "before-chunk", "before-result"];
|
|
10
|
+
const ceilings = {
|
|
11
|
+
inputBytes: 8192, steps: 16, totalMs: 120000, idleMs: 10000, metadataMs: 5000,
|
|
12
|
+
boundedMs: 10000, boundedBytes: 1048576, streamBytes: 67108864, chunkBytes: 65536, outstandingLeases: 1,
|
|
13
|
+
};
|
|
14
|
+
const idPattern = /^[a-z][a-z0-9_]{0,31}$/;
|
|
15
|
+
const digestPattern = /^[a-f0-9]{64}$/;
|
|
16
|
+
const asciiCompare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
17
|
+
function object(value, required, optional = []) {
|
|
18
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
19
|
+
return fail();
|
|
20
|
+
const o = value;
|
|
21
|
+
if (required.some(k => !Object.hasOwn(o, k)) || Object.keys(o).some(k => !required.includes(k) && !optional.includes(k)))
|
|
22
|
+
fail();
|
|
23
|
+
return o;
|
|
24
|
+
}
|
|
25
|
+
function bounded(value, max, min = 1) {
|
|
26
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min)
|
|
27
|
+
return fail();
|
|
28
|
+
if (value > max)
|
|
29
|
+
fail("limit-exceeded");
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function digest(value) {
|
|
33
|
+
if (typeof value !== "string" || !digestPattern.test(value))
|
|
34
|
+
return fail();
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function subset(value, allowed) {
|
|
38
|
+
if (!Array.isArray(value) || !value.length || new Set(value).size !== value.length || value.some(v => !allowed.includes(v)))
|
|
39
|
+
return fail();
|
|
40
|
+
return allowed.filter(v => value.includes(v));
|
|
41
|
+
}
|
|
42
|
+
function limits(value, partial) {
|
|
43
|
+
const keys = Object.keys(ceilings);
|
|
44
|
+
const raw = object(value, partial ? [] : keys, partial ? keys : []);
|
|
45
|
+
const result = { ...ceilings };
|
|
46
|
+
for (const k of keys)
|
|
47
|
+
if (Object.hasOwn(raw, k))
|
|
48
|
+
result[k] = bounded(raw[k], ceilings[k]);
|
|
49
|
+
if (result.idleMs > result.totalMs || result.metadataMs > result.totalMs || result.boundedMs > result.totalMs || result.chunkBytes > result.streamBytes)
|
|
50
|
+
fail();
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
/** Manifest metadata only; never accepts a source path or a caller-chosen digest. */
|
|
54
|
+
export function parseSDKWorkers(value, inertIDs = []) {
|
|
55
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
56
|
+
return fail();
|
|
57
|
+
const entries = Object.entries(value);
|
|
58
|
+
if (!entries.length || entries.length + inertIDs.length > WORKER_CONTRACT.maxWorkers)
|
|
59
|
+
fail("limit-exceeded");
|
|
60
|
+
return Object.fromEntries(entries.sort(([a], [b]) => asciiCompare(a, b)).map(([id, value]) => {
|
|
61
|
+
if (!idPattern.test(id) || inertIDs.includes(id))
|
|
62
|
+
fail();
|
|
63
|
+
const o = object(value, ["kind", "workerRevision", "actions", "modes"], ["limits"]);
|
|
64
|
+
if (o.kind !== "sdk-read-plan")
|
|
65
|
+
fail("unsupported");
|
|
66
|
+
return [id, {
|
|
67
|
+
kind: "sdk-read-plan", workerRevision: bounded(o.workerRevision, Number.MAX_SAFE_INTEGER),
|
|
68
|
+
actions: subset(o.actions, actions), modes: subset(o.modes, modes),
|
|
69
|
+
limits: limits(Object.hasOwn(o, "limits") ? o.limits : {}, true),
|
|
70
|
+
}];
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
/** Must match jobcontract/bindings.go; filenames and exact source bytes are bound. */
|
|
74
|
+
export function sourceWorkerBindings(backend) {
|
|
75
|
+
const hash = (kind, names, root = "internal/helper/jobcontract", version = 1) => {
|
|
76
|
+
const h = createHash("sha256").update(`synopkgland/m3/${kind}/source-v${version}\0`);
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
const path = join(backend, root, name);
|
|
79
|
+
if (!lstatSync(path).isFile() || lstatSync(path).size > 1048576)
|
|
80
|
+
fail();
|
|
81
|
+
for (const b of [Buffer.from(name), readFileSync(path)]) {
|
|
82
|
+
const size = Buffer.alloc(4);
|
|
83
|
+
size.writeUInt32BE(b.length);
|
|
84
|
+
h.update(size).update(b);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return h.digest("hex");
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
handlerBinding: hash("handler", ["jobcontract/stub.go", "sdk_job_child_linux.go", "sdk_job_process_linux.go", "sdk_job.go", "sdk_attach.go", "sdk_rpc.go", "sdk_session.go", "sdk_session_contract.go"], "internal/helper", 2),
|
|
91
|
+
inputSchemaDigest: hash("input", ["decode.go", "digest.go", "types.go", "validate.go"]),
|
|
92
|
+
outputSchemaDigest: hash("result", ["decode.go", "result.go", "types.go", "validate.go"]),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function buildWorkerRegistry(inert, sdkWorkers, backend) {
|
|
96
|
+
// Do not even read new SDK files for legacy projects (including old templates).
|
|
97
|
+
if (sdkWorkers === undefined)
|
|
98
|
+
return inertWorkerRegistry(inert);
|
|
99
|
+
const configs = parseSDKWorkers(sdkWorkers, inert.map(w => w.id));
|
|
100
|
+
const bindings = sourceWorkerBindings(backend);
|
|
101
|
+
const registry = {
|
|
102
|
+
registrySchema: 2, productionAvailability: "unavailable",
|
|
103
|
+
inert: inert.map(({ id, digest }) => ({ id, digest })).sort((a, b) => asciiCompare(a.id, b.id)),
|
|
104
|
+
sdk: Object.entries(configs).map(([workerId, c]) => ({
|
|
105
|
+
registrySchema: 2, workerId, workerRevision: c.workerRevision, kind: c.kind,
|
|
106
|
+
...bindings, actions: c.actions, modes: c.modes, checkpoints: [...checkpoints], limits: c.limits,
|
|
107
|
+
})),
|
|
108
|
+
};
|
|
109
|
+
const raw = JSON.stringify(registry);
|
|
110
|
+
decodeSDKRegistry(raw);
|
|
111
|
+
return raw;
|
|
112
|
+
}
|
|
113
|
+
/** Structural/artifact inspection only; the compiled Go consumer checks source bindings. */
|
|
114
|
+
export function decodeSDKRegistry(raw) {
|
|
115
|
+
const r = object(strictJSON(raw, WORKER_CONTRACT.maxArtifactBytes), ["registrySchema", "productionAvailability", "inert", "sdk"]);
|
|
116
|
+
if (r.registrySchema !== 2 || r.productionAvailability !== "unavailable")
|
|
117
|
+
fail("incompatible");
|
|
118
|
+
if (!Array.isArray(r.inert) || !Array.isArray(r.sdk) || !r.sdk.length || r.inert.length + r.sdk.length > WORKER_CONTRACT.maxWorkers)
|
|
119
|
+
return fail();
|
|
120
|
+
const ids = new Set();
|
|
121
|
+
let previous = "";
|
|
122
|
+
const id = (value) => {
|
|
123
|
+
if (typeof value !== "string" || !idPattern.test(value) || value <= previous || ids.has(value))
|
|
124
|
+
return fail();
|
|
125
|
+
previous = value;
|
|
126
|
+
ids.add(value);
|
|
127
|
+
return value;
|
|
128
|
+
};
|
|
129
|
+
const inert = r.inert.map(value => {
|
|
130
|
+
const w = object(value, ["id", "digest"]);
|
|
131
|
+
return { id: id(w.id), digest: digest(w.digest) };
|
|
132
|
+
});
|
|
133
|
+
previous = "";
|
|
134
|
+
const sdk = r.sdk.map(value => {
|
|
135
|
+
const w = object(value, ["registrySchema", "workerId", "workerRevision", "kind", "handlerBinding", "inputSchemaDigest", "outputSchemaDigest", "actions", "modes", "checkpoints", "limits"]);
|
|
136
|
+
if (w.registrySchema !== 2 || w.kind !== "sdk-read-plan")
|
|
137
|
+
fail("incompatible");
|
|
138
|
+
if (JSON.stringify(w.checkpoints) !== JSON.stringify(checkpoints))
|
|
139
|
+
fail();
|
|
140
|
+
return {
|
|
141
|
+
registrySchema: 2, workerId: id(w.workerId), workerRevision: bounded(w.workerRevision, Number.MAX_SAFE_INTEGER), kind: "sdk-read-plan",
|
|
142
|
+
handlerBinding: digest(w.handlerBinding), inputSchemaDigest: digest(w.inputSchemaDigest), outputSchemaDigest: digest(w.outputSchemaDigest),
|
|
143
|
+
actions: subset(w.actions, actions), modes: subset(w.modes, modes), checkpoints: [...checkpoints], limits: limits(w.limits, false),
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
const result = { registrySchema: 2, productionAvailability: "unavailable", inert, sdk };
|
|
147
|
+
// One byte representation is compiled and approved; no aliases or reordering.
|
|
148
|
+
if (JSON.stringify(result) !== (typeof raw === "string" ? raw : Buffer.from(raw).toString("utf8")))
|
|
149
|
+
fail();
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
const safeReasons = ["invalid-request", "incompatible", "unsupported", "replay", "stale", "expired", "denied", "unavailable", "suspended", "revoked", "fenced", "busy", "limit-exceeded", "canceled", "timeout", "partial", "commit-uncertain", "cleanup-required", "internal"];
|
|
153
|
+
export function decodeWorkerResult(raw) {
|
|
154
|
+
const r = object(strictJSON(raw, WORKER_CONTRACT.maxProgressBytes), ["resultSchema", "completedSteps", "entries", "bytesRead"], ["safeReason"]);
|
|
155
|
+
if (r.resultSchema !== 1)
|
|
156
|
+
fail("incompatible");
|
|
157
|
+
const result = {
|
|
158
|
+
resultSchema: 1, completedSteps: bounded(r.completedSteps, 16, 0),
|
|
159
|
+
entries: bounded(r.entries, 3200, 0), bytesRead: bounded(r.bytesRead, 67108864, 0),
|
|
160
|
+
};
|
|
161
|
+
if (Object.hasOwn(r, "safeReason")) {
|
|
162
|
+
if (!safeReasons.includes(r.safeReason))
|
|
163
|
+
fail();
|
|
164
|
+
result.safeReason = r.safeReason;
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
// DSM runs a package's CGI as the package account and forwards the browser's
|
|
4
|
+
// cookies. The authenticator hands only the session carriers (cookie,
|
|
5
|
+
// SynoToken, client address) to DSM's own authenticate.cgi, which prints the
|
|
6
|
+
// signed-in user name, then resolves local groups or directory groups through DSM NSS.
|
|
7
|
+
// It never parses the session cookie or trusts a user name from the request.
|
|
8
|
+
|
|
9
|
+
import (
|
|
10
|
+
"context"
|
|
11
|
+
"errors"
|
|
12
|
+
"fmt"
|
|
13
|
+
"net"
|
|
14
|
+
"net/http"
|
|
15
|
+
"net/url"
|
|
16
|
+
"os/exec"
|
|
17
|
+
"regexp"
|
|
18
|
+
"strings"
|
|
19
|
+
"time"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// authenticateCGI is DSM's session check for third-party CGIs.
|
|
23
|
+
const authenticateCGI = "/usr/syno/synoman/webman/modules/authenticate.cgi"
|
|
24
|
+
|
|
25
|
+
var errNoSession = errors.New("no valid DSM session")
|
|
26
|
+
|
|
27
|
+
type identity struct {
|
|
28
|
+
User string
|
|
29
|
+
Groups []string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type authenticator interface {
|
|
33
|
+
Authenticate(r *http.Request) (identity, error)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type dsmAuthenticator struct {
|
|
37
|
+
groupFile string
|
|
38
|
+
passwdFile string
|
|
39
|
+
directoryGroups func(context.Context, string) ([]string, error)
|
|
40
|
+
timeout time.Duration
|
|
41
|
+
run func(ctx context.Context, path string, env []string) ([]byte, error)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func newDSMAuthenticator() *dsmAuthenticator {
|
|
45
|
+
return &dsmAuthenticator{groupFile: "/etc/group", passwdFile: "/etc/passwd", timeout: 10 * time.Second, run: runCGI, directoryGroups: (directoryLookup{timeout: 2 * time.Second, run: runDirectoryCommand}).groups}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var userName = regexp.MustCompile(`^[A-Za-z0-9._@\\-]{1,193}$`)
|
|
49
|
+
|
|
50
|
+
func (a *dsmAuthenticator) Authenticate(r *http.Request) (identity, error) {
|
|
51
|
+
cookie := r.Header.Get("Cookie")
|
|
52
|
+
if cookie == "" {
|
|
53
|
+
return identity{}, errNoSession
|
|
54
|
+
}
|
|
55
|
+
ctx, cancel := context.WithTimeout(r.Context(), a.timeout)
|
|
56
|
+
defer cancel()
|
|
57
|
+
out, err := a.run(ctx, authenticateCGI, sessionEnv(r, cookie))
|
|
58
|
+
var exit interface{ ExitCode() int }
|
|
59
|
+
if errors.As(err, &exit) {
|
|
60
|
+
return identity{}, errNoSession
|
|
61
|
+
}
|
|
62
|
+
if err != nil {
|
|
63
|
+
return identity{}, fmt.Errorf("run %s: %w", authenticateCGI, err)
|
|
64
|
+
}
|
|
65
|
+
user := strings.TrimSpace(string(out))
|
|
66
|
+
if !userName.MatchString(user) {
|
|
67
|
+
return identity{}, errNoSession
|
|
68
|
+
}
|
|
69
|
+
groups, err := a.groupsOf(ctx, user)
|
|
70
|
+
if err != nil {
|
|
71
|
+
return identity{}, err
|
|
72
|
+
}
|
|
73
|
+
return identity{User: user, Groups: groups}, nil
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// sessionEnv is the complete environment authenticate.cgi sees: nothing from
|
|
77
|
+
// this process and no request header besides the session carriers.
|
|
78
|
+
func sessionEnv(r *http.Request, cookie string) []string {
|
|
79
|
+
token := r.Header.Get("X-SYNO-TOKEN")
|
|
80
|
+
if token == "" {
|
|
81
|
+
// A navigation or iframe cannot send the header; DSM's front end appends ?SynoToken= instead.
|
|
82
|
+
token = r.URL.Query().Get("SynoToken")
|
|
83
|
+
}
|
|
84
|
+
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
|
85
|
+
if err != nil {
|
|
86
|
+
host = r.RemoteAddr
|
|
87
|
+
}
|
|
88
|
+
return []string{
|
|
89
|
+
"REQUEST_METHOD=GET",
|
|
90
|
+
"HTTP_COOKIE=" + cookie,
|
|
91
|
+
"HTTP_X_SYNO_TOKEN=" + token,
|
|
92
|
+
"QUERY_STRING=SynoToken=" + url.QueryEscape(token),
|
|
93
|
+
"REMOTE_ADDR=" + host,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
func runCGI(ctx context.Context, path string, env []string) ([]byte, error) {
|
|
98
|
+
cmd := exec.CommandContext(ctx, path)
|
|
99
|
+
cmd.Env = env
|
|
100
|
+
return cmd.Output()
|
|
101
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"net/http"
|
|
7
|
+
"net/http/httptest"
|
|
8
|
+
"os"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"slices"
|
|
11
|
+
"strings"
|
|
12
|
+
"testing"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const groupFile = `root:x:0:
|
|
16
|
+
users:x:100:
|
|
17
|
+
administrators:x:101:admin,alice
|
|
18
|
+
staff:x:1030:alice,carol
|
|
19
|
+
http:x:1023:
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
// DSM keeps no member list for users: the group is every local account's primary group.
|
|
23
|
+
const passwdFile = `root:x:0:0::/root:/bin/sh
|
|
24
|
+
alice:x:1001:100::/var/services/homes/alice:/sbin/nologin
|
|
25
|
+
bob:x:1002:100::/var/services/homes/bob:/sbin/nologin
|
|
26
|
+
carol:x:1003:100::/var/services/homes/carol:/sbin/nologin
|
|
27
|
+
dave:x:1004:1030::/var/services/homes/dave:/sbin/nologin
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
type fakeRunner struct {
|
|
31
|
+
out string
|
|
32
|
+
err error
|
|
33
|
+
env []string
|
|
34
|
+
path string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func (f *fakeRunner) run(_ context.Context, path string, env []string) ([]byte, error) {
|
|
38
|
+
f.path, f.env = path, env
|
|
39
|
+
return []byte(f.out), f.err
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type exitError struct{}
|
|
43
|
+
|
|
44
|
+
func (*exitError) Error() string { return "exit status 1" }
|
|
45
|
+
func (*exitError) ExitCode() int { return 1 }
|
|
46
|
+
|
|
47
|
+
func newTestAuth(t *testing.T, runner *fakeRunner) *dsmAuthenticator {
|
|
48
|
+
t.Helper()
|
|
49
|
+
dir := t.TempDir()
|
|
50
|
+
groups, passwd := filepath.Join(dir, "group"), filepath.Join(dir, "passwd")
|
|
51
|
+
for path, content := range map[string]string{groups: groupFile, passwd: passwdFile} {
|
|
52
|
+
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
|
53
|
+
t.Fatal(err)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
a := newDSMAuthenticator()
|
|
57
|
+
a.groupFile, a.passwdFile = groups, passwd
|
|
58
|
+
a.run = runner.run
|
|
59
|
+
return a
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
func sessionRequest() *http.Request {
|
|
63
|
+
r := httptest.NewRequest(http.MethodGet, "/webman/3rdparty/App/cgi/gateway.cgi/", nil)
|
|
64
|
+
r.RemoteAddr = "192.0.2.7:51234"
|
|
65
|
+
r.Header.Set("Cookie", "id=abc; did=xyz")
|
|
66
|
+
r.Header.Set("X-SYNO-TOKEN", "tok+en/=")
|
|
67
|
+
r.Header.Set("User-Agent", "should-not-pass")
|
|
68
|
+
return r
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
func TestUserAndGroupsComeFromAuthenticateCGIAndGroupFile(t *testing.T) {
|
|
72
|
+
runner := &fakeRunner{out: "alice\n"}
|
|
73
|
+
id, err := newTestAuth(t, runner).Authenticate(sessionRequest())
|
|
74
|
+
if err != nil || id.User != "alice" {
|
|
75
|
+
t.Fatalf("got %+v, %v", id, err)
|
|
76
|
+
}
|
|
77
|
+
if want := []string{"users", "administrators", "staff"}; !slices.Equal(id.Groups, want) {
|
|
78
|
+
t.Errorf("groups = %v, want %v", id.Groups, want)
|
|
79
|
+
}
|
|
80
|
+
if runner.path != authenticateCGI {
|
|
81
|
+
t.Errorf("ran %q", runner.path)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func TestOrdinaryUserHasNoAdministratorsGroup(t *testing.T) {
|
|
86
|
+
id, err := newTestAuth(t, &fakeRunner{out: "bob\n"}).Authenticate(sessionRequest())
|
|
87
|
+
if err != nil || id.User != "bob" || slices.Contains(id.Groups, "administrators") {
|
|
88
|
+
t.Fatalf("got %+v, %v", id, err)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func TestPrimaryGroupCountsAsMembershipEvenWithoutAMemberListEntry(t *testing.T) {
|
|
93
|
+
id, err := newTestAuth(t, &fakeRunner{out: "bob\n"}).Authenticate(sessionRequest())
|
|
94
|
+
if err != nil || !slices.Equal(id.Groups, []string{"users"}) {
|
|
95
|
+
t.Fatalf("got %+v, %v", id, err)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func TestPrimaryGroupIsNotDuplicatedWhenAlsoListedAsMember(t *testing.T) {
|
|
100
|
+
a := newTestAuth(t, &fakeRunner{out: "dave"})
|
|
101
|
+
if err := os.WriteFile(a.groupFile, []byte("staff:x:1030:dave\n"), 0o644); err != nil {
|
|
102
|
+
t.Fatal(err)
|
|
103
|
+
}
|
|
104
|
+
id, _ := a.Authenticate(sessionRequest())
|
|
105
|
+
if !slices.Equal(id.Groups, []string{"staff"}) {
|
|
106
|
+
t.Fatalf("groups = %v", id.Groups)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
func TestMissingPasswdFileFailsClosedWithoutBeingNoSession(t *testing.T) {
|
|
111
|
+
a := newTestAuth(t, &fakeRunner{out: "bob"})
|
|
112
|
+
a.passwdFile = filepath.Join(t.TempDir(), "absent")
|
|
113
|
+
if _, err := a.Authenticate(sessionRequest()); err == nil || errors.Is(err, errNoSession) {
|
|
114
|
+
t.Fatalf("err = %v", err)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
func TestOnlySessionCarriersReachAuthenticateCGI(t *testing.T) {
|
|
119
|
+
runner := &fakeRunner{out: "alice"}
|
|
120
|
+
if _, err := newTestAuth(t, runner).Authenticate(sessionRequest()); err != nil {
|
|
121
|
+
t.Fatal(err)
|
|
122
|
+
}
|
|
123
|
+
want := []string{
|
|
124
|
+
"HTTP_COOKIE=id=abc; did=xyz",
|
|
125
|
+
"HTTP_X_SYNO_TOKEN=tok+en/=",
|
|
126
|
+
"QUERY_STRING=SynoToken=tok%2Ben%2F%3D",
|
|
127
|
+
"REMOTE_ADDR=192.0.2.7",
|
|
128
|
+
"REQUEST_METHOD=GET",
|
|
129
|
+
}
|
|
130
|
+
got := slices.Clone(runner.env)
|
|
131
|
+
slices.Sort(got)
|
|
132
|
+
if !slices.Equal(got, want) {
|
|
133
|
+
t.Fatalf("env = %q\nwant %q", got, want)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
func TestMissingCookieNeverRunsAuthenticateCGI(t *testing.T) {
|
|
138
|
+
runner := &fakeRunner{out: "alice"}
|
|
139
|
+
r := sessionRequest()
|
|
140
|
+
r.Header.Del("Cookie")
|
|
141
|
+
_, err := newTestAuth(t, runner).Authenticate(r)
|
|
142
|
+
if !errors.Is(err, errNoSession) || runner.path != "" {
|
|
143
|
+
t.Fatalf("err=%v ran=%q", err, runner.path)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
func TestExpiredOrMalformedSessionsAreNoSession(t *testing.T) {
|
|
148
|
+
for name, runner := range map[string]*fakeRunner{
|
|
149
|
+
"expired session (exit status)": {err: &exitError{}},
|
|
150
|
+
"empty output": {out: "\n"},
|
|
151
|
+
"two lines": {out: "alice\nadmin\n"},
|
|
152
|
+
"html output": {out: "<html>login</html>"},
|
|
153
|
+
"overlong name": {out: strings.Repeat("a", 200)},
|
|
154
|
+
"space in name": {out: "alice admin"},
|
|
155
|
+
} {
|
|
156
|
+
t.Run(name, func(t *testing.T) {
|
|
157
|
+
_, err := newTestAuth(t, runner).Authenticate(sessionRequest())
|
|
158
|
+
if !errors.Is(err, errNoSession) {
|
|
159
|
+
t.Fatalf("err = %v", err)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
func TestAuthenticateCGIThatCannotRunFailsClosedWithoutBeingNoSession(t *testing.T) {
|
|
166
|
+
_, err := newTestAuth(t, &fakeRunner{err: errors.New("fork/exec: no such file")}).Authenticate(sessionRequest())
|
|
167
|
+
if err == nil || errors.Is(err, errNoSession) {
|
|
168
|
+
t.Fatalf("err = %v", err)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
func TestGroupMembershipIsReadFreshOnEveryRequest(t *testing.T) {
|
|
173
|
+
runner := &fakeRunner{out: "carol"}
|
|
174
|
+
a := newTestAuth(t, runner)
|
|
175
|
+
id, _ := a.Authenticate(sessionRequest())
|
|
176
|
+
if !slices.Equal(id.Groups, []string{"users", "staff"}) {
|
|
177
|
+
t.Fatalf("groups = %v", id.Groups)
|
|
178
|
+
}
|
|
179
|
+
if err := os.WriteFile(a.groupFile, []byte("users:x:100:\nstaff:x:1030:alice\n"), 0o644); err != nil {
|
|
180
|
+
t.Fatal(err)
|
|
181
|
+
}
|
|
182
|
+
id, _ = a.Authenticate(sessionRequest())
|
|
183
|
+
if !slices.Equal(id.Groups, []string{"users"}) {
|
|
184
|
+
t.Fatalf("groups after removal = %v", id.Groups)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
func tokenEnv(t *testing.T, r *http.Request) []string {
|
|
189
|
+
t.Helper()
|
|
190
|
+
runner := &fakeRunner{out: "alice"}
|
|
191
|
+
if _, err := newTestAuth(t, runner).Authenticate(r); err != nil {
|
|
192
|
+
t.Fatal(err)
|
|
193
|
+
}
|
|
194
|
+
return runner.env
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
func TestQueryTokenIsUsedWhenHeaderIsEmpty(t *testing.T) {
|
|
198
|
+
r := sessionRequest()
|
|
199
|
+
r.Header.Del("X-SYNO-TOKEN")
|
|
200
|
+
r.URL.RawQuery = "a=b&SynoToken=q%2Btok"
|
|
201
|
+
env := tokenEnv(t, r)
|
|
202
|
+
for _, want := range []string{"HTTP_X_SYNO_TOKEN=q+tok", "QUERY_STRING=SynoToken=q%2Btok"} {
|
|
203
|
+
if !slices.Contains(env, want) {
|
|
204
|
+
t.Fatalf("env = %q, missing %q", env, want)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
func TestHeaderTokenWinsOverQueryToken(t *testing.T) {
|
|
210
|
+
r := sessionRequest()
|
|
211
|
+
r.URL.RawQuery = "SynoToken=from-query"
|
|
212
|
+
env := tokenEnv(t, r)
|
|
213
|
+
if !slices.Contains(env, "HTTP_X_SYNO_TOKEN=tok+en/=") || slices.Contains(env, "QUERY_STRING=SynoToken=from-query") {
|
|
214
|
+
t.Fatalf("env = %q", env)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bufio"
|
|
5
|
+
"bytes"
|
|
6
|
+
"errors"
|
|
7
|
+
"fmt"
|
|
8
|
+
"io"
|
|
9
|
+
"net"
|
|
10
|
+
"net/http"
|
|
11
|
+
"time"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// serveCGI answers one request the way net/http/cgi.Serve does: "Status:" and headers, a blank line, the body
|
|
15
|
+
// on `out`. It is its own copy so that the reply can be hijacked: the handler then owns `in` and `out`, which
|
|
16
|
+
// is how a WebSocket passes through DSM's CGI interface.
|
|
17
|
+
func serveCGI(h http.Handler, req *http.Request, in io.Reader, out io.Writer) error {
|
|
18
|
+
if req.Body == nil {
|
|
19
|
+
req.Body = http.NoBody
|
|
20
|
+
}
|
|
21
|
+
rw := &cgiResponse{req: req, header: make(http.Header), in: in, out: out, bufw: bufio.NewWriter(out)}
|
|
22
|
+
h.ServeHTTP(rw, req)
|
|
23
|
+
if rw.hijacked {
|
|
24
|
+
return nil
|
|
25
|
+
}
|
|
26
|
+
rw.Write(nil) // make sure a reply is sent
|
|
27
|
+
return rw.bufw.Flush()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type cgiResponse struct {
|
|
31
|
+
req *http.Request
|
|
32
|
+
header http.Header
|
|
33
|
+
code int
|
|
34
|
+
wroteHeader bool
|
|
35
|
+
wroteCGI bool
|
|
36
|
+
hijacked bool
|
|
37
|
+
in io.Reader
|
|
38
|
+
out io.Writer
|
|
39
|
+
bufw *bufio.Writer
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func (r *cgiResponse) Header() http.Header { return r.header }
|
|
43
|
+
|
|
44
|
+
func (r *cgiResponse) Flush() {
|
|
45
|
+
if !r.hijacked {
|
|
46
|
+
r.bufw.Flush()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func (r *cgiResponse) WriteHeader(code int) {
|
|
51
|
+
if r.wroteHeader {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
r.wroteHeader, r.code = true, code
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
func (r *cgiResponse) Write(p []byte) (int, error) {
|
|
58
|
+
if r.hijacked {
|
|
59
|
+
return 0, http.ErrHijacked
|
|
60
|
+
}
|
|
61
|
+
if !r.wroteHeader {
|
|
62
|
+
r.WriteHeader(http.StatusOK)
|
|
63
|
+
}
|
|
64
|
+
if !r.wroteCGI {
|
|
65
|
+
r.writeCGIHeader(p)
|
|
66
|
+
}
|
|
67
|
+
return r.bufw.Write(p)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// writeCGIHeader sends the header block; p, the first chunk of the body, is sniffed for a missing Content-Type.
|
|
71
|
+
func (r *cgiResponse) writeCGIHeader(p []byte) {
|
|
72
|
+
r.wroteCGI = true
|
|
73
|
+
fmt.Fprintf(r.bufw, "Status: %d %s\r\n", r.code, http.StatusText(r.code))
|
|
74
|
+
if _, hasType := r.header["Content-Type"]; !hasType {
|
|
75
|
+
r.header.Set("Content-Type", http.DetectContentType(p))
|
|
76
|
+
}
|
|
77
|
+
r.header.Write(r.bufw)
|
|
78
|
+
r.bufw.WriteString("\r\n")
|
|
79
|
+
r.bufw.Flush()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Hijack hands stdin and stdout to the handler. The first thing it writes is an HTTP/1.1 status line and
|
|
83
|
+
// headers (that is what httputil.ReverseProxy writes for a 101); the CGI interface wants "Status: 101 ..."
|
|
84
|
+
// there, so cgiConn rewrites the status line and leaves everything after the blank line alone.
|
|
85
|
+
func (r *cgiResponse) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|
86
|
+
if r.wroteHeader || r.wroteCGI || r.hijacked {
|
|
87
|
+
return nil, nil, errors.New("cgi: Hijack after the reply began")
|
|
88
|
+
}
|
|
89
|
+
r.hijacked = true
|
|
90
|
+
c := &cgiConn{in: r.in, out: r.out}
|
|
91
|
+
return c, bufio.NewReadWriter(bufio.NewReader(c), bufio.NewWriter(c)), nil
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type cgiConn struct {
|
|
95
|
+
in io.Reader
|
|
96
|
+
out io.Writer
|
|
97
|
+
head []byte // the header block, held back until it is complete
|
|
98
|
+
headSent bool
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
func (c *cgiConn) Read(p []byte) (int, error) { return c.in.Read(p) }
|
|
102
|
+
|
|
103
|
+
func (c *cgiConn) Write(p []byte) (int, error) {
|
|
104
|
+
if c.headSent {
|
|
105
|
+
return c.out.Write(p)
|
|
106
|
+
}
|
|
107
|
+
c.head = append(c.head, p...)
|
|
108
|
+
end := bytes.Index(c.head, []byte("\r\n\r\n"))
|
|
109
|
+
if end < 0 {
|
|
110
|
+
return len(p), nil
|
|
111
|
+
}
|
|
112
|
+
c.headSent = true
|
|
113
|
+
statusLine, headers, _ := bytes.Cut(c.head[:end+4], []byte("\r\n"))
|
|
114
|
+
_, status, _ := bytes.Cut(statusLine, []byte(" ")) // "HTTP/1.1 101 Switching Protocols" -> "101 Switching Protocols"
|
|
115
|
+
rewritten := append(append([]byte("Status: "), status...), "\r\n"...)
|
|
116
|
+
rewritten = append(append(rewritten, headers...), c.head[end+4:]...)
|
|
117
|
+
if _, err := c.out.Write(rewritten); err != nil {
|
|
118
|
+
return 0, err
|
|
119
|
+
}
|
|
120
|
+
return len(p), nil
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
func (c *cgiConn) Close() error { return nil }
|
|
124
|
+
func (c *cgiConn) LocalAddr() net.Addr { return cgiAddr{} }
|
|
125
|
+
func (c *cgiConn) RemoteAddr() net.Addr { return cgiAddr{} }
|
|
126
|
+
func (c *cgiConn) SetDeadline(time.Time) error { return nil }
|
|
127
|
+
func (c *cgiConn) SetReadDeadline(time.Time) error { return nil }
|
|
128
|
+
func (c *cgiConn) SetWriteDeadline(time.Time) error { return nil }
|
|
129
|
+
|
|
130
|
+
type cgiAddr struct{}
|
|
131
|
+
|
|
132
|
+
func (cgiAddr) Network() string { return "cgi" }
|
|
133
|
+
func (cgiAddr) String() string { return "cgi" }
|