@synopackageland/cli 0.51.0 → 0.52.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/CHANGELOG.md +7 -0
- package/README.md +7 -0
- package/assets/go/route-audit/main.go +23 -6
- package/dist/cli.js +9 -1
- package/dist/error-registry.js +10 -0
- package/dist/native-http-schema/source.json +1 -1
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/skill.js +1 -0
- package/dist/standalone/api-description.js +2 -1
- package/dist/standalone/build.js +5 -2
- package/dist/standalone/inspect-spk.d.ts +3 -0
- package/dist/standalone/inspect-spk.js +11 -0
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +21 -1
- package/dist/standalone/route-audit.d.ts +1 -1
- package/dist/standalone/route-audit.js +2 -2
- package/dist/standalone/spk.js +1 -0
- package/dist/standalone/tcp-listeners.d.ts +11 -0
- package/dist/standalone/tcp-listeners.js +57 -0
- package/package.json +1 -1
- package/schema/dsm-api-contract.json +1 -1
- package/schema/dsm-package.schema.json +16 -0
- package/skills/SKILL.md +2 -0
- package/skills/reference/dsm-texts.md +2 -2
- package/skills/reference/raw-tcp.md +66 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.52.0
|
|
4
|
+
|
|
5
|
+
- Add declarative `tcp_listeners` for native Go protocols, validating listener IDs, bind scopes, port bounds, and SDK policy support
|
|
6
|
+
- Bind the normalized TCP policy into CGI and worker builds; reject undeclared or dynamic listener IDs and constructor aliases during route audit
|
|
7
|
+
- Show archived TCP listener declarations in `inspect` and add `synopkgland skill show raw-tcp`
|
|
8
|
+
- Pin CLI-owned SDK defaults to 0.53.0; preserve declarative DSM text sections and their inspection and skill guidance
|
|
9
|
+
|
|
3
10
|
## 0.51.0
|
|
4
11
|
|
|
5
12
|
- Add declarative `i18n.dsm_texts`: per-locale DSM strings files become native DSM text sections (for example `[notify]`) in the package, validated against English with matching keys and placeholders; `[synopkgland]` stays reserved
|
package/README.md
CHANGED
|
@@ -717,3 +717,10 @@ all declared locales, keys and placeholder parity; `build` adds the keys to
|
|
|
717
717
|
`ui/config` preload lists. `inspect --json <SPK>` reports archived `nativeTexts`
|
|
718
718
|
sections and keys per DSM language. See `synopkgland skill show dsm-texts` and
|
|
719
719
|
[the format and evidence notes](skills/reference/dsm-texts.md).
|
|
720
|
+
|
|
721
|
+
### Raw TCP protocols
|
|
722
|
+
|
|
723
|
+
Declare `tcp_listeners` for a native Go protocol listener, then call
|
|
724
|
+
`ipc.ListenTCP(ctx, "declared_id", port)` directly. `check` validates bind scope,
|
|
725
|
+
port bounds and SDK policy support; audit rejects undeclared/dynamic IDs and
|
|
726
|
+
constructor aliases. See `synopkgland skill show raw-tcp`.
|
|
@@ -19,11 +19,12 @@ import (
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
type input struct {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
TCPListeners []string
|
|
23
|
+
Dir string
|
|
24
|
+
Roots []string
|
|
25
|
+
Arches []string
|
|
26
|
+
Permissions map[string]string
|
|
27
|
+
SDK map[string]map[string]string
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
type result struct {
|
|
@@ -607,7 +608,7 @@ func main() {
|
|
|
607
608
|
}
|
|
608
609
|
if module == sdkModule+"/ipc" && !direct[selector] {
|
|
609
610
|
switch name {
|
|
610
|
-
case "ServeUnix", "StartUnix", "ServePeerUnix", "StartPeerUnix", "StartPackagePeerUnix", "DialUnix", "DialPeerUnix", "ReserveLoopback", "ProbeLoopback":
|
|
611
|
+
case "ServeUnix", "StartUnix", "ServePeerUnix", "StartPeerUnix", "StartPackagePeerUnix", "DialUnix", "DialPeerUnix", "ReserveLoopback", "ProbeLoopback", "ListenTCP":
|
|
611
612
|
problem(selector.Pos(), "IPC constructor aliases cannot be audited")
|
|
612
613
|
}
|
|
613
614
|
}
|
|
@@ -655,6 +656,22 @@ func main() {
|
|
|
655
656
|
if !ok {
|
|
656
657
|
return true
|
|
657
658
|
}
|
|
659
|
+
if pkg, ok := selector.X.(*ast.Ident); ok && imports[pkg.Name] == sdkModule+"/ipc" && selector.Sel.Name == "ListenTCP" {
|
|
660
|
+
id := ""
|
|
661
|
+
if len(call.Args) == 3 {
|
|
662
|
+
id = stringLiteral(call.Args[1])
|
|
663
|
+
}
|
|
664
|
+
declared := false
|
|
665
|
+
for _, name := range in.TCPListeners {
|
|
666
|
+
if id != "" && name == id {
|
|
667
|
+
declared = true
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if !declared {
|
|
671
|
+
problem(call.Pos(), "ipc.ListenTCP requires a literal declared tcp_listeners ID and three arguments")
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
658
675
|
// An in-process administrator call names one fixed route that
|
|
659
676
|
// already requires DSM administrators; the SDK verifies the account.
|
|
660
677
|
if selector.Sel.Name == "InvokeAsAdministrator" {
|
package/dist/cli.js
CHANGED
|
@@ -371,7 +371,15 @@ async function runCliWithin(argv) {
|
|
|
371
371
|
const policy = options.permissions
|
|
372
372
|
? parseApiPermissions(readFileSync(resolve(dir, options.permissions)))
|
|
373
373
|
: { schema: 1, default: "administrators", methods: {} };
|
|
374
|
-
const
|
|
374
|
+
const root = findStandaloneRoot(dir);
|
|
375
|
+
let listeners = [];
|
|
376
|
+
if (root) {
|
|
377
|
+
const loaded = loadStandaloneManifest(root);
|
|
378
|
+
if (!loaded.ok)
|
|
379
|
+
throw Error(loaded.errors.map(e => e.message).join('\n'));
|
|
380
|
+
listeners = Object.keys(loaded.manifest.tcpListeners ?? {});
|
|
381
|
+
}
|
|
382
|
+
const audit = auditGoRoutes(dir, policy, {}, [main], arches, listeners);
|
|
375
383
|
const ok = audit.problems.length === 0;
|
|
376
384
|
if (json)
|
|
377
385
|
stdout(JSON.stringify({ ok, ...audit }));
|
package/dist/error-registry.js
CHANGED
|
@@ -713,6 +713,16 @@ export const ERROR_REGISTRY = {
|
|
|
713
713
|
description: "An image login_style names is missing, in the wrong format or the wrong size.",
|
|
714
714
|
suggestion: "Use a JPEG wallpaper of at least 1920x1080 and at most 2 MiB, a 320x200 JPEG wallpaper_thumbnail and a 680x124 PNG title, inside the project.",
|
|
715
715
|
},
|
|
716
|
+
STANDALONE_TCP_LISTENERS_INVALID: {
|
|
717
|
+
code: "STANDALONE_TCP_LISTENERS_INVALID",
|
|
718
|
+
description: "A raw TCP listener declaration has invalid names, fields, scopes or port bounds.",
|
|
719
|
+
suggestion: "Declare tcp_listeners.<id> with port 1024..65535, scope loopback (default) or all, and optional port_range: [min,max] including port.",
|
|
720
|
+
},
|
|
721
|
+
STANDALONE_TCP_LISTENERS_UNSUPPORTED: {
|
|
722
|
+
code: "STANDALONE_TCP_LISTENERS_UNSUPPORTED",
|
|
723
|
+
description: "The backend SDK does not support the build-bound raw TCP listener policy.",
|
|
724
|
+
suggestion: "Use a native Go backend and an SDK with ipc.ListenTCP policy v1; SYNOPKGLAND_SDK_DIR may select a local SDK branch for development.",
|
|
725
|
+
},
|
|
716
726
|
STANDALONE_I18N_INVALID: {
|
|
717
727
|
code: "STANDALONE_I18N_INVALID",
|
|
718
728
|
description: "The i18n configuration in dsm-package.yaml is invalid.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"
|
|
1
|
+
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"development","local":true}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { goPrivateCovers } from './go-env.js';
|
|
2
2
|
import { type ExecutorManifest } from './sdk-executor-manifest.js';
|
|
3
3
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
4
|
-
export declare const DEFAULT_SDK_VERSION = "0.
|
|
4
|
+
export declare const DEFAULT_SDK_VERSION = "0.53.0";
|
|
5
5
|
export declare const SDK_PACKAGE = "@synopackageland/sdk";
|
|
6
6
|
export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
|
|
7
7
|
export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
|
|
7
7
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
8
|
-
export const DEFAULT_SDK_VERSION = '0.
|
|
8
|
+
export const DEFAULT_SDK_VERSION = '0.53.0';
|
|
9
9
|
export const SDK_PACKAGE = '@synopackageland/sdk';
|
|
10
10
|
export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
|
|
11
11
|
export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
|
package/dist/skill.js
CHANGED
|
@@ -33,6 +33,7 @@ const SKILL_CATALOG = [
|
|
|
33
33
|
when: "Needs a DSM sign-in",
|
|
34
34
|
},
|
|
35
35
|
{ id: "dsm-texts", file: "reference/dsm-texts.md", when: "Ship native DSM sections and fixed desktop notification strings" },
|
|
36
|
+
{ id: "raw-tcp", file: "reference/raw-tcp.md", when: "Declare raw TCP protocol listeners and their bind/port boundary" },
|
|
36
37
|
{ id: "mobile", file: "reference/mobile.md", when: "Register an App for the mobile shell and generate its SDK entry page" },
|
|
37
38
|
{ id: "files", file: "reference/files.md", when: "Needs NAS files" },
|
|
38
39
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tcpPolicyFlag } from "./tcp-listeners.js";
|
|
1
2
|
import { portalByExecutor } from '../build-spk/dsm-version.js';
|
|
2
3
|
import { generateOperations } from './operation-registry.js';
|
|
3
4
|
import { readFileSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
@@ -49,7 +50,7 @@ export async function describeApiRoutes(m, bridgeMethods, run) {
|
|
|
49
50
|
else {
|
|
50
51
|
if (!readFileSync(join(m.backend.dir, m.backend.main, 'main.go'), 'utf8').includes('--describe'))
|
|
51
52
|
throw new StandaloneBuildError('CTL_DESCRIBE_REQUIRED', 'Go CGI must support build-only --describe; update its template.');
|
|
52
|
-
const flags = [`-X github.com/synopackageland/syno-pkg-land-sdk/api.expectedEntryMode=${m.entry ?? ''}`, `-X main.packageID=${m.package}`, `-X main.version=${m.spkVersion}`, ...(m.capabilities.files || m.capabilities.delegate ? ['-X main.fileStation=session'] : []), ...(m.portal ? [`-X main.portal=${portalByExecutor(m.os_min_ver) ? 'executor' : 'on'}`] : [])].join(' ');
|
|
53
|
+
const flags = [...tcpPolicyFlag(m), `-X github.com/synopackageland/syno-pkg-land-sdk/ipc.packageID=${m.package}`, `-X github.com/synopackageland/syno-pkg-land-sdk/api.expectedEntryMode=${m.entry ?? ''}`, `-X main.packageID=${m.package}`, `-X main.version=${m.spkVersion}`, ...(m.capabilities.files || m.capabilities.delegate ? ['-X main.fileStation=session'] : []), ...(m.portal ? [`-X main.portal=${portalByExecutor(m.os_min_ver) ? 'executor' : 'on'}`] : [])].join(' ');
|
|
53
54
|
const response = await run('go', ['run', '-trimpath', '-buildvcs=false', '-ldflags', flags, m.backend.main, '--describe'], { cwd: m.backend.dir, env: goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, CGO_ENABLED: '0' }), capture: true });
|
|
54
55
|
if (response.status !== 0)
|
|
55
56
|
throw new StandaloneBuildError('CTL_DESCRIBE_FAILED', 'Go route metadata export failed.');
|
package/dist/standalone/build.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tcpPolicyFlag } from "./tcp-listeners.js";
|
|
1
2
|
import { buildInstallSettings } from './install-settings.js';
|
|
2
3
|
import { enforceRepositorySecrets } from "../secret-files.js";
|
|
3
4
|
import { buildAppBackup } from './hyper-backup.js';
|
|
@@ -244,7 +245,7 @@ async function buildGoCgi(manifest, backend, arch, work, run) {
|
|
|
244
245
|
throw new StandaloneBuildError("STANDALONE_API_PERMISSIONS_CHANGED", "API permissions changed during build; check and rebuild.");
|
|
245
246
|
}
|
|
246
247
|
const policy = readApiPermissions(backend, manifest.capabilities);
|
|
247
|
-
const audit = auditGoRoutes(backend.dir, policy.policy, policy.sdk, [backend.main], [goBuildEnv(arch).GOARCH]);
|
|
248
|
+
const audit = auditGoRoutes(backend.dir, policy.policy, policy.sdk, [backend.main], [goBuildEnv(arch).GOARCH], Object.keys(manifest.tcpListeners ?? {}));
|
|
248
249
|
if (audit.problems.length || manifest.entry && !audit.entryGate) {
|
|
249
250
|
throw new StandaloneBuildError("STANDALONE_API_REGISTRY_INVALID", audit.problems.join("\n") || "App entry gate was removed during build.");
|
|
250
251
|
}
|
|
@@ -264,6 +265,7 @@ async function buildGoCgi(manifest, backend, arch, work, run) {
|
|
|
264
265
|
`-X ${SDK_MODULE}/api.expectedPermissionsDigest=${manifest.apiPermissionsDigest}`,
|
|
265
266
|
`-X ${SDK_MODULE}/api.expectedHTTPRoutesDigest=${httpRoutesDigest(audit)}`,
|
|
266
267
|
`-X ${SDK_MODULE}/ipc.packageID=${manifest.package}`,
|
|
268
|
+
...tcpPolicyFlag(manifest),
|
|
267
269
|
`-X ${SDK_MODULE}/ipc.executorTier=none`,
|
|
268
270
|
...(manifest.entry ? [`-X ${SDK_MODULE}/api.expectedEntryMode=${manifest.entry}`] : []),
|
|
269
271
|
...delegateBuildFlags(manifest),
|
|
@@ -317,7 +319,7 @@ async function buildBackgroundWorker(manifest, arch, work, run) {
|
|
|
317
319
|
return undefined;
|
|
318
320
|
const out = join(work, `background-worker-${arch}`);
|
|
319
321
|
const policy = readApiPermissions(manifest.backend, manifest.capabilities);
|
|
320
|
-
const audit = auditGoRoutes(manifest.backend.dir, policy.policy, policy.sdk, [BACKGROUND_WORKER_MAIN], [goBuildEnv(arch).GOARCH]);
|
|
322
|
+
const audit = auditGoRoutes(manifest.backend.dir, policy.policy, policy.sdk, [BACKGROUND_WORKER_MAIN], [goBuildEnv(arch).GOARCH], Object.keys(manifest.tcpListeners ?? {}));
|
|
321
323
|
if (audit.problems.length)
|
|
322
324
|
throw new StandaloneBuildError("STANDALONE_API_REGISTRY_INVALID", audit.problems.join("\n"));
|
|
323
325
|
const ldflags = [
|
|
@@ -326,6 +328,7 @@ async function buildBackgroundWorker(manifest, arch, work, run) {
|
|
|
326
328
|
"-buildid=",
|
|
327
329
|
`-X main.packageID=${manifest.package}`,
|
|
328
330
|
`-X ${SDK_MODULE}/ipc.packageID=${manifest.package}`,
|
|
331
|
+
...tcpPolicyFlag(manifest),
|
|
329
332
|
`-X ${SDK_MODULE}/ipc.executorTier=none`,
|
|
330
333
|
`-X ${SDK_MODULE}/api.expectedHTTPRoutesDigest=${httpRoutesDigest(audit)}`,
|
|
331
334
|
`-X ${SDK_MODULE}/api.expectedPermissionsDigest=${manifest.apiPermissionsDigest}`,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TCPListeners } from "./tcp-listeners.js";
|
|
1
2
|
import { type PackageDependencies } from "./package-dependencies.js";
|
|
2
3
|
import { type InstallSettings } from './install-settings.js';
|
|
3
4
|
import { type WebLaunchMode } from "../contract/web-launch.js";
|
|
@@ -13,6 +14,8 @@ export type SpkKind = "native-go" | "native-python" | "native-node" | "native-ru
|
|
|
13
14
|
export interface SpkInspection {
|
|
14
15
|
/** Archived DSM language -> native section -> sorted keys (no text values). */
|
|
15
16
|
nativeTexts?: Record<string, Record<string, string[]>>;
|
|
17
|
+
/** Manifest policy recorded at build time; not proof of runtime listener health. */
|
|
18
|
+
tcpListeners?: TCPListeners;
|
|
16
19
|
dependencies?: PackageDependencies;
|
|
17
20
|
installSettings?: InstallSettings;
|
|
18
21
|
/** Hyper Backup application backup, as sdk-package.json records it. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseDsmStrings } from "./dsm-texts.js";
|
|
2
|
+
import { readTCPListeners } from "./tcp-listeners.js";
|
|
2
3
|
import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
|
|
3
4
|
import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
|
|
4
5
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
@@ -157,6 +158,15 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
157
158
|
findings.push("sdk-package.json does not match the schema 2 capability inventory.");
|
|
158
159
|
}
|
|
159
160
|
}
|
|
161
|
+
let tcpListeners;
|
|
162
|
+
try {
|
|
163
|
+
tcpListeners = readTCPListeners(metadata.tcp_listeners);
|
|
164
|
+
if (tcpListeners && metadata.backend !== "go")
|
|
165
|
+
throw Error("tcp_listeners requires a native Go backend");
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
findings.push(`STANDALONE_TCP_LISTENERS_INVALID ${error.message}`);
|
|
169
|
+
}
|
|
160
170
|
const dependencies = inspectPackageDependencies(metadata.dependencies, findings);
|
|
161
171
|
const daemonNoFile = readNoFile(metadata.daemon_nofile, e => findings.push(e.message));
|
|
162
172
|
if (metadata.daemon_nofile !== undefined)
|
|
@@ -347,6 +357,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
347
357
|
...(dependencies ? { dependencies } : {}),
|
|
348
358
|
kind,
|
|
349
359
|
...(nativeTexts ? { nativeTexts } : {}),
|
|
360
|
+
...(tcpListeners ? { tcpListeners } : {}),
|
|
350
361
|
...(identityGateway ? { identityGateway } : {}),
|
|
351
362
|
...(gateway ? { gateway } : {}),
|
|
352
363
|
...(installSettings ? { installSettings } : {}),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type NativeTexts } from "./dsm-texts.js";
|
|
2
|
+
import { type TCPListeners } from "./tcp-listeners.js";
|
|
2
3
|
import { type MobileDeclaration } from './mobile.js';
|
|
3
4
|
import { type PackageDependencies } from "./package-dependencies.js";
|
|
4
5
|
import { type InstallSettings } from './install-settings.js';
|
|
@@ -49,6 +50,7 @@ export interface StandaloneI18n {
|
|
|
49
50
|
info: InfoTranslations;
|
|
50
51
|
}
|
|
51
52
|
export interface StandaloneManifest {
|
|
53
|
+
tcpListeners?: TCPListeners;
|
|
52
54
|
/** Exact payload paths exempted from the SPK secret guard, never repository checks. */
|
|
53
55
|
allowSecretFiles?: string[];
|
|
54
56
|
ctl?: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loadNativeTexts } from "./dsm-texts.js";
|
|
2
|
+
import { readTCPListeners, tcpSDKProblem } from "./tcp-listeners.js";
|
|
2
3
|
import { validateNativeManifest } from './native-http.js';
|
|
3
4
|
import { readMobile, mobileIconPath } from './mobile.js';
|
|
4
5
|
import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM, DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM } from './daemon-nofile.js';
|
|
@@ -50,6 +51,7 @@ import { BRIDGE_RUNTIMES, isBridgeBackend, overlaps, readBridgeBackend, } from "
|
|
|
50
51
|
*/
|
|
51
52
|
export const STANDALONE_MANIFEST = "dsm-package.yaml";
|
|
52
53
|
export const KNOWN_FIELDS = new Set([
|
|
54
|
+
"tcp_listeners",
|
|
53
55
|
"allow_secret_files",
|
|
54
56
|
"ctl",
|
|
55
57
|
"schema",
|
|
@@ -440,12 +442,29 @@ function readManifest(raw, c) {
|
|
|
440
442
|
c.fail("STANDALONE_ENTRY_UNSUPPORTED", "The SDK entry floor source is unavailable; update the SDK and retry.");
|
|
441
443
|
}
|
|
442
444
|
}
|
|
445
|
+
let tcpListeners;
|
|
446
|
+
if (raw.tcp_listeners !== undefined) {
|
|
447
|
+
try {
|
|
448
|
+
tcpListeners = readTCPListeners(raw.tcp_listeners);
|
|
449
|
+
const problem = backend ? tcpSDKProblem(backend) : "tcp_listeners requires a native Go backend.";
|
|
450
|
+
if (problem)
|
|
451
|
+
c.fail("STANDALONE_TCP_LISTENERS_UNSUPPORTED", problem);
|
|
452
|
+
const occupied = Object.values(identityGateway?.listen ?? {}).concat(identityGateway?.oidc ? [identityGateway.oidc.issuer_port] : []);
|
|
453
|
+
for (const [id, listener] of Object.entries(tcpListeners ?? {})) {
|
|
454
|
+
if (occupied.includes(listener.port))
|
|
455
|
+
c.fail("STANDALONE_TCP_LISTENERS_INVALID", `tcp_listeners.${id}.port conflicts with an identity_gateway default port.`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
c.fail("STANDALONE_TCP_LISTENERS_INVALID", error.message);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
443
462
|
if (backend?.kind === "go" && permissions && sdkVersionOrUndefined(backend) && (raw.entry === undefined || entry)) {
|
|
444
463
|
try {
|
|
445
464
|
const problems = new Set();
|
|
446
465
|
for (const main of [backend.main, ...(capabilities.jobs ? [BACKGROUND_WORKER_MAIN] : [])]) {
|
|
447
466
|
for (const arch of arches ?? []) {
|
|
448
|
-
const audit = auditGoRoutes(backend.dir, permissions.policy, permissions.sdk, [main], [({ x86_64: 'amd64', aarch64: 'arm64', armv7: 'arm' })[arch]]);
|
|
467
|
+
const audit = auditGoRoutes(backend.dir, permissions.policy, permissions.sdk, [main], [({ x86_64: 'amd64', aarch64: 'arm64', armv7: 'arm' })[arch]], Object.keys(tcpListeners ?? {}));
|
|
449
468
|
for (const problem of audit.problems)
|
|
450
469
|
problems.add(problem);
|
|
451
470
|
if (main === backend.main && entry && !audit.entryGate)
|
|
@@ -637,6 +656,7 @@ function readManifest(raw, c) {
|
|
|
637
656
|
}
|
|
638
657
|
: {}),
|
|
639
658
|
ui,
|
|
659
|
+
...(tcpListeners ? { tcpListeners } : {}),
|
|
640
660
|
...(i18n ? { i18n } : {}),
|
|
641
661
|
capabilities,
|
|
642
662
|
...(rootOps ? { rootOps } : {}),
|
|
@@ -9,4 +9,4 @@ export interface RouteAudit {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function httpRoutesDigest(audit: RouteAudit): string;
|
|
11
11
|
/** Parse Go syntax without executing an App's main, init functions or --describe. */
|
|
12
|
-
export declare function auditGoRoutes(dir: string, policy: ApiPermissions, sdk: Record<string, Record<string, string>>, roots?: string[], arches?: string[]): RouteAudit;
|
|
12
|
+
export declare function auditGoRoutes(dir: string, policy: ApiPermissions, sdk: Record<string, Record<string, string>>, roots?: string[], arches?: string[], tcpListeners?: string[]): RouteAudit;
|
|
@@ -10,7 +10,7 @@ export function httpRoutesDigest(audit) {
|
|
|
10
10
|
return createHash('sha256').update(JSON.stringify(audit.httpRoutes)).digest('hex');
|
|
11
11
|
}
|
|
12
12
|
/** Parse Go syntax without executing an App's main, init functions or --describe. */
|
|
13
|
-
export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64', 'arm64', 'arm']) {
|
|
13
|
+
export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64', 'arm64', 'arm'], tcpListeners = []) {
|
|
14
14
|
const env = goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, GOWORK: 'off', CGO_ENABLED: '0' });
|
|
15
15
|
if (!binary) {
|
|
16
16
|
const work = mkdtempSync(join(tmpdir(), 'synopkgland-route-audit-'));
|
|
@@ -22,7 +22,7 @@ export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64'
|
|
|
22
22
|
throw new Error('Cannot build the Go route auditor; install Go and retry.');
|
|
23
23
|
binary = out;
|
|
24
24
|
}
|
|
25
|
-
const result = spawnSync(binary, [], { env, input: JSON.stringify({ Dir: realpathSync(dir), Roots: roots, Arches: arches, Permissions: policy.methods, SDK: sdk }), encoding: 'utf8', timeout: 120_000, maxBuffer: 4 << 20 });
|
|
25
|
+
const result = spawnSync(binary, [], { env, input: JSON.stringify({ Dir: realpathSync(dir), Roots: roots, Arches: arches, Permissions: policy.methods, SDK: sdk, TCPListeners: tcpListeners }), encoding: 'utf8', timeout: 120_000, maxBuffer: 4 << 20 });
|
|
26
26
|
if (result.error || result.status !== 0)
|
|
27
27
|
throw new Error(`Cannot audit Go routes: ${result.stderr?.trim() || 'auditor unavailable'}`);
|
|
28
28
|
return JSON.parse(result.stdout);
|
package/dist/standalone/spk.js
CHANGED
|
@@ -278,6 +278,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
278
278
|
.digest("hex");
|
|
279
279
|
writeFile(join(staging, "sdk-package.json"), JSON.stringify({
|
|
280
280
|
schema: 2,
|
|
281
|
+
...(manifest.tcpListeners ? { tcp_listeners: manifest.tcpListeners } : {}),
|
|
281
282
|
...(mobile ? { mobile: mobile.record } : {}),
|
|
282
283
|
dependencies: packageDependencies(manifest),
|
|
283
284
|
...(moduleVersion ? { ui_module: moduleVersion } : {}),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StandaloneBackend, StandaloneManifest } from './manifest.js';
|
|
2
|
+
export interface TCPListener {
|
|
3
|
+
scope: 'loopback' | 'all';
|
|
4
|
+
port: number;
|
|
5
|
+
port_range?: [number, number];
|
|
6
|
+
}
|
|
7
|
+
export type TCPListeners = Record<string, TCPListener>;
|
|
8
|
+
/** Normalize once for audit, linker flags and the archived declaration. */
|
|
9
|
+
export declare function readTCPListeners(raw: unknown): TCPListeners | undefined;
|
|
10
|
+
export declare function tcpSDKProblem(backend: StandaloneBackend): string | undefined;
|
|
11
|
+
export declare function tcpPolicyFlag(m: Pick<StandaloneManifest, 'tcpListeners'>): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { appSdkVersion, sdkSource } from '../runtime/sdk-source.js';
|
|
4
|
+
const ID = /^[a-z][a-z0-9_]{0,63}$/;
|
|
5
|
+
function record(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|
|
6
|
+
/** Normalize once for audit, linker flags and the archived declaration. */
|
|
7
|
+
export function readTCPListeners(raw) {
|
|
8
|
+
if (raw === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
const invalid = (why) => { throw Error('tcp_listeners ' + why); };
|
|
11
|
+
if (!record(raw) || Object.keys(raw).length === 0 || Object.keys(raw).length > 64)
|
|
12
|
+
invalid('must declare between 1 and 64 named listeners.');
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const id of Object.keys(raw).sort()) {
|
|
15
|
+
const value = raw[id];
|
|
16
|
+
if (!ID.test(id) || !record(value) || Object.keys(value).some(k => !['scope', 'port', 'port_range'].includes(k)))
|
|
17
|
+
invalid(`${id}: use a lowercase letter followed by lowercase letters, digits or underscores (max 64); accepted fields: scope, port, port_range.`);
|
|
18
|
+
const v = value;
|
|
19
|
+
const scope = v.scope === undefined ? 'loopback' : v.scope;
|
|
20
|
+
if (scope !== 'loopback' && scope !== 'all')
|
|
21
|
+
invalid(`${id}.scope must be loopback (default, 127.0.0.1) or explicit all (0.0.0.0), IPv4 only.`);
|
|
22
|
+
if (!Number.isInteger(v.port) || Number(v.port) < 1024 || Number(v.port) > 65535)
|
|
23
|
+
invalid(`${id}.port must be an integer from 1024 to 65535.`);
|
|
24
|
+
const range = v.port_range;
|
|
25
|
+
if (range !== undefined && (!Array.isArray(range) || range.length !== 2 || range.some(p => !Number.isInteger(p) || p < 1024 || p > 65535) || range[0] > range[1] || Number(v.port) < range[0] || Number(v.port) > range[1]))
|
|
26
|
+
invalid(`${id}.port_range must be [min,max] within 1024..65535 and include port; omit it to allow only port.`);
|
|
27
|
+
result[id] = { scope: scope, port: v.port, ...(range !== undefined ? { port_range: range } : {}) };
|
|
28
|
+
}
|
|
29
|
+
const entries = Object.entries(result);
|
|
30
|
+
for (let i = 0; i < entries.length; i++)
|
|
31
|
+
for (let j = i + 1; j < entries.length; j++)
|
|
32
|
+
if (entries[i][1].port === entries[j][1].port)
|
|
33
|
+
invalid(`${entries[j][0]} default port conflicts with ${entries[i][0]}; all and loopback bindings share the IPv4 port space.`);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export function tcpSDKProblem(backend) {
|
|
37
|
+
if (backend.kind !== 'go')
|
|
38
|
+
return 'tcp_listeners requires a native Go backend.';
|
|
39
|
+
try {
|
|
40
|
+
const version = appSdkVersion(backend);
|
|
41
|
+
if (!version)
|
|
42
|
+
return 'tcp_listeners requires a pinned Go SDK with ipc.ListenTCP policy v1 (SDK 0.53.0).';
|
|
43
|
+
const source = readFileSync(join(sdkSource(version).goDir, 'ipc/tcp.go'), 'utf8');
|
|
44
|
+
if (!source.includes('const RawTCPPolicyVersion = 1'))
|
|
45
|
+
throw Error('policy v1 missing');
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return 'tcp_listeners requires Go SDK ipc.ListenTCP policy v1 (SDK 0.53.0); update the SDK pin, or use SYNOPKGLAND_SDK_DIR for local branch validation.';
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
export function tcpPolicyFlag(m) {
|
|
53
|
+
if (!m.tcpListeners)
|
|
54
|
+
return [];
|
|
55
|
+
const policy = Buffer.from(JSON.stringify({ schema: 1, listeners: m.tcpListeners })).toString('base64url');
|
|
56
|
+
return [`-X github.com/synopackageland/syno-pkg-land-sdk/ipc.tcpListenersPolicy=${policy}`];
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1112,7 +1112,7 @@
|
|
|
1112
1112
|
"sourceAudit": {
|
|
1113
1113
|
"build-spk/share-combobox.ts": "797cd3eea347e7fe57946f9584f725d6faef79fe9c56b690e1199ea7489fa973",
|
|
1114
1114
|
"build-spk/share-validation.ts": "a51b160cea9bea096e6efb45879abbf6d0dfecf21c761dca7cd06647d44cef62",
|
|
1115
|
-
"cli.ts": "
|
|
1115
|
+
"cli.ts": "d198112e9b2e238373f96e85da50f509f55915a3995704936591162c2a37a783",
|
|
1116
1116
|
"ctl/cli.ts": "97d218069c6fac42f64573c68c354d7a0e549ca2900b9d8b2935c9786bc5d11d",
|
|
1117
1117
|
"ctl/external.ts": "f66490ded838f934a0cf373f284418d4d02441edc8c8365066fc45b898ba81dc",
|
|
1118
1118
|
"ctl/flows.ts": "0f35d03176655bfe1d1df5d02ea36199e05973634dffcc6710112b7c8ce78b7e",
|
|
@@ -16,6 +16,22 @@
|
|
|
16
16
|
"pattern": "^(?![\\s\\S]*(?:^|/)\\.{1,2}(?:/|$))[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+(?:/[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+)*$(?![\\s\\S])"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
"tcp_listeners": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"minProperties": 1,
|
|
22
|
+
"maxProperties": 64,
|
|
23
|
+
"propertyNames": {"pattern": "^[a-z][a-z0-9_]{0,63}$"},
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["port"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"scope": {"enum": ["loopback", "all"], "default": "loopback"},
|
|
29
|
+
"port": {"type": "integer", "minimum": 1024, "maximum": 65535},
|
|
30
|
+
"port_range": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "integer", "minimum": 1024, "maximum": 65535}}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
19
35
|
"identity_gateway": {"$ref": "identity-gateway.v1.schema.json"},
|
|
20
36
|
"mobile": {"$ref": "mobile.v1.schema.json"},
|
|
21
37
|
"i18n": {
|
package/skills/SKILL.md
CHANGED
|
@@ -7,6 +7,8 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
|
|
|
7
7
|
|
|
8
8
|
For native DSM strings and fixed desktop notifications, read
|
|
9
9
|
[reference/dsm-texts.md](reference/dsm-texts.md) (`synopkgland skill show dsm-texts`).
|
|
10
|
+
For raw TCP protocols, read [reference/raw-tcp.md](reference/raw-tcp.md)
|
|
11
|
+
(`synopkgland skill show raw-tcp`).
|
|
10
12
|
|
|
11
13
|
For mobile registration, entry pages and native-shell capabilities, read
|
|
12
14
|
[reference/mobile.md](reference/mobile.md).
|
|
@@ -75,7 +75,7 @@ recipients or accept arbitrary package/section/key references from callers.
|
|
|
75
75
|
|
|
76
76
|
## Evidence and limits
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
A DSM 7.3.2-86009 Update 3 experiment (2026-11-06)
|
|
79
79
|
recorded one fixed-key desktop send as a non-root package user, with an existing
|
|
80
80
|
installed package's preloaded title/description keys. Its source index references
|
|
81
81
|
`developer-guide` commit `eeeffb04af21f14a5928e93c03b1f9e71a0bb15d`,
|
|
@@ -85,7 +85,7 @@ config declares `texts` and `preloadTexts`. `libsynosysnotify/lib/utils/string.c
|
|
|
85
85
|
DSM7-3 commit `99131ab07c4fc7c9c5980db475bd46c61e25316a` L362-390 validates
|
|
86
86
|
`package:section:key`. These are research references, not bundled internal source.
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
A separate unsigned-SPK test (2026-11-07) recorded a package rejected with
|
|
89
89
|
4539 for the Synology-only `sysnotify` worker. This extension adds no `sysnotify`
|
|
90
90
|
resource, `mails` event definitions, JSON-variable mode or email/push/webhook
|
|
91
91
|
forwarding. Those are different mechanisms. Exact `[notify]` resources generated
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Declared raw TCP listeners
|
|
2
|
+
|
|
3
|
+
`ipc.ListenTCP(ctx, "mail_relay", port)` returns a `net.Listener` constrained by
|
|
4
|
+
the native Go package's build-bound manifest declaration. This supports private
|
|
5
|
+
protocols such as a loopback SMTP relay without permitting arbitrary `net.Listen`
|
|
6
|
+
constructors in shipped application binaries. Use a matching CLI with TCP policy
|
|
7
|
+
v1 support; look up matching released SDK and CLI versions before updating pins.
|
|
8
|
+
No release is made by this change.
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
# dsm-package.yaml, schema 2
|
|
12
|
+
tcp_listeners:
|
|
13
|
+
mail_relay:
|
|
14
|
+
port: 2525
|
|
15
|
+
# scope defaults to loopback: exactly IPv4 127.0.0.1
|
|
16
|
+
port_range: [1024, 65535] # optional explicit configurable-port allowance
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```go
|
|
20
|
+
import "github.com/synopackageland/syno-pkg-land-sdk/ipc"
|
|
21
|
+
|
|
22
|
+
listener, err := ipc.ListenTCP(ctx, "mail_relay", configuredPort)
|
|
23
|
+
if err != nil { return err }
|
|
24
|
+
defer listener.Close()
|
|
25
|
+
// Accept and serve the App's bounded, authenticated protocol.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A zero requested port selects the manifest default, rather than an ephemeral
|
|
29
|
+
port. Without `port_range`, only that fixed default is allowed. All ports must
|
|
30
|
+
be unprivileged integers, 1024–65535. Only the declaration selects the address:
|
|
31
|
+
`scope: loopback` (default) means `tcp4` on `127.0.0.1`; explicit `scope: all`
|
|
32
|
+
means `tcp4` on `0.0.0.0`. IPv6, DNS names, arbitrary host strings and privileged
|
|
33
|
+
ports are unsupported. Names use lowercase ASCII letters, digits and underscores,
|
|
34
|
+
start with a letter and have at most 64 characters. At most 64 declarations are
|
|
35
|
+
allowed. Duplicate default ports fail CLI validation; overlapping configurable
|
|
36
|
+
ranges are allowed and runtime binding decides conflicts. No DSM firewall rule,
|
|
37
|
+
service-port registration, installer UI, process supervision or root authority is
|
|
38
|
+
created. Use the existing jobs worker or daemon to host a long-lived service.
|
|
39
|
+
|
|
40
|
+
The CLI normalizes the policy and binds it, plus the package identity, into both
|
|
41
|
+
CGI and worker binaries with linker flags. The SDK does not read an environment
|
|
42
|
+
variable, a writable policy file or policy supplied by the caller. A binary with
|
|
43
|
+
no compiled policy/identity, an undeclared ID or an out-of-policy port fails
|
|
44
|
+
closed. Local SDK source replacement is a development mechanism, not a published
|
|
45
|
+
SDK pin. `check` validates the pinned/resolved SDK supports policy v1.
|
|
46
|
+
|
|
47
|
+
Use a **direct call with a literal ID** at each call site. Constructor aliases,
|
|
48
|
+
dynamic IDs and undeclared IDs fail the shipped-source audit. Declaring TCP does
|
|
49
|
+
not exempt any `net`, `tls`, syscall or HTTP constructor, file, directory or
|
|
50
|
+
handler from the existing audit. HTTP routes still use the SDK HTTP registry.
|
|
51
|
+
The auditor and compiler policy provide a supported source boundary, not an OS
|
|
52
|
+
sandbox against malicious code, reflection, plugins, cgo or custom syscalls.
|
|
53
|
+
|
|
54
|
+
Loopback binding uses the same internal bind primitive as `ipc.ReserveLoopback`;
|
|
55
|
+
the raw listener retains the bound socket without a release/rebind handoff.
|
|
56
|
+
Reservations still expose no listener and cannot bypass declarations. Kernel bind
|
|
57
|
+
failure is authoritative; a prior probe never guarantees ownership. `Close` is
|
|
58
|
+
idempotent. Context cancellation closes the listening socket and unblocks
|
|
59
|
+
`Accept`, but **does not close already accepted connections**. The App owns those
|
|
60
|
+
connections, deadlines, shutdown, concurrency limits, TLS/STARTTLS, authentication,
|
|
61
|
+
frame/message limits and upstream authorization. Other NAS processes can connect
|
|
62
|
+
to loopback; it is not a DSM identity boundary.
|
|
63
|
+
|
|
64
|
+
`inspect --json` reports the archived normalized `tcpListeners` policy. That is
|
|
65
|
+
build metadata, not proof of runtime binding, firewall reachability, SMTP delivery
|
|
66
|
+
or a package signature. No NAS acceptance is established by local tests.
|