Verify script revision binding and recovery after interrupted submission
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user