@synopackageland/cli 0.50.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-spk/generator.js +3 -3
- package/dist/build-spk/reproducible-archive.js +3 -1
- package/dist/ctl/ai-tools.d.ts +2 -0
- package/dist/ctl/cli.js +14 -0
- package/dist/ctl/diagnostics.d.ts +16 -0
- package/dist/ctl/diagnostics.js +11 -0
- package/dist/ctl/native-auth-command.js +5 -0
- package/dist/ctl/native-paths.js +13 -2
- package/dist/ctl/native-store.d.ts +6 -0
- package/dist/ctl/native-store.js +20 -26
- package/dist/ctl/service.d.ts +2 -0
- package/dist/ctl/service.js +1 -1
- package/dist/ctl/windows-acl.d.ts +39 -0
- package/dist/ctl/windows-acl.js +80 -0
- package/dist/ctl/windows-prompt.d.ts +5 -0
- package/dist/ctl/windows-prompt.js +119 -0
- package/dist/ctl/windows-sddl.d.ts +20 -0
- package/dist/ctl/windows-sddl.js +162 -0
- package/dist/ctl/windows-security-helper.d.ts +7 -0
- package/dist/ctl/windows-security-helper.js +88 -0
- package/dist/ctl/windows-security.d.ts +10 -0
- package/dist/ctl/windows-security.js +95 -0
- package/dist/ctl/windows-tools.d.ts +11 -0
- package/dist/ctl/windows-tools.js +23 -0
- package/dist/native-http-schema/source.json +1 -1
- package/dist/spk/extract.d.ts +6 -0
- package/dist/spk/extract.js +39 -0
- package/dist/standalone/daemon.js +1 -0
- package/dist/standalone/inspect-spk.js +21 -20
- package/dist/standalone/install-ports.js +2 -1
- package/dist/standalone/native-layout.js +2 -0
- package/package.json +2 -1
- package/skills/reference/ctl.md +32 -1
|
@@ -27,6 +27,7 @@ import { inspectHyperBackup } from "./hyper-backup.js";
|
|
|
27
27
|
import { tmpdir } from "node:os";
|
|
28
28
|
import { join } from "node:path";
|
|
29
29
|
import * as tar from "tar";
|
|
30
|
+
import { extractSpkArchive } from "../spk/extract.js";
|
|
30
31
|
import { familyOfArchToken, NATIVE_ARCH_FAMILIES, } from "../build-spk/dsm-arch.js";
|
|
31
32
|
import { CONTAINER_MIN_DSM, isDsmAtLeast, PORTAL_EXECUTOR_MIN_DSM, PORTAL_MIN_DSM, PORTAL_MIN_DSM_REASON, } from "../build-spk/dsm-version.js";
|
|
32
33
|
import { ELF_MACHINE } from "./binary.js";
|
|
@@ -74,7 +75,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
74
75
|
const findings = (await archiveInventory(spkPath, true)).map(formatArchiveIssue);
|
|
75
76
|
if (findings.length)
|
|
76
77
|
return { signed: false, payload: [], findings, capabilities: [] };
|
|
77
|
-
await
|
|
78
|
+
findings.push(...await extractSpkArchive({ file: spkPath, cwd: dir }));
|
|
78
79
|
if (existsSync(join(dir, 'package.tgz'))) {
|
|
79
80
|
findings.push(...(await archiveInventory(join(dir, 'package.tgz'))).map(formatArchiveIssue));
|
|
80
81
|
if (findings.length)
|
|
@@ -90,7 +91,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
90
91
|
const payload = await listPayload(join(dir, "package.tgz"), findings);
|
|
91
92
|
const target = join(dir, "layout-inspection");
|
|
92
93
|
mkdirSync(target);
|
|
93
|
-
await
|
|
94
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: target });
|
|
94
95
|
findings.push(...inspectNativeLayout(dir, target, info));
|
|
95
96
|
for (const key of [
|
|
96
97
|
"package",
|
|
@@ -177,7 +178,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
177
178
|
const root = join(dir, "backup-inspection");
|
|
178
179
|
if (!existsSync(root)) {
|
|
179
180
|
mkdirSync(root);
|
|
180
|
-
await
|
|
181
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root });
|
|
181
182
|
}
|
|
182
183
|
return root;
|
|
183
184
|
}, payload, metadata.hyperBackup, /^package="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1] ?? "", familyOfArchToken(/^arch="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1]?.split(/\s+/)[0] ?? "") ?? "x86_64", findings);
|
|
@@ -268,7 +269,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
268
269
|
paths.has("executor/executor")) {
|
|
269
270
|
const executorDir = join(dir, "executor-inspection");
|
|
270
271
|
mkdirSync(executorDir);
|
|
271
|
-
await
|
|
272
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: executorDir });
|
|
272
273
|
const inspected = inspectExecutor(executorDir, info.package, info.arch);
|
|
273
274
|
findings.push(...inspected.findings);
|
|
274
275
|
executor = inspected.executor;
|
|
@@ -406,7 +407,7 @@ async function inspectModuleUi(dir, paths, version, findings, mobile) {
|
|
|
406
407
|
throw new Error("module UI assets must all belong to the recorded tree");
|
|
407
408
|
const root = join(dir, "module-ui-inspection");
|
|
408
409
|
mkdirSync(root);
|
|
409
|
-
await
|
|
410
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: path => path.replace(/^\.\//, "").startsWith(prefix) });
|
|
410
411
|
if (uiTreeDigest(join(root, "ui/app", version), true) !== version)
|
|
411
412
|
throw new Error("UI assets differ from their recorded digest");
|
|
412
413
|
}
|
|
@@ -420,7 +421,7 @@ const LAUNCHER_PORTAL_MISMATCH = "LAUNCHER_PORTAL_MISMATCH";
|
|
|
420
421
|
async function checkLaunchConfiguration(dir, info, native, declared, alias, findings, console = false, windowless = false) {
|
|
421
422
|
const target = join(dir, "launch-inspection");
|
|
422
423
|
mkdirSync(target);
|
|
423
|
-
await
|
|
424
|
+
await extractSpkArchive({
|
|
424
425
|
file: join(dir, "package.tgz"),
|
|
425
426
|
cwd: target,
|
|
426
427
|
filter: (path) => ["ui/config", "synology-app.yaml"].includes(path.replace(/^\.\//, "")),
|
|
@@ -558,7 +559,7 @@ function checkGatewayOnlyLauncher(target, info, native, findings) {
|
|
|
558
559
|
async function checkEntryLauncher(dir, pkg, entry, findings) {
|
|
559
560
|
const target = join(dir, "entry-inspection");
|
|
560
561
|
mkdirSync(target);
|
|
561
|
-
await
|
|
562
|
+
await extractSpkArchive({
|
|
562
563
|
file: join(dir, "package.tgz"),
|
|
563
564
|
cwd: target,
|
|
564
565
|
filter: (path) => path.replace(/^\.\//, "") === "ui/config",
|
|
@@ -591,7 +592,7 @@ const LOGIN_STYLE_FILES = [
|
|
|
591
592
|
async function inspectLoginStyle(dir, pkg, portal, findings) {
|
|
592
593
|
const target = join(dir, "login-style-inspection");
|
|
593
594
|
mkdirSync(target);
|
|
594
|
-
await
|
|
595
|
+
await extractSpkArchive({
|
|
595
596
|
file: join(dir, "package.tgz"),
|
|
596
597
|
cwd: target,
|
|
597
598
|
filter: (path) => path.replace(/^\.\//, "").startsWith("ui/"),
|
|
@@ -701,7 +702,7 @@ async function checkArch(dir, info, kind, hasCgi, findings) {
|
|
|
701
702
|
const cgi = join(dir, "cgi-inspection");
|
|
702
703
|
mkdirSync(cgi);
|
|
703
704
|
// Only the header is read; the CGI is never run.
|
|
704
|
-
await
|
|
705
|
+
await extractSpkArchive({
|
|
705
706
|
file: join(dir, "package.tgz"),
|
|
706
707
|
cwd: cgi,
|
|
707
708
|
filter: (path) => path.replace(/^\.\//, "") === CGI_PAYLOAD_PATH,
|
|
@@ -735,7 +736,7 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings) {
|
|
|
735
736
|
const appScripts = unwrapAppScripts(join(dir, "scripts"), findings);
|
|
736
737
|
const root = join(dir, "unified-compose-inspection");
|
|
737
738
|
mkdirSync(root);
|
|
738
|
-
await
|
|
739
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root });
|
|
739
740
|
try {
|
|
740
741
|
if (metadata.capabilities?.some((c) => c !== "composeMounts"))
|
|
741
742
|
throw new Error("Compose cannot claim an undeclared executor capability");
|
|
@@ -927,7 +928,7 @@ async function recoverCompose(dir, value, findings) {
|
|
|
927
928
|
throw new Error("invalid compose inventory");
|
|
928
929
|
const root = join(dir, "compose-inspection");
|
|
929
930
|
mkdirSync(root);
|
|
930
|
-
await
|
|
931
|
+
await extractSpkArchive({
|
|
931
932
|
file: join(dir, "package.tgz"),
|
|
932
933
|
cwd: root,
|
|
933
934
|
filter: (p) => ["compose/docker-compose.yml", "sso/gateway.json"].includes(p.replace(/^\.\//, "")),
|
|
@@ -974,7 +975,7 @@ async function checkDaemon(dir, info, paths, payload, findings, executor, backgr
|
|
|
974
975
|
// Extract only the bounded config; the payload executable is never run.
|
|
975
976
|
const { mkdirSync } = await import("node:fs");
|
|
976
977
|
mkdirSync(unpacked);
|
|
977
|
-
await
|
|
978
|
+
await extractSpkArchive({
|
|
978
979
|
file: join(dir, "package.tgz"),
|
|
979
980
|
cwd: unpacked,
|
|
980
981
|
filter: (path) => ["daemon/config.json", `daemon/payload/${NODE_LAUNCHER}`].includes(path.replace(/^\.\//, "")),
|
|
@@ -1166,7 +1167,7 @@ function readInfo(path, findings, kind, compose = false, daemonNode, dependencie
|
|
|
1166
1167
|
async function checkContainerExposure(dir, packageTgz, findings) {
|
|
1167
1168
|
const extracted = join(dir, "payload");
|
|
1168
1169
|
mkdirSync(extracted);
|
|
1169
|
-
await
|
|
1170
|
+
await extractSpkArchive({
|
|
1170
1171
|
file: packageTgz,
|
|
1171
1172
|
cwd: extracted,
|
|
1172
1173
|
filter: (path) => path.replace(/^\.\//, "") === "compose.yaml",
|
|
@@ -1198,7 +1199,7 @@ async function inspectGatewayAdmission(dir, paths, saved, findings) {
|
|
|
1198
1199
|
}
|
|
1199
1200
|
const root = join(dir, "gateway-admission-inspection");
|
|
1200
1201
|
mkdirSync(root);
|
|
1201
|
-
await
|
|
1202
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: p => p.replace(/^\.\//, "") === "sso/gateway.json" });
|
|
1202
1203
|
const cfg = JSON.parse(readFileSync(join(root, "sso/gateway.json"), "utf8"));
|
|
1203
1204
|
const gateway = gatewayReviewReport(cfg);
|
|
1204
1205
|
if (cfg.upstream_access !== undefined && !["public", "protected"].includes(cfg.upstream_access))
|
|
@@ -1233,7 +1234,7 @@ async function inspectExternalGateway(dir, paths, payload, saved, findings) {
|
|
|
1233
1234
|
const root = join(dir, "external-gateway-inspection");
|
|
1234
1235
|
mkdirSync(root);
|
|
1235
1236
|
const entries = ["sso/gateway.json", GATEWAY_SETTINGS_CGI_PATH, "ui/sso/open.cgi"];
|
|
1236
|
-
await
|
|
1237
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: p => entries.includes(p.replace(/^\.\//, "")) });
|
|
1237
1238
|
const cfg = JSON.parse(readFileSync(join(root, "sso/gateway.json"), "utf8"));
|
|
1238
1239
|
if (saved === undefined && cfg.external === undefined && !paths.has(GATEWAY_SETTINGS_CGI_PATH))
|
|
1239
1240
|
return;
|
|
@@ -1276,7 +1277,7 @@ async function recoverNativeGateway(dir, value, info, findings) {
|
|
|
1276
1277
|
throw new Error('unsupported native gateway SDK/DSM floor');
|
|
1277
1278
|
const root = join(dir, 'native-gateway-inspection');
|
|
1278
1279
|
mkdirSync(root);
|
|
1279
|
-
await
|
|
1280
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: root, filter: path => ['sso/gateway.json', 'ui/sso/open.cgi', NATIVE_GATEWAY_CONFIG].includes(path.replace(/^\.\//, '')) });
|
|
1280
1281
|
const config = JSON.parse(readFileSync(join(root, 'sso/gateway.json'), 'utf8'));
|
|
1281
1282
|
if (config.native_ingress !== true || config.package !== info.package || !isDeepStrictEqual(config.listen, plan.listen) || config.ingress_path !== plan.ingress?.path
|
|
1282
1283
|
|| config.state_dir !== `/var/packages/${info.package}/var/sso`)
|
|
@@ -1328,7 +1329,7 @@ async function recoverDaemonIngress(dir, value, info, paths, findings) {
|
|
|
1328
1329
|
throw new Error("ingress needs the package daemon");
|
|
1329
1330
|
const root = join(dir, "daemon-ingress-inspection");
|
|
1330
1331
|
mkdirSync(root);
|
|
1331
|
-
await
|
|
1332
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => path.replace(/^\.\//, "") === DAEMON_INGRESS_CONFIG });
|
|
1332
1333
|
if (readOptional(join(root, DAEMON_INGRESS_CONFIG)) !== renderDaemonIngressConfig(info.package, ingress))
|
|
1333
1334
|
throw new Error("ingress location differs from its fixed proxy");
|
|
1334
1335
|
for (const key of ["instuninst_restart_services", "startstop_restart_services"])
|
|
@@ -1544,7 +1545,7 @@ async function inspectInstallSettings(dir, payload, metadata, findings) {
|
|
|
1544
1545
|
}
|
|
1545
1546
|
const root = join(dir, 'install-settings-inspection');
|
|
1546
1547
|
mkdirSync(root);
|
|
1547
|
-
await
|
|
1548
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: root });
|
|
1548
1549
|
const info = readInfo(join(dir, 'INFO'), findings, 'binary', Boolean(metadata.compose), undefined, inspectPackageDependencies(metadata.dependencies, findings));
|
|
1549
1550
|
const gateway = metadata.compose?.gateway ?? metadata.native_gateway;
|
|
1550
1551
|
const m = { package: info.package, os_min_ver: info.os_min_ver, capabilities: {}, installSettings: settings, identityGateway: gateway, ...(ports ? { installPorts: true } : {}) };
|
|
@@ -1621,7 +1622,7 @@ async function recoverPortal(dir, info, appId, paths, payload, findings, nativeG
|
|
|
1621
1622
|
return;
|
|
1622
1623
|
const unpacked = join(dir, "portal-inspection");
|
|
1623
1624
|
mkdirSync(unpacked);
|
|
1624
|
-
await
|
|
1625
|
+
await extractSpkArchive({
|
|
1625
1626
|
file: join(dir, "package.tgz"),
|
|
1626
1627
|
cwd: unpacked,
|
|
1627
1628
|
filter: (path) => files.includes(path.replace(/^\.\//, "")),
|
|
@@ -1827,7 +1828,7 @@ async function inspectMobile(dir, paths, record, info, findings) {
|
|
|
1827
1828
|
throw new Error('registration package or version differs from INFO');
|
|
1828
1829
|
const target = join(dir, 'mobile-inspection');
|
|
1829
1830
|
mkdirSync(target);
|
|
1830
|
-
await
|
|
1831
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: target, filter: path => path.replace(/^\.\//, '').startsWith('ui/app/') });
|
|
1831
1832
|
const problem = inspectMobileFiles(join(target, 'ui/app'), record);
|
|
1832
1833
|
if (problem)
|
|
1833
1834
|
throw new Error(problem);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
export function portDefaults(m) {
|
|
4
4
|
if (!m.installPorts || !m.identityGateway)
|
|
@@ -125,4 +125,5 @@ export function writePortPayload(m, root, render) {
|
|
|
125
125
|
mkdirSync(join(root, 'install'), { recursive: true });
|
|
126
126
|
writeFileSync(join(root, 'install/ports.json'), JSON.stringify({ schema: 1, package: m.package, ports, files }, null, 2) + '\n', { mode: 0o600 });
|
|
127
127
|
writeFileSync(join(root, `install/${m.package}.sc`), Object.entries(ports).map(([key, p]) => `[synopkgland.${m.package.replaceAll('_', '-')}.${key.replaceAll('_', '-')}]\ntitle="${m.package}"\ndesc="${m.package}"\nport_forward="no"\ndst.ports="${p.default}/${p.protocol}"\n`).join('\n'), { mode: 0o644 });
|
|
128
|
+
chmodSync(join(root, `install/${m.package}.sc`), 0o644);
|
|
128
129
|
}
|
|
@@ -360,6 +360,8 @@ export async function buildNativeLayout(options) {
|
|
|
360
360
|
fail('INFO anchor collides with an INFO field');
|
|
361
361
|
writeFileSync(join(stage, 'INFO'), info.map(([k, v]) => `${k}="${v.replace(/([\\"$`])/g, '\\$1')}"\n`).join(''));
|
|
362
362
|
writeFileSync(join(stage, 'native-layout.json'), JSON.stringify({ format: 1, arch, dependencies: m.dependencies ?? { packages: [] }, binaries: binaries.map(({ path, linkage }) => ({ path, linkage })), files, ...(m.layout.anchors ? { anchors: m.layout.anchors } : {}), ...(m.portal ? { portal: m.portal } : {}) }));
|
|
363
|
+
for (const name of ['INFO', 'native-layout.json'])
|
|
364
|
+
chmodSync(join(stage, name), 0o644);
|
|
363
365
|
const output = join(outDir, `${m.package}-${version}-${arch}.spk`);
|
|
364
366
|
await createReproducibleTar(stage, output, { rejectSecrets: true });
|
|
365
367
|
return output;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.1",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"commander": "^13.1.0",
|
|
45
45
|
"esbuild": "^0.28.2",
|
|
46
46
|
"json-canonicalize": "^3.0.1",
|
|
47
|
+
"koffi": "3.3.7",
|
|
47
48
|
"re2js": "2.9.1",
|
|
48
49
|
"tar": "^7.4.3",
|
|
49
50
|
"yaml": "^2.7.0"
|
package/skills/reference/ctl.md
CHANGED
|
@@ -92,7 +92,38 @@ The independent passphrase is hidden, process-local and never derived from DSM
|
|
|
92
92
|
credentials. The vault uses scrypt and AES-256-GCM, bounded authenticated metadata,
|
|
93
93
|
private file permissions (user-only ACL on Windows), exclusive locking and atomic
|
|
94
94
|
replacement. Wrong passphrase, tamper, symlinks or unsafe permissions refuse
|
|
95
|
-
access.
|
|
95
|
+
access. On Windows, inherited ACLs on the shared ctl state directory are accepted
|
|
96
|
+
only when its owner is the current user, Administrators, local Administrator (LA)
|
|
97
|
+
or SYSTEM and no other
|
|
98
|
+
principal has write, delete, ACL-change or ownership-change access. Ancestors
|
|
99
|
+
are checked separately: the exact TrustedInstaller SID is also trusted there;
|
|
100
|
+
inherit-only grants do not apply to that directory, and create-subdirectory
|
|
101
|
+
permission alone cannot replace an existing protected child. Each next directory
|
|
102
|
+
is checked for effective grants. These ancestor exceptions do not apply to state
|
|
103
|
+
or private leaves. LA/LG use Win32 identity resolution, never the current user
|
|
104
|
+
SID prefix. Other recognized well-known aliases remain subject to the same
|
|
105
|
+
untrusted-writer policy. Private native
|
|
106
|
+
directories and files additionally reject other principals' read access. Existing
|
|
107
|
+
unsafe ACLs are refused rather than rewritten; new private objects use protected
|
|
108
|
+
current-user ACLs. An unavailable list entry includes a bounded `auth.reason`
|
|
109
|
+
code (for example `windows-acl-other-user-write`), without paths, SIDs or secrets.
|
|
110
|
+
ACL inspection uses Win32 GetNamedSecurityInfoW through a pinned native bridge
|
|
111
|
+
in a Node child that waits for completion without a wall-clock timeout; Ctrl-C
|
|
112
|
+
can interrupt it. No PowerShell is involved. Child output remains size-bounded,
|
|
113
|
+
with hidden windows and piped stdio. It reads the actual owner and DACL;
|
|
114
|
+
icacls /save alone omits the owner. The current SID is queried once per process
|
|
115
|
+
with whoami. New private objects use icacls and native readback;
|
|
116
|
+
unknown SDDL rights, flags or ACEs fail closed. Object ACE grants are evaluated
|
|
117
|
+
conservatively; conditional ACEs are explicitly refused. OWNER RIGHTS follows the
|
|
118
|
+
validated owner. Group, audit and mandatory-label sections cannot excuse unsafe
|
|
119
|
+
DACL grants. Invalid descriptors include a bounded tokenKind/token/section detail
|
|
120
|
+
with account SIDs masked, never the full descriptor or local paths. Inspection failures include a
|
|
121
|
+
fixed auth.detail.category and, when available, exitCode or win32Code. Raw child
|
|
122
|
+
stderr is never returned. ACL phase diagnostics include elapsedMs. Windows interactive prompts enable raw mode
|
|
123
|
+
before displaying input and wait for the prompt write to flush. An optional
|
|
124
|
+
`SYNOPKGLAND_CTL_DIAGNOSTICS_FILE` records private phase/TTY metadata only, never
|
|
125
|
+
input values, prompt text, local paths or SIDs.
|
|
126
|
+
Headless encrypted-file unlock is unsupported; automation requires an OS
|
|
96
127
|
secret service. Actual OS availability must be verified on the target platform.
|
|
97
128
|
Changing storage backends requires explicit `--reset` and enrollment, which
|
|
98
129
|
prevents a failed migration from leaving an unindexed old secret behind.
|