@uns-kit/core 3.0.28 → 3.0.30
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/MIGRATIONS.md +100 -0
- package/README.md +10 -0
- package/dist/config/app-config.d.ts +14 -0
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/configuration-group-authorization.d.ts +50 -0
- package/dist/runtime/configuration-group-authorization.d.ts.map +1 -0
- package/dist/runtime/configuration-group-authorization.js +113 -0
- package/dist/runtime/configuration-group-authorization.js.map +1 -0
- package/dist/runtime/configuration-group-contract.d.ts +75 -0
- package/dist/runtime/configuration-group-contract.d.ts.map +1 -0
- package/dist/runtime/configuration-group-contract.js +233 -0
- package/dist/runtime/configuration-group-contract.js.map +1 -0
- package/dist/runtime/process-group-authorization.d.ts +2 -0
- package/dist/runtime/process-group-authorization.d.ts.map +1 -1
- package/dist/runtime/process-group-authorization.js +34 -12
- package/dist/runtime/process-group-authorization.js.map +1 -1
- package/dist/runtime/process-group-backup-contract.d.ts +22 -0
- package/dist/runtime/process-group-backup-contract.d.ts.map +1 -0
- package/dist/runtime/process-group-backup-contract.js +20 -0
- package/dist/runtime/process-group-backup-contract.js.map +1 -0
- package/dist/runtime/process-group-backup-contract.json +7 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts +4 -0
- package/dist/runtime/process-group-configured-upgrade.d.ts.map +1 -0
- package/dist/runtime/process-group-configured-upgrade.js +107 -0
- package/dist/runtime/process-group-configured-upgrade.js.map +1 -0
- package/dist/runtime/process-group-generation.d.ts +166 -0
- package/dist/runtime/process-group-generation.d.ts.map +1 -0
- package/dist/runtime/process-group-generation.js +278 -0
- package/dist/runtime/process-group-generation.js.map +1 -0
- package/dist/runtime/process-group-inspection.d.ts +2 -0
- package/dist/runtime/process-group-inspection.d.ts.map +1 -1
- package/dist/runtime/process-group-inspection.js +120 -40
- package/dist/runtime/process-group-inspection.js.map +1 -1
- package/dist/runtime/process-group-resources.d.ts +1 -0
- package/dist/runtime/process-group-resources.d.ts.map +1 -1
- package/dist/runtime/process-group-resources.js +8 -0
- package/dist/runtime/process-group-resources.js.map +1 -1
- package/dist/runtime/process-group-runtime-selection.d.ts +14 -0
- package/dist/runtime/process-group-runtime-selection.d.ts.map +1 -0
- package/dist/runtime/process-group-runtime-selection.js +29 -0
- package/dist/runtime/process-group-runtime-selection.js.map +1 -0
- package/dist/runtime/process-group-snapshot.mjs +60 -8
- package/dist/runtime/process-group-staging.d.ts +2 -2
- package/dist/runtime/process-group-staging.d.ts.map +1 -1
- package/dist/runtime/process-group-staging.js +6 -4
- package/dist/runtime/process-group-staging.js.map +1 -1
- package/dist/runtime/process-group-supervision.d.ts +2 -2
- package/dist/runtime/process-group-supervision.d.ts.map +1 -1
- package/dist/runtime/process-group-supervision.js +3 -2
- package/dist/runtime/process-group-supervision.js.map +1 -1
- package/dist/runtime/process-group-upgrade.d.ts +76 -6
- package/dist/runtime/process-group-upgrade.d.ts.map +1 -1
- package/dist/runtime/process-group-upgrade.js +7 -1
- package/dist/runtime/process-group-upgrade.js.map +1 -1
- package/dist/uns/uns-interfaces.d.ts +3 -0
- package/dist/uns/uns-interfaces.d.ts.map +1 -1
- package/dist/uns/uns-interfaces.js.map +1 -1
- package/dist/uns/uns-proxy-process.d.ts.map +1 -1
- package/dist/uns/uns-proxy-process.js +3 -0
- package/dist/uns/uns-proxy-process.js.map +1 -1
- package/dist/uns-config/config-schema.d.ts +16 -0
- package/dist/uns-config/config-schema.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.d.ts +1 -1
- package/dist/uns-config/mqtt-channel.d.ts.map +1 -1
- package/dist/uns-config/mqtt-channel.js +3 -0
- package/dist/uns-config/mqtt-channel.js.map +1 -1
- package/dist/uns-config/uns-core-schema.d.ts +137 -0
- package/dist/uns-config/uns-core-schema.d.ts.map +1 -1
- package/dist/uns-config/uns-core-schema.js +6 -1
- package/dist/uns-config/uns-core-schema.js.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.d.ts +5 -0
- package/dist/uns-mqtt/mqtt-interfaces.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-interfaces.js.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.d.ts +3 -0
- package/dist/uns-mqtt/mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-proxy.js +26 -1
- package/dist/uns-mqtt/mqtt-proxy.js.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts +3 -1
- package/dist/uns-mqtt/mqtt-worker.d.ts.map +1 -1
- package/dist/uns-mqtt/mqtt-worker.js +45 -8
- package/dist/uns-mqtt/mqtt-worker.js.map +1 -1
- package/dist/uns-mqtt/publish-queue-contract.d.ts +33 -0
- package/dist/uns-mqtt/publish-queue-contract.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-contract.js +18 -0
- package/dist/uns-mqtt/publish-queue-contract.js.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts +33 -0
- package/dist/uns-mqtt/publish-queue-store.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue-store.js +177 -0
- package/dist/uns-mqtt/publish-queue-store.js.map +1 -0
- package/dist/uns-mqtt/publish-queue.d.ts +43 -0
- package/dist/uns-mqtt/publish-queue.d.ts.map +1 -0
- package/dist/uns-mqtt/publish-queue.js +235 -0
- package/dist/uns-mqtt/publish-queue.js.map +1 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts +7 -0
- package/dist/uns-mqtt/uns-mqtt-proxy.d.ts.map +1 -1
- package/dist/uns-mqtt/uns-mqtt-proxy.js +98 -5
- package/dist/uns-mqtt/uns-mqtt-proxy.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { readConfigurationSelector } from "./process-group-contract.js";
|
|
6
|
+
import { readProcessGroupResource } from "./process-group-resources.js";
|
|
7
|
+
const identity = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);
|
|
8
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
9
|
+
const selector = z
|
|
10
|
+
.array(z
|
|
11
|
+
.string()
|
|
12
|
+
.regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/)
|
|
13
|
+
.refine((v) => !["__proto__", "prototype", "constructor"].includes(v)))
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(8);
|
|
16
|
+
const MAX_BYTES = 1024 * 1024;
|
|
17
|
+
/** Versioned canonical JSON: binary key order, no locale, executable values or accessors. */
|
|
18
|
+
export function configurationResourceJson(value) {
|
|
19
|
+
let nodes = 0, bytes = 0;
|
|
20
|
+
const ancestors = new Set();
|
|
21
|
+
const charge = (size) => {
|
|
22
|
+
bytes += size;
|
|
23
|
+
if (bytes > MAX_BYTES)
|
|
24
|
+
throw Error("Configuration resource exceeds 1 MiB");
|
|
25
|
+
};
|
|
26
|
+
function visit(v, depth) {
|
|
27
|
+
if (++nodes > 65536 || depth > 32)
|
|
28
|
+
throw Error("Configuration resource exceeds its structural budget");
|
|
29
|
+
if (v === null || typeof v === "boolean") {
|
|
30
|
+
charge(v === null ? 4 : v ? 4 : 5);
|
|
31
|
+
return JSON.stringify(v);
|
|
32
|
+
}
|
|
33
|
+
if (typeof v === "string") {
|
|
34
|
+
if (Buffer.byteLength(v) > MAX_BYTES)
|
|
35
|
+
throw Error("Configuration resource string exceeds 1 MiB");
|
|
36
|
+
const encoded = JSON.stringify(v);
|
|
37
|
+
charge(Buffer.byteLength(encoded));
|
|
38
|
+
return encoded;
|
|
39
|
+
}
|
|
40
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
41
|
+
const encoded = JSON.stringify(v);
|
|
42
|
+
charge(encoded.length);
|
|
43
|
+
return encoded;
|
|
44
|
+
}
|
|
45
|
+
if (!v || typeof v !== "object" || ancestors.has(v))
|
|
46
|
+
throw Error("Configuration resource must contain finite plain JSON only");
|
|
47
|
+
if (Array.isArray(v)
|
|
48
|
+
? Object.getPrototypeOf(v) !== Array.prototype
|
|
49
|
+
: Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null)
|
|
50
|
+
throw Error("Configuration resource must contain plain JSON objects");
|
|
51
|
+
if (Object.getOwnPropertySymbols(v).length)
|
|
52
|
+
throw Error("Configuration resource cannot contain symbol properties");
|
|
53
|
+
const descriptors = Object.getOwnPropertyDescriptors(v);
|
|
54
|
+
for (const [key, d] of Object.entries(descriptors)) {
|
|
55
|
+
if (Array.isArray(v) && key === "length")
|
|
56
|
+
continue;
|
|
57
|
+
if (!d.enumerable || !Object.hasOwn(d, "value"))
|
|
58
|
+
throw Error("Configuration resource cannot contain hidden properties or accessors");
|
|
59
|
+
}
|
|
60
|
+
ancestors.add(v);
|
|
61
|
+
charge(2); // Container brackets/braces.
|
|
62
|
+
let result;
|
|
63
|
+
if (Array.isArray(v)) {
|
|
64
|
+
if (v.length > 65536 || Object.keys(v).length !== v.length || Object.keys(v).some((k, i) => k !== String(i)))
|
|
65
|
+
throw Error("Configuration resource arrays must be dense JSON arrays");
|
|
66
|
+
charge(Math.max(0, v.length - 1));
|
|
67
|
+
result = "[" + Array.from({ length: v.length }, (_, i) => visit(descriptors[String(i)].value, depth + 1)).join(",") + "]";
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
result =
|
|
71
|
+
"{" +
|
|
72
|
+
Object.keys(v)
|
|
73
|
+
.sort()
|
|
74
|
+
.map((k, i) => {
|
|
75
|
+
if (Buffer.byteLength(k) > MAX_BYTES)
|
|
76
|
+
throw Error("Configuration resource key exceeds 1 MiB");
|
|
77
|
+
charge(Buffer.byteLength(JSON.stringify(k)) + 1 + (i ? 1 : 0));
|
|
78
|
+
return JSON.stringify(k) + ":" + visit(descriptors[k].value, depth + 1);
|
|
79
|
+
})
|
|
80
|
+
.join(",") +
|
|
81
|
+
"}";
|
|
82
|
+
ancestors.delete(v);
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
const json = visit(value, 0);
|
|
86
|
+
if (Buffer.byteLength(json) > MAX_BYTES)
|
|
87
|
+
throw Error("Configuration resource exceeds 1 MiB");
|
|
88
|
+
return json;
|
|
89
|
+
}
|
|
90
|
+
export function configurationResourceHash(value) {
|
|
91
|
+
return createHash("sha256").update("uns-configuration-json-v1\n").update(configurationResourceJson(value)).digest("hex");
|
|
92
|
+
}
|
|
93
|
+
export const configurationGroupProfileSchema = z.strictObject({
|
|
94
|
+
id: identity,
|
|
95
|
+
processName: identity,
|
|
96
|
+
dataGroup: identity,
|
|
97
|
+
resource: z.unknown(),
|
|
98
|
+
});
|
|
99
|
+
export const configurationGroupSchema = z.strictObject({
|
|
100
|
+
schemaVersion: z.literal(2),
|
|
101
|
+
id: identity,
|
|
102
|
+
inputTopic: z
|
|
103
|
+
.string()
|
|
104
|
+
.min(1)
|
|
105
|
+
.max(512)
|
|
106
|
+
.regex(/^[^#+\0]+$/),
|
|
107
|
+
processName: identity,
|
|
108
|
+
receiverProcessName: identity,
|
|
109
|
+
profiles: z.array(configurationGroupProfileSchema).min(2).max(16),
|
|
110
|
+
});
|
|
111
|
+
export const configurationGroupDescriptorSchema = z
|
|
112
|
+
.strictObject({
|
|
113
|
+
protocolVersion: z.literal(2),
|
|
114
|
+
namespace: identity,
|
|
115
|
+
publisherPath: selector,
|
|
116
|
+
groupPath: selector,
|
|
117
|
+
memberPath: selector,
|
|
118
|
+
journalPath: selector,
|
|
119
|
+
runtimeRolePath: selector,
|
|
120
|
+
receiverRole: identity,
|
|
121
|
+
match: z.strictObject({ path: selector, value: z.string().min(1).max(100) }).optional(),
|
|
122
|
+
})
|
|
123
|
+
.superRefine((d, context) => {
|
|
124
|
+
const independent = [d.publisherPath, d.journalPath, d.runtimeRolePath].map((p) => p.join("."));
|
|
125
|
+
if (new Set(independent).size !== independent.length || independent.some((p, i) => independent.some((q, j) => i !== j && q.startsWith(p + "."))))
|
|
126
|
+
context.addIssue({ code: "custom", message: "Independent publisher, journal and role selectors required" });
|
|
127
|
+
const parent = d.publisherPath.join(".") + ".", group = d.groupPath.join("."), member = d.memberPath.join(".");
|
|
128
|
+
if (!group.startsWith(parent) ||
|
|
129
|
+
!member.startsWith(parent) ||
|
|
130
|
+
group === member ||
|
|
131
|
+
group.startsWith(member + ".") ||
|
|
132
|
+
member.startsWith(group + "."))
|
|
133
|
+
context.addIssue({ code: "custom", message: "Distinct group/member selectors within the publisher required" });
|
|
134
|
+
});
|
|
135
|
+
const snapshots = new WeakSet();
|
|
136
|
+
function freeze(value) {
|
|
137
|
+
if (value && typeof value === "object") {
|
|
138
|
+
for (const child of Object.values(value))
|
|
139
|
+
freeze(child);
|
|
140
|
+
Object.freeze(value);
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
export function configurationGroupSnapshot(value) {
|
|
145
|
+
// Bound and copy before schema traversal; caller mutation cannot change a running revision.
|
|
146
|
+
const group = configurationGroupSchema.parse(JSON.parse(configurationResourceJson(value)));
|
|
147
|
+
const names = [group.processName, group.receiverProcessName, ...group.profiles.map((p) => p.processName)];
|
|
148
|
+
if (new Set(names).size !== names.length || new Set(group.profiles.map((p) => p.id)).size !== group.profiles.length)
|
|
149
|
+
throw Error("Configuration group identities overlap");
|
|
150
|
+
const profiles = group.profiles.map((p) => ({ ...p, resourceSha256: configurationResourceHash(p.resource) }));
|
|
151
|
+
const result = freeze({ group, sha256: configurationResourceHash(group), profiles });
|
|
152
|
+
snapshots.add(result);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
export function assertConfigurationGroupSnapshot(value) {
|
|
156
|
+
if (!snapshots.has(value))
|
|
157
|
+
throw Error("Exact SDK-issued configuration group snapshot required");
|
|
158
|
+
}
|
|
159
|
+
/** Optional data-only capability; packages without it keep their existing behavior. */
|
|
160
|
+
export function configurationGroupDescriptor(packageRoot) {
|
|
161
|
+
const file = path.join(packageRoot, "package.json");
|
|
162
|
+
// Ordinary Node/Python deployments do not opt in by existing on the host.
|
|
163
|
+
if (!fs.existsSync(file))
|
|
164
|
+
return undefined;
|
|
165
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
166
|
+
let bytes;
|
|
167
|
+
try {
|
|
168
|
+
const stat = fs.fstatSync(fd);
|
|
169
|
+
if (!stat.isFile() || stat.size > MAX_BYTES)
|
|
170
|
+
throw Error("Invalid installed runtime metadata");
|
|
171
|
+
bytes = fs.readFileSync(fd);
|
|
172
|
+
if (bytes.length > MAX_BYTES)
|
|
173
|
+
throw Error("Installed runtime metadata is too large");
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
fs.closeSync(fd);
|
|
177
|
+
}
|
|
178
|
+
const pkg = JSON.parse(bytes.toString());
|
|
179
|
+
const value = pkg.unsDatahub?.processGroupConfigurationRuntime;
|
|
180
|
+
if (value !== undefined && !readProcessGroupResource(file).equals(bytes))
|
|
181
|
+
throw Error("Installed runtime metadata changed during discovery");
|
|
182
|
+
return value === undefined ? undefined : configurationGroupDescriptorSchema.parse(value);
|
|
183
|
+
}
|
|
184
|
+
export function selectedConfigurationGroup(packageRoot, raw) {
|
|
185
|
+
const descriptor = configurationGroupDescriptor(packageRoot);
|
|
186
|
+
if (!descriptor)
|
|
187
|
+
return undefined;
|
|
188
|
+
const value = readConfigurationSelector(raw, descriptor.groupPath);
|
|
189
|
+
if (value === undefined)
|
|
190
|
+
return undefined;
|
|
191
|
+
if (descriptor.match && readConfigurationSelector(raw, descriptor.match.path) !== descriptor.match.value)
|
|
192
|
+
throw Error("Configuration group capability selector does not match");
|
|
193
|
+
return { descriptor, snapshot: configurationGroupSnapshot(value) };
|
|
194
|
+
}
|
|
195
|
+
export const configurationGroupJournalSchema = z.strictObject({
|
|
196
|
+
directory: z.string().startsWith("/").max(512),
|
|
197
|
+
journalId: z.string().uuid().optional(),
|
|
198
|
+
generationId: identity,
|
|
199
|
+
groupSha256: digest,
|
|
200
|
+
minFreeBytes: z
|
|
201
|
+
.number()
|
|
202
|
+
.int()
|
|
203
|
+
.min(1024 * 1024)
|
|
204
|
+
.max(1024 * 1024 * 1024)
|
|
205
|
+
.default(64 * 1024 * 1024),
|
|
206
|
+
maxRecords: z.number().int().min(1).max(100000).default(20000),
|
|
207
|
+
maxBytes: z
|
|
208
|
+
.number()
|
|
209
|
+
.int()
|
|
210
|
+
.min(1024)
|
|
211
|
+
.max(256 * 1024 * 1024)
|
|
212
|
+
.default(32 * 1024 * 1024),
|
|
213
|
+
});
|
|
214
|
+
export function configurationGroupJournalContract(snapshot, sourceIdentity, config, profiles) {
|
|
215
|
+
assertConfigurationGroupSnapshot(snapshot);
|
|
216
|
+
const journal = configurationGroupJournalSchema.parse(config);
|
|
217
|
+
if (journal.groupSha256 !== snapshot.sha256 || !digest.safeParse(sourceIdentity).success)
|
|
218
|
+
throw Error("Configuration group journal revision differs");
|
|
219
|
+
const expected = snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup }));
|
|
220
|
+
const normalize = (v) => [...v].sort((a, b) => (a.processName < b.processName ? -1 : a.processName > b.processName ? 1 : 0));
|
|
221
|
+
if (configurationResourceHash(normalize([...profiles])) !== configurationResourceHash(normalize(expected)))
|
|
222
|
+
throw Error("Configuration group journal profiles differ");
|
|
223
|
+
return configurationResourceJson({
|
|
224
|
+
version: 2,
|
|
225
|
+
generationId: journal.generationId,
|
|
226
|
+
groupSha256: snapshot.sha256,
|
|
227
|
+
sourceIdentity,
|
|
228
|
+
maxRecords: journal.maxRecords,
|
|
229
|
+
maxBytes: journal.maxBytes,
|
|
230
|
+
profiles: normalize(expected),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=configuration-group-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-group-contract.js","sourceRoot":"","sources":["../../src/runtime/configuration-group-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC5D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,CAAC;KACf,KAAK,CACJ,CAAC;KACE,MAAM,EAAE;KACR,KAAK,CAAC,+BAA+B,CAAC;KACtC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACzE;KACA,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,CAAC,CAAC,CAAC;AACV,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9B,6FAA6F;AAC7F,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,IAAI,KAAK,GAAG,CAAC,EACX,KAAK,GAAG,CAAC,CAAC;IACZ,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE;QAC9B,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,KAAK,GAAG,SAAS;YAAE,MAAM,KAAK,CAAC,sCAAsC,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,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACrI,MAAM,SAAS,GAAG,CAAC,CAAkB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9I,IAAI,yBAAyB,CAAC,SAAS,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,yBAAyB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACxG,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC7D,OAAO,yBAAyB,CAAC;QAC/B,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,WAAW,EAAE,QAAQ,CAAC,MAAM;QAC5B,cAAc;QACd,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport { readConfigurationSelector } from \"./process-group-contract.js\";\nimport { readProcessGroupResource } from \"./process-group-resources.js\";\n\nconst identity = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);\nconst digest = z.string().regex(/^[a-f0-9]{64}$/);\nconst selector = z\n .array(\n z\n .string()\n .regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,99}$/)\n .refine((v) => ![\"__proto__\", \"prototype\", \"constructor\"].includes(v)),\n )\n .min(1)\n .max(8);\nconst MAX_BYTES = 1024 * 1024;\n\n/** Versioned canonical JSON: binary key order, no locale, executable values or accessors. */\nexport function configurationResourceJson(value: unknown): string {\n let nodes = 0,\n bytes = 0;\n const ancestors = new Set<object>();\n const charge = (size: number) => {\n bytes += size;\n if (bytes > MAX_BYTES) throw Error(\"Configuration resource exceeds 1 MiB\");\n };\n function visit(v: unknown, depth: number): string {\n if (++nodes > 65536 || depth > 32) throw Error(\"Configuration resource exceeds its structural budget\");\n if (v === null || typeof v === \"boolean\") {\n charge(v === null ? 4 : v ? 4 : 5);\n return JSON.stringify(v);\n }\n if (typeof v === \"string\") {\n if (Buffer.byteLength(v) > MAX_BYTES) throw Error(\"Configuration resource string exceeds 1 MiB\");\n const encoded = JSON.stringify(v);\n charge(Buffer.byteLength(encoded));\n return encoded;\n }\n if (typeof v === \"number\" && Number.isFinite(v)) {\n const encoded = JSON.stringify(v);\n charge(encoded.length);\n return encoded;\n }\n if (!v || typeof v !== \"object\" || ancestors.has(v)) throw Error(\"Configuration resource must contain finite plain JSON only\");\n if (\n Array.isArray(v)\n ? Object.getPrototypeOf(v) !== Array.prototype\n : Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null\n )\n throw Error(\"Configuration resource must contain plain JSON objects\");\n if (Object.getOwnPropertySymbols(v).length) throw Error(\"Configuration resource cannot contain symbol properties\");\n const descriptors = Object.getOwnPropertyDescriptors(v);\n for (const [key, d] of Object.entries(descriptors)) {\n if (Array.isArray(v) && key === \"length\") continue;\n if (!d.enumerable || !Object.hasOwn(d, \"value\")) throw Error(\"Configuration resource cannot contain hidden properties or accessors\");\n }\n ancestors.add(v);\n charge(2); // Container brackets/braces.\n let result: string;\n if (Array.isArray(v)) {\n if (v.length > 65536 || Object.keys(v).length !== v.length || Object.keys(v).some((k, i) => k !== String(i)))\n throw Error(\"Configuration resource arrays must be dense JSON arrays\");\n charge(Math.max(0, v.length - 1));\n result = \"[\" + Array.from({ length: v.length }, (_, i) => visit(descriptors[String(i)]!.value, depth + 1)).join(\",\") + \"]\";\n } else\n result =\n \"{\" +\n Object.keys(v)\n .sort()\n .map((k, i) => {\n if (Buffer.byteLength(k) > MAX_BYTES) throw Error(\"Configuration resource key exceeds 1 MiB\");\n charge(Buffer.byteLength(JSON.stringify(k)) + 1 + (i ? 1 : 0));\n return JSON.stringify(k) + \":\" + visit(descriptors[k]!.value, depth + 1);\n })\n .join(\",\") +\n \"}\";\n ancestors.delete(v);\n return result;\n }\n const json = visit(value, 0);\n if (Buffer.byteLength(json) > MAX_BYTES) throw Error(\"Configuration resource exceeds 1 MiB\");\n return json;\n}\n\nexport function configurationResourceHash(value: unknown): string {\n return createHash(\"sha256\").update(\"uns-configuration-json-v1\\n\").update(configurationResourceJson(value)).digest(\"hex\");\n}\n\nexport const configurationGroupProfileSchema = z.strictObject({\n id: identity,\n processName: identity,\n dataGroup: identity,\n resource: z.unknown(),\n});\nexport const configurationGroupSchema = z.strictObject({\n schemaVersion: z.literal(2),\n id: identity,\n inputTopic: z\n .string()\n .min(1)\n .max(512)\n .regex(/^[^#+\\0]+$/),\n processName: identity,\n receiverProcessName: identity,\n profiles: z.array(configurationGroupProfileSchema).min(2).max(16),\n});\nexport const configurationGroupDescriptorSchema = z\n .strictObject({\n protocolVersion: z.literal(2),\n namespace: identity,\n publisherPath: selector,\n groupPath: selector,\n memberPath: selector,\n journalPath: selector,\n runtimeRolePath: selector,\n receiverRole: identity,\n match: z.strictObject({ path: selector, value: z.string().min(1).max(100) }).optional(),\n })\n .superRefine((d, context) => {\n const independent = [d.publisherPath, d.journalPath, d.runtimeRolePath].map((p) => p.join(\".\"));\n if (new Set(independent).size !== independent.length || independent.some((p, i) => independent.some((q, j) => i !== j && q.startsWith(p + \".\"))))\n context.addIssue({ code: \"custom\", message: \"Independent publisher, journal and role selectors required\" });\n const parent = d.publisherPath.join(\".\") + \".\",\n group = d.groupPath.join(\".\"),\n member = d.memberPath.join(\".\");\n if (\n !group.startsWith(parent) ||\n !member.startsWith(parent) ||\n group === member ||\n group.startsWith(member + \".\") ||\n member.startsWith(group + \".\")\n )\n context.addIssue({ code: \"custom\", message: \"Distinct group/member selectors within the publisher required\" });\n });\nexport type ConfigurationGroupDescriptor = z.infer<typeof configurationGroupDescriptorSchema>;\nexport type ConfigurationGroup = z.infer<typeof configurationGroupSchema>;\nexport interface ConfigurationGroupProfile {\n readonly id: string;\n readonly processName: string;\n readonly dataGroup: string;\n readonly resourceSha256: string;\n readonly resource: unknown;\n}\nexport interface ConfigurationGroupSnapshot {\n readonly group: Readonly<ConfigurationGroup>;\n readonly sha256: string;\n readonly profiles: readonly ConfigurationGroupProfile[];\n}\nconst snapshots = new WeakSet<object>();\nfunction freeze<T>(value: T): T {\n if (value && typeof value === \"object\") {\n for (const child of Object.values(value)) freeze(child);\n Object.freeze(value);\n }\n return value;\n}\nexport function configurationGroupSnapshot(value: unknown): ConfigurationGroupSnapshot {\n // Bound and copy before schema traversal; caller mutation cannot change a running revision.\n const group = configurationGroupSchema.parse(JSON.parse(configurationResourceJson(value)));\n const names = [group.processName, group.receiverProcessName, ...group.profiles.map((p) => p.processName)];\n if (new Set(names).size !== names.length || new Set(group.profiles.map((p) => p.id)).size !== group.profiles.length)\n throw Error(\"Configuration group identities overlap\");\n const profiles = group.profiles.map((p) => ({ ...p, resourceSha256: configurationResourceHash(p.resource) }));\n const result = freeze({ group, sha256: configurationResourceHash(group), profiles });\n snapshots.add(result);\n return result;\n}\nexport function assertConfigurationGroupSnapshot(value: ConfigurationGroupSnapshot): void {\n if (!snapshots.has(value)) throw Error(\"Exact SDK-issued configuration group snapshot required\");\n}\n\n/** Optional data-only capability; packages without it keep their existing behavior. */\nexport function configurationGroupDescriptor(packageRoot: string): ConfigurationGroupDescriptor | undefined {\n const file = path.join(packageRoot, \"package.json\");\n // Ordinary Node/Python deployments do not opt in by existing on the host.\n if (!fs.existsSync(file)) return undefined;\n const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n let bytes: Buffer;\n try {\n const stat = fs.fstatSync(fd);\n if (!stat.isFile() || stat.size > MAX_BYTES) throw Error(\"Invalid installed runtime metadata\");\n bytes = fs.readFileSync(fd);\n if (bytes.length > MAX_BYTES) throw Error(\"Installed runtime metadata is too large\");\n } finally {\n fs.closeSync(fd);\n }\n const pkg = JSON.parse(bytes.toString());\n const value = pkg.unsDatahub?.processGroupConfigurationRuntime;\n if (value !== undefined && !readProcessGroupResource(file).equals(bytes)) throw Error(\"Installed runtime metadata changed during discovery\");\n return value === undefined ? undefined : configurationGroupDescriptorSchema.parse(value);\n}\nexport function selectedConfigurationGroup(\n packageRoot: string,\n raw: Record<string, unknown>,\n):\n | {\n descriptor: ConfigurationGroupDescriptor;\n snapshot: ConfigurationGroupSnapshot;\n }\n | undefined {\n const descriptor = configurationGroupDescriptor(packageRoot);\n if (!descriptor) return undefined;\n const value = readConfigurationSelector(raw, descriptor.groupPath);\n if (value === undefined) return undefined;\n if (descriptor.match && readConfigurationSelector(raw, descriptor.match.path) !== descriptor.match.value)\n throw Error(\"Configuration group capability selector does not match\");\n return { descriptor, snapshot: configurationGroupSnapshot(value) };\n}\n\nexport const configurationGroupJournalSchema = z.strictObject({\n directory: z.string().startsWith(\"/\").max(512),\n journalId: z.string().uuid().optional(),\n generationId: identity,\n groupSha256: digest,\n minFreeBytes: z\n .number()\n .int()\n .min(1024 * 1024)\n .max(1024 * 1024 * 1024)\n .default(64 * 1024 * 1024),\n maxRecords: z.number().int().min(1).max(100000).default(20000),\n maxBytes: z\n .number()\n .int()\n .min(1024)\n .max(256 * 1024 * 1024)\n .default(32 * 1024 * 1024),\n});\nexport type ConfigurationGroupJournal = z.infer<typeof configurationGroupJournalSchema>;\nexport function configurationGroupJournalContract(\n snapshot: ConfigurationGroupSnapshot,\n sourceIdentity: string,\n config: ConfigurationGroupJournal,\n profiles: readonly { processName: string; resourceSha256: string; dataGroup: string }[],\n): string {\n assertConfigurationGroupSnapshot(snapshot);\n const journal = configurationGroupJournalSchema.parse(config);\n if (journal.groupSha256 !== snapshot.sha256 || !digest.safeParse(sourceIdentity).success)\n throw Error(\"Configuration group journal revision differs\");\n const expected = snapshot.profiles.map(({ processName, resourceSha256, dataGroup }) => ({ processName, resourceSha256, dataGroup }));\n const normalize = (v: typeof expected) => [...v].sort((a, b) => (a.processName < b.processName ? -1 : a.processName > b.processName ? 1 : 0));\n if (configurationResourceHash(normalize([...profiles])) !== configurationResourceHash(normalize(expected)))\n throw Error(\"Configuration group journal profiles differ\");\n return configurationResourceJson({\n version: 2,\n generationId: journal.generationId,\n groupSha256: snapshot.sha256,\n sourceIdentity,\n maxRecords: journal.maxRecords,\n maxBytes: journal.maxBytes,\n profiles: normalize(expected),\n });\n}\n"]}
|
|
@@ -52,6 +52,8 @@ interface GenericAuthorization {
|
|
|
52
52
|
readonly groupId: string;
|
|
53
53
|
readonly groupProcessName: string;
|
|
54
54
|
readonly namespace: string;
|
|
55
|
+
readonly generationId?: string;
|
|
56
|
+
readonly configurationGroupSha256?: string;
|
|
55
57
|
}
|
|
56
58
|
export type ProcessGroupAuthorization = legacy.HvAuthorization | GenericAuthorization;
|
|
57
59
|
export type HvAuthorization = ProcessGroupAuthorization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-authorization.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-authorization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,MAAM,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"process-group-authorization.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-authorization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,MAAM,MAAM,+CAA+C,CA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EAAE,MAAM,GAAG,SAAS,GAC3B,IAAI,CAwBN;AACD,eAAO,MAAM,oBAAoB,uCAAiC,CAAC"}
|
|
@@ -2,8 +2,9 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import * as legacy from "./compatibility/energenti-authorization-v1.js";
|
|
5
|
+
import { configurationGroupAuthorizationSchema, configurationGroupPolicyIdentity, verifyConfigurationGroupPolicy } from "./configuration-group-authorization.js";
|
|
5
6
|
import { normalizeProcessGroupConfiguration, processGroupDescriptor, resolvedProcessGroupChannels, } from "./process-group-contract.js";
|
|
6
|
-
import { configurationAuthorizationHash, groupArtifactHash, groupChannelsHash, readProcessGroupResource as read, sha256 as sha, } from "./process-group-resources.js";
|
|
7
|
+
import { configurationAuthorizationHash, groupArtifactHash, groupChannelsHash, readProcessGroupResource as read, sha256 as sha, assertPrivateProcessGroupDirectory, } from "./process-group-resources.js";
|
|
7
8
|
export { configurationAuthorizationHash, groupArtifactHash, groupChannelsHash } from "./process-group-resources.js";
|
|
8
9
|
export const hasProcessGroupAuthorization = legacy.hasProcessGroupAuthorization;
|
|
9
10
|
const digest = z.string().regex(/^[a-f0-9]{64}$/), id = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);
|
|
@@ -52,14 +53,7 @@ export const processGroupManifestSchema = z.strictObject({
|
|
|
52
53
|
export const hvAuthorizationSchema = legacy.hvAuthorizationSchema;
|
|
53
54
|
export const productionGroupIds = legacy.productionGroupIds;
|
|
54
55
|
const issued = new WeakSet();
|
|
55
|
-
|
|
56
|
-
for (let p = dir; p !== path.dirname(p); p = path.dirname(p))
|
|
57
|
-
if (fs.lstatSync(p).isSymbolicLink())
|
|
58
|
-
throw Error("Linked policy directory");
|
|
59
|
-
const s = fs.lstatSync(dir);
|
|
60
|
-
if (!s.isDirectory() || s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0)
|
|
61
|
-
throw Error("Insecure policy directory");
|
|
62
|
-
}
|
|
56
|
+
const privateDirectory = assertPrivateProcessGroupDirectory;
|
|
63
57
|
function registryRoot(root, dir) {
|
|
64
58
|
if (!path.isAbsolute(root) || path.resolve(root) !== root || path.resolve(dir) !== dir)
|
|
65
59
|
throw Error("Invalid policy registry");
|
|
@@ -74,6 +68,24 @@ function registryRoot(root, dir) {
|
|
|
74
68
|
return relative.split("/")[0];
|
|
75
69
|
}
|
|
76
70
|
function selectedFile(pkg, raw, root, explicit) {
|
|
71
|
+
const configured = configurationGroupPolicyIdentity(pkg, raw);
|
|
72
|
+
if (configured) {
|
|
73
|
+
if (explicit)
|
|
74
|
+
return explicit;
|
|
75
|
+
const directory = process.env["UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY"];
|
|
76
|
+
if (directory) {
|
|
77
|
+
const selected = registryRoot(root, directory);
|
|
78
|
+
if (selected !== "*" && selected !== configured.namespace)
|
|
79
|
+
throw Error("Foreign runtime registry");
|
|
80
|
+
const registry = selected === "*" ? path.join(root, configured.namespace, "authorizations") : directory;
|
|
81
|
+
privateDirectory(registry);
|
|
82
|
+
return path.join(registry, configured.generationId + ".json");
|
|
83
|
+
}
|
|
84
|
+
const single = process.env["UNS_PROCESS_GROUP_AUTHORIZATION_FILE"];
|
|
85
|
+
if (!single)
|
|
86
|
+
throw Error("No selected policy");
|
|
87
|
+
return single;
|
|
88
|
+
}
|
|
77
89
|
const descriptor = processGroupDescriptor(pkg);
|
|
78
90
|
if (!descriptor)
|
|
79
91
|
throw Error("Missing runtime contract");
|
|
@@ -175,10 +187,11 @@ export function configuredGroupProcessNames() {
|
|
|
175
187
|
const result = new Set();
|
|
176
188
|
for (const file of files) {
|
|
177
189
|
const raw = JSON.parse(read(file, true).toString());
|
|
178
|
-
const p = raw.schemaVersion === 3
|
|
190
|
+
const p = raw.schemaVersion === 4 ? configurationGroupAuthorizationSchema.parse(raw) : raw.schemaVersion === 3
|
|
179
191
|
? processGroupAuthorizationSchema.parse(raw)
|
|
180
192
|
: z.union([legacy.hvAuthorizationSchema, legacy.processGroupAuthorizationSchema]).parse(raw);
|
|
181
|
-
const { namespace, group } = p.schemaVersion ===
|
|
193
|
+
const { namespace, group } = p.schemaVersion === 4 ? { namespace: p.namespace, group: p.generationId }
|
|
194
|
+
: p.schemaVersion === 3 ? { namespace: p.namespace, group: p.groupId } : legacy.legacyPolicyIdentity(p);
|
|
182
195
|
if (p.stateRoot !== root ||
|
|
183
196
|
file !== path.join(root, namespace, "authorizations", group + ".json") ||
|
|
184
197
|
p.directory !== path.join(root, namespace, "admission", group))
|
|
@@ -200,6 +213,12 @@ function verifyRuntimePolicy(context, candidate) {
|
|
|
200
213
|
if (!root || !context.controllerName)
|
|
201
214
|
throw Error();
|
|
202
215
|
const file = selectedFile(context.packageRoot, context.rawConfiguration, root, context.file), bytes = candidate ?? read(file, true), unparsed = JSON.parse(bytes.toString());
|
|
216
|
+
if (unparsed.schemaVersion === 4) {
|
|
217
|
+
const result = verifyConfigurationGroupPolicy(context, bytes, root, file);
|
|
218
|
+
if (!candidate)
|
|
219
|
+
issued.add(result);
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
203
222
|
if (unparsed.schemaVersion !== 3) {
|
|
204
223
|
if (candidate)
|
|
205
224
|
throw Error("Only generic policies can be staged");
|
|
@@ -331,7 +350,7 @@ export function assertProcessGroupStateMount(value, root) {
|
|
|
331
350
|
return;
|
|
332
351
|
}
|
|
333
352
|
assertProcessGroupJournalAuthorization(value, value.directory, value.journalId ?? undefined);
|
|
334
|
-
if (process.platform !== "linux" || !("namespace" in value) || value.directory !== path.join(root, value.namespace, "admission", value.groupId))
|
|
353
|
+
if (process.platform !== "linux" || !("namespace" in value) || value.directory !== path.join(root, value.namespace, "admission", value.generationId ?? value.groupId))
|
|
335
354
|
throw Error("Process group requires its reviewed Linux state mount");
|
|
336
355
|
const mount = fs
|
|
337
356
|
.readFileSync("/proc/self/mountinfo", "utf8")
|
|
@@ -361,6 +380,9 @@ export function assertProcessGroupTargetLaunch(value, dir, operationId, launchId
|
|
|
361
380
|
!z.string().uuid().safeParse(r.lastLaunch?.requestId).success ||
|
|
362
381
|
!digest.safeParse(r.configurationChecksum).success)
|
|
363
382
|
throw Error();
|
|
383
|
+
if ("configurationGroupSha256" in value && value.configurationGroupSha256 !== undefined &&
|
|
384
|
+
(r.configurationGroupSha256 !== value.configurationGroupSha256 || r.generationId !== value.generationId))
|
|
385
|
+
throw Error();
|
|
364
386
|
}
|
|
365
387
|
catch {
|
|
366
388
|
throw Error("Target requires its exact reviewed group reservation and launch identity");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-group-authorization.js","sourceRoot":"","sources":["../../src/runtime/process-group-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,MAAM,MAAM,+CAA+C,CAAC;AACxE,OAAO,EAEL,kCAAkC,EAClC,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,8BAA8B,EAC9B,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,IAAI,IAAI,EAChC,MAAM,IAAI,GAAG,GACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEpH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,4BAA4B,CAAC;AAChF,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAC/C,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,CAAC;KACf,MAAM,EAAE;KACR,GAAG,CAAC,GAAG,CAAC;KACR,MAAM,CAAC,CAA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AAC,IAAI,KAAK,QAAQ;QAAE,OAAO;IACpC,IAAI,CAAC;QACH,sCAAsC,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC;QAC7F,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gCAAgC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9F,IACE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO;YACjD,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO;YAC9C,CAAC,CAAC,WAAW,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,KAAK,QAAQ;YACnB,CAAC,CAAC,UAAU,EAAE,QAAQ,KAAK,QAAQ;YACnC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,OAAO;YAC7D,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,OAAO;YAElD,MAAM,KAAK,EAAE,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AACD,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport * as legacy from \"./compatibility/energenti-authorization-v1.js\";\nimport {\n type ProcessGroupRuntimeDescriptor,\n normalizeProcessGroupConfiguration,\n processGroupDescriptor,\n resolvedProcessGroupChannels,\n} from \"./process-group-contract.js\";\nimport {\n configurationAuthorizationHash,\n groupArtifactHash,\n groupChannelsHash,\n readProcessGroupResource as read,\n sha256 as sha,\n} from \"./process-group-resources.js\";\n\nexport { configurationAuthorizationHash, groupArtifactHash, groupChannelsHash } from \"./process-group-resources.js\";\n\nexport const hasProcessGroupAuthorization = legacy.hasProcessGroupAuthorization;\nconst digest = z.string().regex(/^[a-f0-9]{64}$/),\n id = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);\nconst absolute = z\n .string()\n .max(512)\n .refine((v) => path.isAbsolute(v) && path.resolve(v) === v);\nconst placement = z.strictObject({\n instanceId: z.string().regex(/^[a-zA-Z0-9-]{1,100}$/),\n processName: id,\n role: z.enum([\"source\", \"target\", \"receiver\"]),\n configurationSha256: digest,\n});\nexport const processGroupAuthorizationSchema = z.strictObject({\n schemaVersion: z.literal(3),\n kind: z.literal(\"uns-process-group-runtime-authorization\"),\n protocolVersion: z.literal(1),\n packageName: z.string().min(1).max(214),\n namespace: id,\n groupId: id,\n descriptorSha256: digest,\n controllerName: z.string().min(1).max(100),\n packageRoot: absolute,\n artifactSha256: digest,\n groupManifestSha256: digest,\n channelsSha256: digest,\n stateRoot: absolute,\n directory: absolute,\n journalId: z.string().uuid().nullable(),\n placements: z.array(placement).min(4).max(18),\n});\nexport type ProcessGroupAuthorizationPolicy = z.infer<typeof processGroupAuthorizationSchema>;\nexport const processGroupManifestSchema = z.strictObject({\n schemaVersion: z.literal(1),\n id,\n inputTopic: z\n .string()\n .min(1)\n .max(512)\n .regex(/^[^#+\\0]+$/),\n processName: id,\n profiles: z\n .array(z.strictObject({ id, processName: id, mappingFile: z.string().min(1).max(512), mappingSha256: digest, dataGroup: id }))\n .min(2)\n .max(16),\n});\ninterface GenericAuthorization {\n readonly sha256: string;\n readonly file: string;\n readonly directory: string;\n readonly journalId: string | null;\n readonly role: \"source\" | \"target\" | \"receiver\";\n readonly groupId: string;\n readonly groupProcessName: string;\n readonly namespace: string;\n}\nexport type ProcessGroupAuthorization = legacy.HvAuthorization | GenericAuthorization;\nexport type HvAuthorization = ProcessGroupAuthorization;\nexport type HvAuthorizationPolicy = legacy.HvAuthorizationPolicy;\nexport const hvAuthorizationSchema = legacy.hvAuthorizationSchema;\nexport const productionGroupIds = legacy.productionGroupIds;\nconst issued = new WeakSet<object>();\nfunction privateDirectory(dir: string): void {\n for (let p = dir; p !== path.dirname(p); p = path.dirname(p)) if (fs.lstatSync(p).isSymbolicLink()) throw Error(\"Linked policy directory\");\n const s = fs.lstatSync(dir);\n if (!s.isDirectory() || s.uid !== process.getuid?.() || (s.mode & 0o077) !== 0) throw Error(\"Insecure policy directory\");\n}\nfunction registryRoot(root: string, dir: string): string {\n if (!path.isAbsolute(root) || path.resolve(root) !== root || path.resolve(dir) !== dir) throw Error(\"Invalid policy registry\");\n privateDirectory(root);\n if (dir === root) return \"*\"; // Explicit collection of independently owned namespaces.\n const relative = path.relative(root, dir);\n if (!path.isAbsolute(root) || path.resolve(root) !== root || !/^([a-z][a-z0-9-]{0,99})\\/authorizations$/.test(relative))\n throw Error(\"Invalid policy registry\");\n privateDirectory(root);\n privateDirectory(dir);\n return relative.split(\"/\")[0]!;\n}\nfunction selectedFile(pkg: string, raw: Record<string, unknown>, root: string, explicit?: string): string {\n const descriptor = processGroupDescriptor(pkg);\n if (!descriptor) throw Error(\"Missing runtime contract\");\n const c = normalizeProcessGroupConfiguration(raw, descriptor),\n journal = c.journal as Record<string, unknown> | undefined;\n const manifest = descriptor.manifests.find((m) => m.file === journal?.[\"groupManifest\"]);\n if (!manifest) throw Error(\"Unregistered group manifest\");\n const dir = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY\"];\n if (explicit) return explicit;\n if (dir) {\n const selected = registryRoot(root, dir);\n if (selected !== \"*\" && selected !== descriptor.namespace) throw Error(\"Foreign runtime registry\");\n const registry = selected === \"*\" ? path.join(root, descriptor.namespace, \"authorizations\") : dir;\n privateDirectory(registry);\n return path.join(registry, manifest.id + \".json\");\n }\n const single = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_FILE\"];\n if (!single) throw Error(\"No selected policy\");\n return single;\n}\n/** Bounded private registry enumeration; retained state without its policy fails closed.\n * New groups are operator-owned data and never a release-time enum in the Controller.\n */\nexport function configuredGroupProcessNames(): Set<string> {\n if (!hasProcessGroupAuthorization()) return new Set();\n try {\n const root = process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root) throw Error();\n const files = new Set<string>();\n const single = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_FILE\"];\n if (single) files.add(single);\n const dir = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY\"];\n if (dir) {\n const selected = registryRoot(root, dir);\n let registries: { namespace: string; directory: string }[];\n if (selected === \"*\") {\n const namespaces = fs.readdirSync(root, { withFileTypes: true });\n if (namespaces.length > 64 || namespaces.some((e) => e.isSymbolicLink())) throw Error(\"Registry namespace budget or link violation\");\n registries = namespaces\n .filter((e) => e.isDirectory())\n .map((e) => {\n if (!id.safeParse(e.name).success) throw Error(\"Invalid registry namespace\");\n privateDirectory(path.join(root, e.name));\n return { namespace: e.name, directory: path.join(root, e.name, \"authorizations\") };\n });\n } else registries = [{ namespace: selected, directory: dir }];\n for (const registry of registries) {\n let entries: fs.Dirent[] = [];\n try {\n privateDirectory(registry.directory);\n entries = fs.readdirSync(registry.directory, { withFileTypes: true });\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n if (entries.length > 64) throw Error(\"Policy registry budget exceeded\");\n for (const entry of entries)\n if (entry.name.endsWith(\".json\")) {\n if (!/^[a-z][a-z0-9-]{0,99}\\.json$/.test(entry.name)) throw Error(\"Invalid registry entry\");\n files.add(path.join(registry.directory, entry.name));\n if (files.size > 64) throw Error(\"Total policy registry budget exceeded\");\n }\n const journals = path.join(root, registry.namespace, \"admission\");\n try {\n // Root/registry permissions already protect visibility; retain old parent modes.\n for (let parent = journals; parent !== path.dirname(parent); parent = path.dirname(parent))\n if (fs.lstatSync(parent).isSymbolicLink()) throw Error(\"Linked journal registry\");\n const retained = fs.readdirSync(journals, { withFileTypes: true });\n if (retained.length > 64) throw Error(\"Retained journal budget exceeded\");\n for (const entry of retained)\n if (\n !id.safeParse(entry.name).success ||\n entry.isSymbolicLink() ||\n !entry.isDirectory() ||\n !files.has(path.join(registry.directory, entry.name + \".json\"))\n )\n throw Error(\"Retained journal has no reviewed policy\");\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n }\n }\n const result = new Set<string>();\n for (const file of files) {\n const raw = JSON.parse(read(file, true).toString());\n const p =\n raw.schemaVersion === 3\n ? processGroupAuthorizationSchema.parse(raw)\n : z.union([legacy.hvAuthorizationSchema, legacy.processGroupAuthorizationSchema]).parse(raw);\n const { namespace, group } = p.schemaVersion === 3 ? { namespace: p.namespace, group: p.groupId } : legacy.legacyPolicyIdentity(p);\n if (\n p.stateRoot !== root ||\n file !== path.join(root, namespace, \"authorizations\", group + \".json\") ||\n p.directory !== path.join(root, namespace, \"admission\", group)\n )\n throw Error();\n privateDirectory(root);\n privateDirectory(path.dirname(file));\n for (const role of p.placements) result.add(role.processName);\n }\n return result;\n } catch {\n throw Error(\"Process-group authorization registry is missing, changed or insecure; review required\");\n }\n}\nexport interface ProcessGroupAuthorizationContext {\n packageRoot: string;\n instanceDirectory: string;\n rawConfiguration: Record<string, unknown>;\n channels: unknown[];\n controllerName: string;\n file?: string;\n stateRoot?: string;\n initialize?: boolean;\n}\nfunction verifyRuntimePolicy(context: ProcessGroupAuthorizationContext, candidate?: Buffer): ProcessGroupAuthorization {\n try {\n const root = context.stateRoot ?? process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root || !context.controllerName) throw Error();\n const file = selectedFile(context.packageRoot, context.rawConfiguration, root, context.file),\n bytes = candidate ?? read(file, true),\n unparsed = JSON.parse(bytes.toString());\n if (unparsed.schemaVersion !== 3) {\n if (candidate) throw Error(\"Only generic policies can be staged\");\n return legacy.authorizeHvRuntime({ ...context, file, stateRoot: root });\n }\n const p = processGroupAuthorizationSchema.parse(unparsed),\n d = processGroupDescriptor(context.packageRoot);\n if (!d || d.legacy) throw Error(\"Generic runtime descriptor required\");\n const pkg = JSON.parse(read(path.join(context.packageRoot, \"package.json\")).toString());\n const manifest = d.manifests.find((m) => m.id === p.groupId);\n if (\n !manifest ||\n p.packageName !== pkg.name ||\n p.namespace !== d.namespace ||\n p.descriptorSha256 !== configurationAuthorizationHash(pkg.unsDatahub.processGroupRuntime) ||\n p.packageRoot !== context.packageRoot ||\n p.controllerName !== context.controllerName ||\n p.stateRoot !== root ||\n file !== path.join(root, d.namespace, \"authorizations\", p.groupId + \".json\") ||\n p.directory !== path.join(root, d.namespace, \"admission\", p.groupId)\n )\n throw Error();\n privateDirectory(root);\n privateDirectory(path.dirname(file));\n if (groupArtifactHash(context.packageRoot) !== p.artifactSha256 || groupChannelsHash(context.channels) !== p.channelsSha256) throw Error();\n const manifestBytes = read(path.join(context.packageRoot, manifest.file));\n if (sha(manifestBytes) !== p.groupManifestSha256) throw Error();\n const m = processGroupManifestSchema.parse(JSON.parse(manifestBytes.toString()));\n if (m.id !== p.groupId) throw Error();\n const receiver = m.processName + \"-admission\";\n if (\n new Set(m.profiles.map((x) => x.id)).size !== m.profiles.length ||\n new Set(m.profiles.map((x) => x.processName)).size !== m.profiles.length ||\n m.profiles.some((x) => x.processName === m.processName || x.processName === receiver)\n )\n throw Error();\n for (const member of m.profiles) {\n const f = path.resolve(context.packageRoot, path.dirname(manifest.file), member.mappingFile);\n if (!f.startsWith(context.packageRoot + path.sep) || sha(read(f)) !== member.mappingSha256) throw Error();\n }\n const expected = new Map([\n ...m.profiles.map((x) => [x.processName, \"source\"] as const),\n [m.processName, \"target\"] as const,\n [receiver, \"receiver\"] as const,\n ]);\n if (\n p.placements.length !== expected.size ||\n new Set(p.placements.map((x) => x.instanceId)).size !== expected.size ||\n new Set(p.placements.map((x) => x.processName)).size !== expected.size ||\n p.placements.some((x) => expected.get(x.processName) !== x.role)\n )\n throw Error();\n const entry = p.placements.find((x) => context.instanceDirectory === path.join(context.packageRoot, \"instances\", x.instanceId));\n const c = normalizeProcessGroupConfiguration(context.rawConfiguration, d),\n j = c.journal as Record<string, unknown> | undefined,\n k = c.publisher;\n if (\n !entry ||\n !c.matches ||\n entry.processName !== c.uns?.[\"processName\"] ||\n entry.configurationSha256 !== configurationAuthorizationHash(context.rawConfiguration) ||\n !j ||\n j[\"directory\"] !== p.directory ||\n (j[\"journalId\"] ?? null) !== p.journalId ||\n j[\"groupManifest\"] !== manifest.file\n )\n throw Error();\n if (context.initialize ? p.journalId !== null || entry.role !== \"receiver\" : p.journalId === null) throw Error();\n if (entry.role === \"receiver\" ? c.runtimeRole !== \"admission\" : c.runtimeRole !== undefined && c.runtimeRole !== \"publisher\") throw Error();\n const member = m.profiles.find((x) => x.processName === entry.processName),\n mapping = path.resolve(context.packageRoot, String(k[\"mappingFile\"]));\n if (\n entry.role !== \"source\"\n ? k[\"groupManifest\"] !== manifest.file\n : k[\"groupManifest\"] !== undefined ||\n k[\"dataGroup\"] !== member?.dataGroup ||\n !mapping.startsWith(context.packageRoot + path.sep) ||\n sha(read(mapping)) !== member?.mappingSha256\n )\n throw Error();\n const result = Object.freeze({\n sha256: sha(bytes),\n file,\n directory: p.directory,\n journalId: p.journalId,\n role: entry.role,\n groupId: p.groupId,\n groupProcessName: m.processName,\n namespace: d.namespace,\n });\n if (!candidate) issued.add(result);\n return result;\n } catch {\n throw Error(\"Process-group runtime authorization is missing, changed or does not match this installed placement; review required\");\n }\n}\n/** Live authority always comes from the current canonical private policy. */\nexport function authorizeProcessGroupRuntime(context: ProcessGroupAuthorizationContext): ProcessGroupAuthorization {\n return verifyRuntimePolicy(context);\n}\n/** Review only: never issues an authorization accepted by runtime/launch checks. */\nexport function validateProcessGroupPolicyCandidate(context: ProcessGroupAuthorizationContext, bytes: Buffer): void {\n verifyRuntimePolicy(context, bytes);\n}\nexport function processGroupAuthorizationFile(context: ProcessGroupAuthorizationContext): string {\n const root = context.stateRoot ?? process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root) throw Error(\"Missing process-group state root\");\n return selectedFile(context.packageRoot, context.rawConfiguration, root, context.file);\n}\nexport const authorizeHvRuntime = authorizeProcessGroupRuntime;\nexport function authorizeConfiguredProcessGroupRuntime(\n pkg: string,\n dir: string,\n raw: Record<string, unknown>,\n controllerName: string,\n initialize = false,\n) {\n return authorizeProcessGroupRuntime({\n packageRoot: pkg,\n instanceDirectory: dir,\n rawConfiguration: raw,\n channels: resolvedProcessGroupChannels(raw),\n controllerName,\n initialize,\n });\n}\nexport function assertProcessGroupJournalAuthorization(\n value: ProcessGroupAuthorization | undefined,\n directory: string,\n journalId: string | undefined,\n): void {\n if (value && issued.has(value)) {\n if (value.directory !== directory || value.journalId !== (journalId ?? null) || sha(read(value.file, true)) !== value.sha256)\n throw Error(\"Exact reviewed process-group authorization required\");\n return;\n }\n legacy.assertHvJournalAuthorization(value as legacy.HvAuthorization | undefined, directory, journalId);\n}\nexport const assertHvJournalAuthorization = assertProcessGroupJournalAuthorization;\nexport function assertProcessGroupStateMount(value: ProcessGroupAuthorization, root: string): void {\n if (!issued.has(value)) {\n legacy.assertHvStateMount(value as legacy.HvAuthorization, root);\n return;\n }\n assertProcessGroupJournalAuthorization(value, value.directory, value.journalId ?? undefined);\n if (process.platform !== \"linux\" || !(\"namespace\" in value) || value.directory !== path.join(root, value.namespace, \"admission\", value.groupId))\n throw Error(\"Process group requires its reviewed Linux state mount\");\n const mount = fs\n .readFileSync(\"/proc/self/mountinfo\", \"utf8\")\n .split(\"\\n\")\n .map((l) => l.split(\" \"))\n .filter((f) => f[4] === root)\n .at(-1);\n if (!mount || !mount[5]?.split(\",\").includes(\"rw\") || ![\"xfs\", \"ext4\", \"btrfs\", \"zfs\"].includes(mount[mount.indexOf(\"-\") + 1] ?? \"\"))\n throw Error(\"Process-group state root must be an explicit writable local Linux filesystem mount\");\n}\nexport const assertHvStateMount = assertProcessGroupStateMount;\nexport function assertProcessGroupTargetLaunch(\n value: ProcessGroupAuthorization,\n dir: string,\n operationId: string | undefined,\n launchId: string | undefined,\n): void {\n if (!issued.has(value)) {\n legacy.assertHvTargetLaunch(value as legacy.HvAuthorization, dir, operationId, launchId);\n return;\n }\n if (value.role !== \"target\") return;\n try {\n assertProcessGroupJournalAuthorization(value, value.directory, value.journalId ?? undefined);\n const r = JSON.parse(read(path.join(dir, \"process-group-reservation.json\"), true).toString());\n if (\n !z.string().uuid().safeParse(operationId).success ||\n !z.string().uuid().safeParse(launchId).success ||\n r.operationId !== operationId ||\n r.role !== \"target\" ||\n r.lastLaunch?.launchId !== launchId ||\n !z.string().uuid().safeParse(r.lastLaunch?.requestId).success ||\n !digest.safeParse(r.configurationChecksum).success\n )\n throw Error();\n } catch {\n throw Error(\"Target requires its exact reviewed group reservation and launch identity\");\n }\n}\nexport const assertHvTargetLaunch = assertProcessGroupTargetLaunch;\n"]}
|
|
1
|
+
{"version":3,"file":"process-group-authorization.js","sourceRoot":"","sources":["../../src/runtime/process-group-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,MAAM,MAAM,+CAA+C,CAAC;AACxE,OAAO,EAAE,qCAAqC,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACjK,OAAO,EAEL,kCAAkC,EAClC,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,8BAA8B,EAC9B,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,IAAI,IAAI,EAChC,MAAM,IAAI,GAAG,EACb,kCAAkC,GACnC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,iBA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AM,oBAAoB,GAAG,8BAA8B,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nimport * as legacy from \"./compatibility/energenti-authorization-v1.js\";\nimport { configurationGroupAuthorizationSchema, configurationGroupPolicyIdentity, verifyConfigurationGroupPolicy } from \"./configuration-group-authorization.js\";\nimport {\n type ProcessGroupRuntimeDescriptor,\n normalizeProcessGroupConfiguration,\n processGroupDescriptor,\n resolvedProcessGroupChannels,\n} from \"./process-group-contract.js\";\nimport {\n configurationAuthorizationHash,\n groupArtifactHash,\n groupChannelsHash,\n readProcessGroupResource as read,\n sha256 as sha,\n assertPrivateProcessGroupDirectory,\n} from \"./process-group-resources.js\";\n\nexport { configurationAuthorizationHash, groupArtifactHash, groupChannelsHash } from \"./process-group-resources.js\";\n\nexport const hasProcessGroupAuthorization = legacy.hasProcessGroupAuthorization;\nconst digest = z.string().regex(/^[a-f0-9]{64}$/),\n id = z.string().regex(/^[a-z][a-z0-9-]{0,99}$/);\nconst absolute = z\n .string()\n .max(512)\n .refine((v) => path.isAbsolute(v) && path.resolve(v) === v);\nconst placement = z.strictObject({\n instanceId: z.string().regex(/^[a-zA-Z0-9-]{1,100}$/),\n processName: id,\n role: z.enum([\"source\", \"target\", \"receiver\"]),\n configurationSha256: digest,\n});\nexport const processGroupAuthorizationSchema = z.strictObject({\n schemaVersion: z.literal(3),\n kind: z.literal(\"uns-process-group-runtime-authorization\"),\n protocolVersion: z.literal(1),\n packageName: z.string().min(1).max(214),\n namespace: id,\n groupId: id,\n descriptorSha256: digest,\n controllerName: z.string().min(1).max(100),\n packageRoot: absolute,\n artifactSha256: digest,\n groupManifestSha256: digest,\n channelsSha256: digest,\n stateRoot: absolute,\n directory: absolute,\n journalId: z.string().uuid().nullable(),\n placements: z.array(placement).min(4).max(18),\n});\nexport type ProcessGroupAuthorizationPolicy = z.infer<typeof processGroupAuthorizationSchema>;\nexport const processGroupManifestSchema = z.strictObject({\n schemaVersion: z.literal(1),\n id,\n inputTopic: z\n .string()\n .min(1)\n .max(512)\n .regex(/^[^#+\\0]+$/),\n processName: id,\n profiles: z\n .array(z.strictObject({ id, processName: id, mappingFile: z.string().min(1).max(512), mappingSha256: digest, dataGroup: id }))\n .min(2)\n .max(16),\n});\ninterface GenericAuthorization {\n readonly sha256: string;\n readonly file: string;\n readonly directory: string;\n readonly journalId: string | null;\n readonly role: \"source\" | \"target\" | \"receiver\";\n readonly groupId: string;\n readonly groupProcessName: string;\n readonly namespace: string;\n readonly generationId?: string;\n readonly configurationGroupSha256?: string;\n}\nexport type ProcessGroupAuthorization = legacy.HvAuthorization | GenericAuthorization;\nexport type HvAuthorization = ProcessGroupAuthorization;\nexport type HvAuthorizationPolicy = legacy.HvAuthorizationPolicy;\nexport const hvAuthorizationSchema = legacy.hvAuthorizationSchema;\nexport const productionGroupIds = legacy.productionGroupIds;\nconst issued = new WeakSet<object>();\nconst privateDirectory = assertPrivateProcessGroupDirectory;\nfunction registryRoot(root: string, dir: string): string {\n if (!path.isAbsolute(root) || path.resolve(root) !== root || path.resolve(dir) !== dir) throw Error(\"Invalid policy registry\");\n privateDirectory(root);\n if (dir === root) return \"*\"; // Explicit collection of independently owned namespaces.\n const relative = path.relative(root, dir);\n if (!path.isAbsolute(root) || path.resolve(root) !== root || !/^([a-z][a-z0-9-]{0,99})\\/authorizations$/.test(relative))\n throw Error(\"Invalid policy registry\");\n privateDirectory(root);\n privateDirectory(dir);\n return relative.split(\"/\")[0]!;\n}\nfunction selectedFile(pkg: string, raw: Record<string, unknown>, root: string, explicit?: string): string {\n const configured = configurationGroupPolicyIdentity(pkg, raw);\n if (configured) {\n if (explicit) return explicit;\n const directory = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY\"];\n if (directory) {\n const selected = registryRoot(root, directory);\n if (selected !== \"*\" && selected !== configured.namespace) throw Error(\"Foreign runtime registry\");\n const registry = selected === \"*\" ? path.join(root, configured.namespace, \"authorizations\") : directory;\n privateDirectory(registry);\n return path.join(registry, configured.generationId + \".json\");\n }\n const single = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_FILE\"];\n if (!single) throw Error(\"No selected policy\");\n return single;\n }\n const descriptor = processGroupDescriptor(pkg);\n if (!descriptor) throw Error(\"Missing runtime contract\");\n const c = normalizeProcessGroupConfiguration(raw, descriptor),\n journal = c.journal as Record<string, unknown> | undefined;\n const manifest = descriptor.manifests.find((m) => m.file === journal?.[\"groupManifest\"]);\n if (!manifest) throw Error(\"Unregistered group manifest\");\n const dir = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY\"];\n if (explicit) return explicit;\n if (dir) {\n const selected = registryRoot(root, dir);\n if (selected !== \"*\" && selected !== descriptor.namespace) throw Error(\"Foreign runtime registry\");\n const registry = selected === \"*\" ? path.join(root, descriptor.namespace, \"authorizations\") : dir;\n privateDirectory(registry);\n return path.join(registry, manifest.id + \".json\");\n }\n const single = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_FILE\"];\n if (!single) throw Error(\"No selected policy\");\n return single;\n}\n/** Bounded private registry enumeration; retained state without its policy fails closed.\n * New groups are operator-owned data and never a release-time enum in the Controller.\n */\nexport function configuredGroupProcessNames(): Set<string> {\n if (!hasProcessGroupAuthorization()) return new Set();\n try {\n const root = process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root) throw Error();\n const files = new Set<string>();\n const single = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_FILE\"];\n if (single) files.add(single);\n const dir = process.env[\"UNS_PROCESS_GROUP_AUTHORIZATION_DIRECTORY\"];\n if (dir) {\n const selected = registryRoot(root, dir);\n let registries: { namespace: string; directory: string }[];\n if (selected === \"*\") {\n const namespaces = fs.readdirSync(root, { withFileTypes: true });\n if (namespaces.length > 64 || namespaces.some((e) => e.isSymbolicLink())) throw Error(\"Registry namespace budget or link violation\");\n registries = namespaces\n .filter((e) => e.isDirectory())\n .map((e) => {\n if (!id.safeParse(e.name).success) throw Error(\"Invalid registry namespace\");\n privateDirectory(path.join(root, e.name));\n return { namespace: e.name, directory: path.join(root, e.name, \"authorizations\") };\n });\n } else registries = [{ namespace: selected, directory: dir }];\n for (const registry of registries) {\n let entries: fs.Dirent[] = [];\n try {\n privateDirectory(registry.directory);\n entries = fs.readdirSync(registry.directory, { withFileTypes: true });\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n if (entries.length > 64) throw Error(\"Policy registry budget exceeded\");\n for (const entry of entries)\n if (entry.name.endsWith(\".json\")) {\n if (!/^[a-z][a-z0-9-]{0,99}\\.json$/.test(entry.name)) throw Error(\"Invalid registry entry\");\n files.add(path.join(registry.directory, entry.name));\n if (files.size > 64) throw Error(\"Total policy registry budget exceeded\");\n }\n const journals = path.join(root, registry.namespace, \"admission\");\n try {\n // Root/registry permissions already protect visibility; retain old parent modes.\n for (let parent = journals; parent !== path.dirname(parent); parent = path.dirname(parent))\n if (fs.lstatSync(parent).isSymbolicLink()) throw Error(\"Linked journal registry\");\n const retained = fs.readdirSync(journals, { withFileTypes: true });\n if (retained.length > 64) throw Error(\"Retained journal budget exceeded\");\n for (const entry of retained)\n if (\n !id.safeParse(entry.name).success ||\n entry.isSymbolicLink() ||\n !entry.isDirectory() ||\n !files.has(path.join(registry.directory, entry.name + \".json\"))\n )\n throw Error(\"Retained journal has no reviewed policy\");\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n }\n }\n const result = new Set<string>();\n for (const file of files) {\n const raw = JSON.parse(read(file, true).toString());\n const p =\n raw.schemaVersion === 4 ? configurationGroupAuthorizationSchema.parse(raw) : raw.schemaVersion === 3\n ? processGroupAuthorizationSchema.parse(raw)\n : z.union([legacy.hvAuthorizationSchema, legacy.processGroupAuthorizationSchema]).parse(raw);\n const { namespace, group } = p.schemaVersion === 4 ? { namespace: p.namespace, group: p.generationId }\n : p.schemaVersion === 3 ? { namespace: p.namespace, group: p.groupId } : legacy.legacyPolicyIdentity(p);\n if (\n p.stateRoot !== root ||\n file !== path.join(root, namespace, \"authorizations\", group + \".json\") ||\n p.directory !== path.join(root, namespace, \"admission\", group)\n )\n throw Error();\n privateDirectory(root);\n privateDirectory(path.dirname(file));\n for (const role of p.placements) result.add(role.processName);\n }\n return result;\n } catch {\n throw Error(\"Process-group authorization registry is missing, changed or insecure; review required\");\n }\n}\nexport interface ProcessGroupAuthorizationContext {\n packageRoot: string;\n instanceDirectory: string;\n rawConfiguration: Record<string, unknown>;\n channels: unknown[];\n controllerName: string;\n file?: string;\n stateRoot?: string;\n initialize?: boolean;\n}\nfunction verifyRuntimePolicy(context: ProcessGroupAuthorizationContext, candidate?: Buffer): ProcessGroupAuthorization {\n try {\n const root = context.stateRoot ?? process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root || !context.controllerName) throw Error();\n const file = selectedFile(context.packageRoot, context.rawConfiguration, root, context.file),\n bytes = candidate ?? read(file, true),\n unparsed = JSON.parse(bytes.toString());\n if (unparsed.schemaVersion === 4) {\n const result = verifyConfigurationGroupPolicy(context, bytes, root, file);\n if (!candidate) issued.add(result);\n return result;\n }\n if (unparsed.schemaVersion !== 3) {\n if (candidate) throw Error(\"Only generic policies can be staged\");\n return legacy.authorizeHvRuntime({ ...context, file, stateRoot: root });\n }\n const p = processGroupAuthorizationSchema.parse(unparsed),\n d = processGroupDescriptor(context.packageRoot);\n if (!d || d.legacy) throw Error(\"Generic runtime descriptor required\");\n const pkg = JSON.parse(read(path.join(context.packageRoot, \"package.json\")).toString());\n const manifest = d.manifests.find((m) => m.id === p.groupId);\n if (\n !manifest ||\n p.packageName !== pkg.name ||\n p.namespace !== d.namespace ||\n p.descriptorSha256 !== configurationAuthorizationHash(pkg.unsDatahub.processGroupRuntime) ||\n p.packageRoot !== context.packageRoot ||\n p.controllerName !== context.controllerName ||\n p.stateRoot !== root ||\n file !== path.join(root, d.namespace, \"authorizations\", p.groupId + \".json\") ||\n p.directory !== path.join(root, d.namespace, \"admission\", p.groupId)\n )\n throw Error();\n privateDirectory(root);\n privateDirectory(path.dirname(file));\n if (groupArtifactHash(context.packageRoot) !== p.artifactSha256 || groupChannelsHash(context.channels) !== p.channelsSha256) throw Error();\n const manifestBytes = read(path.join(context.packageRoot, manifest.file));\n if (sha(manifestBytes) !== p.groupManifestSha256) throw Error();\n const m = processGroupManifestSchema.parse(JSON.parse(manifestBytes.toString()));\n if (m.id !== p.groupId) throw Error();\n const receiver = m.processName + \"-admission\";\n if (\n new Set(m.profiles.map((x) => x.id)).size !== m.profiles.length ||\n new Set(m.profiles.map((x) => x.processName)).size !== m.profiles.length ||\n m.profiles.some((x) => x.processName === m.processName || x.processName === receiver)\n )\n throw Error();\n for (const member of m.profiles) {\n const f = path.resolve(context.packageRoot, path.dirname(manifest.file), member.mappingFile);\n if (!f.startsWith(context.packageRoot + path.sep) || sha(read(f)) !== member.mappingSha256) throw Error();\n }\n const expected = new Map([\n ...m.profiles.map((x) => [x.processName, \"source\"] as const),\n [m.processName, \"target\"] as const,\n [receiver, \"receiver\"] as const,\n ]);\n if (\n p.placements.length !== expected.size ||\n new Set(p.placements.map((x) => x.instanceId)).size !== expected.size ||\n new Set(p.placements.map((x) => x.processName)).size !== expected.size ||\n p.placements.some((x) => expected.get(x.processName) !== x.role)\n )\n throw Error();\n const entry = p.placements.find((x) => context.instanceDirectory === path.join(context.packageRoot, \"instances\", x.instanceId));\n const c = normalizeProcessGroupConfiguration(context.rawConfiguration, d),\n j = c.journal as Record<string, unknown> | undefined,\n k = c.publisher;\n if (\n !entry ||\n !c.matches ||\n entry.processName !== c.uns?.[\"processName\"] ||\n entry.configurationSha256 !== configurationAuthorizationHash(context.rawConfiguration) ||\n !j ||\n j[\"directory\"] !== p.directory ||\n (j[\"journalId\"] ?? null) !== p.journalId ||\n j[\"groupManifest\"] !== manifest.file\n )\n throw Error();\n if (context.initialize ? p.journalId !== null || entry.role !== \"receiver\" : p.journalId === null) throw Error();\n if (entry.role === \"receiver\" ? c.runtimeRole !== \"admission\" : c.runtimeRole !== undefined && c.runtimeRole !== \"publisher\") throw Error();\n const member = m.profiles.find((x) => x.processName === entry.processName),\n mapping = path.resolve(context.packageRoot, String(k[\"mappingFile\"]));\n if (\n entry.role !== \"source\"\n ? k[\"groupManifest\"] !== manifest.file\n : k[\"groupManifest\"] !== undefined ||\n k[\"dataGroup\"] !== member?.dataGroup ||\n !mapping.startsWith(context.packageRoot + path.sep) ||\n sha(read(mapping)) !== member?.mappingSha256\n )\n throw Error();\n const result = Object.freeze({\n sha256: sha(bytes),\n file,\n directory: p.directory,\n journalId: p.journalId,\n role: entry.role,\n groupId: p.groupId,\n groupProcessName: m.processName,\n namespace: d.namespace,\n });\n if (!candidate) issued.add(result);\n return result;\n } catch {\n throw Error(\"Process-group runtime authorization is missing, changed or does not match this installed placement; review required\");\n }\n}\n/** Live authority always comes from the current canonical private policy. */\nexport function authorizeProcessGroupRuntime(context: ProcessGroupAuthorizationContext): ProcessGroupAuthorization {\n return verifyRuntimePolicy(context);\n}\n/** Review only: never issues an authorization accepted by runtime/launch checks. */\nexport function validateProcessGroupPolicyCandidate(context: ProcessGroupAuthorizationContext, bytes: Buffer): void {\n verifyRuntimePolicy(context, bytes);\n}\nexport function processGroupAuthorizationFile(context: ProcessGroupAuthorizationContext): string {\n const root = context.stateRoot ?? process.env[\"UNS_PROCESS_GROUP_STATE_ROOT\"];\n if (!root) throw Error(\"Missing process-group state root\");\n return selectedFile(context.packageRoot, context.rawConfiguration, root, context.file);\n}\nexport const authorizeHvRuntime = authorizeProcessGroupRuntime;\nexport function authorizeConfiguredProcessGroupRuntime(\n pkg: string,\n dir: string,\n raw: Record<string, unknown>,\n controllerName: string,\n initialize = false,\n) {\n return authorizeProcessGroupRuntime({\n packageRoot: pkg,\n instanceDirectory: dir,\n rawConfiguration: raw,\n channels: resolvedProcessGroupChannels(raw),\n controllerName,\n initialize,\n });\n}\nexport function assertProcessGroupJournalAuthorization(\n value: ProcessGroupAuthorization | undefined,\n directory: string,\n journalId: string | undefined,\n): void {\n if (value && issued.has(value)) {\n if (value.directory !== directory || value.journalId !== (journalId ?? null) || sha(read(value.file, true)) !== value.sha256)\n throw Error(\"Exact reviewed process-group authorization required\");\n return;\n }\n legacy.assertHvJournalAuthorization(value as legacy.HvAuthorization | undefined, directory, journalId);\n}\nexport const assertHvJournalAuthorization = assertProcessGroupJournalAuthorization;\nexport function assertProcessGroupStateMount(value: ProcessGroupAuthorization, root: string): void {\n if (!issued.has(value)) {\n legacy.assertHvStateMount(value as legacy.HvAuthorization, root);\n return;\n }\n assertProcessGroupJournalAuthorization(value, value.directory, value.journalId ?? undefined);\n if (process.platform !== \"linux\" || !(\"namespace\" in value) || value.directory !== path.join(root, value.namespace, \"admission\", value.generationId ?? value.groupId))\n throw Error(\"Process group requires its reviewed Linux state mount\");\n const mount = fs\n .readFileSync(\"/proc/self/mountinfo\", \"utf8\")\n .split(\"\\n\")\n .map((l) => l.split(\" \"))\n .filter((f) => f[4] === root)\n .at(-1);\n if (!mount || !mount[5]?.split(\",\").includes(\"rw\") || ![\"xfs\", \"ext4\", \"btrfs\", \"zfs\"].includes(mount[mount.indexOf(\"-\") + 1] ?? \"\"))\n throw Error(\"Process-group state root must be an explicit writable local Linux filesystem mount\");\n}\nexport const assertHvStateMount = assertProcessGroupStateMount;\nexport function assertProcessGroupTargetLaunch(\n value: ProcessGroupAuthorization,\n dir: string,\n operationId: string | undefined,\n launchId: string | undefined,\n): void {\n if (!issued.has(value)) {\n legacy.assertHvTargetLaunch(value as legacy.HvAuthorization, dir, operationId, launchId);\n return;\n }\n if (value.role !== \"target\") return;\n try {\n assertProcessGroupJournalAuthorization(value, value.directory, value.journalId ?? undefined);\n const r = JSON.parse(read(path.join(dir, \"process-group-reservation.json\"), true).toString());\n if (\n !z.string().uuid().safeParse(operationId).success ||\n !z.string().uuid().safeParse(launchId).success ||\n r.operationId !== operationId ||\n r.role !== \"target\" ||\n r.lastLaunch?.launchId !== launchId ||\n !z.string().uuid().safeParse(r.lastLaunch?.requestId).success ||\n !digest.safeParse(r.configurationChecksum).success\n )\n throw Error();\n if (\"configurationGroupSha256\" in value && value.configurationGroupSha256 !== undefined &&\n (r.configurationGroupSha256 !== value.configurationGroupSha256 || r.generationId !== value.generationId)) throw Error();\n } catch {\n throw Error(\"Target requires its exact reviewed group reservation and launch identity\");\n }\n}\nexport const assertHvTargetLaunch = assertProcessGroupTargetLaunch;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** SDK-owned fixed resource budget; hosts never accept it from an operation request. */
|
|
3
|
+
export declare const processGroupBackupLimits: Readonly<{
|
|
4
|
+
schemaVersion: 1;
|
|
5
|
+
maximumJournals: number;
|
|
6
|
+
maximumManifestBytes: 262144;
|
|
7
|
+
maximumSnapshotBytes: 536870912;
|
|
8
|
+
maximumCapsuleBytes: 1073741824;
|
|
9
|
+
}>;
|
|
10
|
+
/** Public coverage only; identities, checkpoints and payloads remain encrypted. */
|
|
11
|
+
export declare const processGroupStateBackupSchema: z.ZodObject<{
|
|
12
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
13
|
+
state: z.ZodEnum<{
|
|
14
|
+
included: "included";
|
|
15
|
+
empty: "empty";
|
|
16
|
+
}>;
|
|
17
|
+
rootSha256: z.ZodString;
|
|
18
|
+
journals: z.ZodNumber;
|
|
19
|
+
bytes: z.ZodNumber;
|
|
20
|
+
sha256: z.ZodString;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
//# sourceMappingURL=process-group-backup-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-group-backup-contract.d.ts","sourceRoot":"","sources":["../../src/runtime/process-group-backup-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wFAAwF;AACxF,eAAO,MAAM,wBAAwB;;;;;;EAMlB,CAAC;AAEpB,mFAAmF;AACnF,eAAO,MAAM,6BAA6B;;;;;;;;;;kBAOgC,CAAC"}
|