Verify script revision binding and recovery after interrupted submission

This commit is contained in:
2026-11-17 22:43:46 +01:00
parent 439c729160
commit a3b7a237be
5 changed files with 1336 additions and 278 deletions
+23 -9
View File
@@ -14,22 +14,36 @@ export interface Revision extends Script {
script_sha256: string;
}
export const interpreterNames: Record<Interpreter, string> = {
posix_sh: 'Linux · Shell', bash: 'Linux · Bash', powershell: 'Windows · PowerShell'
posix_sh: 'Linux · Shell',
bash: 'Linux · Bash',
powershell: 'Windows · PowerShell'
};
export const identityNames: Record<Identity, string> = {
agent_service: 'Agent-Dienstkonto', root: 'root', system: 'SYSTEM'
agent_service: 'Agent-Dienstkonto',
root: 'root',
system: 'SYSTEM'
};
export function parseRevision(value: unknown): Revision {
const row = record(value);
if ((row.interpreter !== 'posix_sh' && row.interpreter !== 'bash' && row.interpreter !== 'powershell') ||
(row.execution_identity !== 'agent_service' && row.execution_identity !== 'root' && row.execution_identity !== 'system') ||
typeof row.version !== 'number' || !Number.isSafeInteger(row.version) || row.version < 1) {
if (
(row.interpreter !== 'posix_sh' && row.interpreter !== 'bash' && row.interpreter !== 'powershell') ||
(row.execution_identity !== 'agent_service' &&
row.execution_identity !== 'root' &&
row.execution_identity !== 'system') ||
typeof row.version !== 'number' ||
!Number.isSafeInteger(row.version) ||
row.version < 1
) {
throw Error('Der Server meldet eine ungültige Skriptversion.');
}
return {
revision_id: objectId(row, 'revision'), name: text(row.name, 'Skriptname'), version: row.version,
interpreter: row.interpreter, execution_identity: row.execution_identity,
script_utf8: text(row.script_utf8, 'Skriptinhalt'), script_sha256: text(row.script_sha256, 'Prüfsumme')
revision_id: objectId(row, 'revision'),
name: text(row.name, 'Skriptname'),
version: row.version,
interpreter: row.interpreter,
execution_identity: row.execution_identity,
script_utf8: text(row.script_utf8, 'Skriptinhalt'),
script_sha256: text(row.script_sha256, 'Prüfsumme')
};
}
export async function loadRevisions(tenantId: string, signal: AbortSignal): Promise<Revision[]> {
@@ -37,7 +51,7 @@ export async function loadRevisions(tenantId: string, signal: AbortSignal): Prom
const cursors = new Set<string>();
let cursor: string | null = null;
do {
const params = new URLSearchParams({limit: '100'});
const params = new URLSearchParams({ limit: '100' });
if (cursor) params.set('cursor', cursor);
const batch = page(await request(tenantPath(tenantId, '/script-revisions?' + params), { signal }));
revisions.push(...batch.items.map(parseRevision));