fix(automation,vault): drain direct rsync stdout, guard ssh2 ed25519 keygen, and match succeeded badge
This commit is contained in:
parent
41e79c3df3
commit
3791f83bf6
4 changed files with 48 additions and 20 deletions
|
|
@ -371,9 +371,9 @@ export async function renderDashboardView(
|
|||
const wf = entry.workflow;
|
||||
const runStatus = entry.latestRun?.status ?? 'idle';
|
||||
const badgeClass =
|
||||
runStatus === 'success'
|
||||
runStatus === 'succeeded'
|
||||
? 'badge badge-ok'
|
||||
: runStatus === 'failed' || runStatus === 'timed-out'
|
||||
: runStatus === 'failed' || runStatus === 'cancelled'
|
||||
? 'badge badge-err'
|
||||
: runStatus === 'running' || runStatus === 'queued'
|
||||
? 'badge badge-warn'
|
||||
|
|
|
|||
|
|
@ -577,17 +577,20 @@ export async function renderSystemsView(
|
|||
wf.trigger.type === 'cron'
|
||||
? `cron: ${wf.trigger.expression ?? ''}${entry.nextRunAt ? ` (next ${new Date(entry.nextRunAt).toISOString().slice(0, 19).replace('T', ' ')})` : ''}`
|
||||
: wf.trigger.type;
|
||||
const runStatus = entry.latestRun?.status ?? 'idle';
|
||||
const statusBadge = el(
|
||||
'span',
|
||||
{
|
||||
class:
|
||||
entry.latestRun?.status === 'success'
|
||||
runStatus === 'succeeded'
|
||||
? 'badge badge-ok'
|
||||
: entry.latestRun?.status === 'failed'
|
||||
: runStatus === 'failed' || runStatus === 'cancelled'
|
||||
? 'badge badge-err'
|
||||
: runStatus === 'running' || runStatus === 'queued'
|
||||
? 'badge badge-warn'
|
||||
: 'badge',
|
||||
},
|
||||
entry.latestRun?.status ?? 'idle',
|
||||
runStatus,
|
||||
);
|
||||
const runTaskBtn = el('button', { type: 'button', class: 'btn btn-sm btn-primary' }, 'Run Task');
|
||||
runTaskBtn.addEventListener('click', async () => {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ export class TransferEngine {
|
|||
|
||||
const errBuf: Buffer[] = [];
|
||||
let errLen = 0;
|
||||
handle.channel.on('data', (chunk: Buffer) => {
|
||||
opts.onProgress?.(chunk.toString('utf8'));
|
||||
});
|
||||
handle.channel.stderr?.on('data', (chunk: Buffer) => {
|
||||
if (errLen < 16_384) {
|
||||
errBuf.push(chunk);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,37 @@ export function computeOpenSshFingerprint(publicKeyLine: string): string {
|
|||
return `SHA256:${hash}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an OpenSSH Ed25519 keypair, retrying around ssh2's BitString
|
||||
* leading-zero stripping bug when a generated public key starts with 0x00.
|
||||
*/
|
||||
export function generateValidEd25519KeyPair(opts: {
|
||||
comment: string;
|
||||
passphrase?: string;
|
||||
}): { privateKey: string; publicKey: string; fingerprint: string } {
|
||||
let lastErr: unknown;
|
||||
for (let attempt = 0; attempt < 16; attempt++) {
|
||||
const kp = opts.passphrase
|
||||
? ssh2.utils.generateKeyPairSync('ed25519', {
|
||||
comment: opts.comment,
|
||||
passphrase: opts.passphrase,
|
||||
cipher: 'aes256-ctr',
|
||||
rounds: 16,
|
||||
})
|
||||
: ssh2.utils.generateKeyPairSync('ed25519', {
|
||||
comment: opts.comment,
|
||||
});
|
||||
const publicKey = kp.public.trim();
|
||||
try {
|
||||
const fingerprint = computeOpenSshFingerprint(publicKey);
|
||||
return { privateKey: kp.private, publicKey, fingerprint };
|
||||
} catch (err) {
|
||||
lastErr = err;
|
||||
}
|
||||
}
|
||||
throw lastErr instanceof Error ? lastErr : new Error('Failed to generate valid Ed25519 keypair');
|
||||
}
|
||||
|
||||
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
||||
|
||||
export type VaultCredentialInput = DistributiveOmit<
|
||||
|
|
@ -483,25 +514,16 @@ export class VaultService {
|
|||
this.assertWriteUnlocked();
|
||||
this.autoInitializedEmpty = false;
|
||||
|
||||
const keyPair = options.passphrase
|
||||
? ssh2.utils.generateKeyPairSync('ed25519', {
|
||||
const { privateKey, publicKey, fingerprint } = generateValidEd25519KeyPair({
|
||||
comment: options.comment ?? options.id,
|
||||
passphrase: options.passphrase,
|
||||
cipher: 'aes256-ctr',
|
||||
rounds: 16,
|
||||
})
|
||||
: ssh2.utils.generateKeyPairSync('ed25519', {
|
||||
comment: options.comment ?? options.id,
|
||||
});
|
||||
|
||||
const publicKey = keyPair.public.trim();
|
||||
const fingerprint = computeOpenSshFingerprint(publicKey);
|
||||
|
||||
return this.upsertCredential({
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
type: 'ssh-key',
|
||||
privateKey: keyPair.private,
|
||||
privateKey,
|
||||
publicKey,
|
||||
passphrase: options.passphrase || undefined,
|
||||
fingerprint,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue