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 wf = entry.workflow;
|
||||||
const runStatus = entry.latestRun?.status ?? 'idle';
|
const runStatus = entry.latestRun?.status ?? 'idle';
|
||||||
const badgeClass =
|
const badgeClass =
|
||||||
runStatus === 'success'
|
runStatus === 'succeeded'
|
||||||
? 'badge badge-ok'
|
? 'badge badge-ok'
|
||||||
: runStatus === 'failed' || runStatus === 'timed-out'
|
: runStatus === 'failed' || runStatus === 'cancelled'
|
||||||
? 'badge badge-err'
|
? 'badge badge-err'
|
||||||
: runStatus === 'running' || runStatus === 'queued'
|
: runStatus === 'running' || runStatus === 'queued'
|
||||||
? 'badge badge-warn'
|
? 'badge badge-warn'
|
||||||
|
|
|
||||||
|
|
@ -577,17 +577,20 @@ export async function renderSystemsView(
|
||||||
wf.trigger.type === 'cron'
|
wf.trigger.type === 'cron'
|
||||||
? `cron: ${wf.trigger.expression ?? ''}${entry.nextRunAt ? ` (next ${new Date(entry.nextRunAt).toISOString().slice(0, 19).replace('T', ' ')})` : ''}`
|
? `cron: ${wf.trigger.expression ?? ''}${entry.nextRunAt ? ` (next ${new Date(entry.nextRunAt).toISOString().slice(0, 19).replace('T', ' ')})` : ''}`
|
||||||
: wf.trigger.type;
|
: wf.trigger.type;
|
||||||
|
const runStatus = entry.latestRun?.status ?? 'idle';
|
||||||
const statusBadge = el(
|
const statusBadge = el(
|
||||||
'span',
|
'span',
|
||||||
{
|
{
|
||||||
class:
|
class:
|
||||||
entry.latestRun?.status === 'success'
|
runStatus === 'succeeded'
|
||||||
? 'badge badge-ok'
|
? 'badge badge-ok'
|
||||||
: entry.latestRun?.status === 'failed'
|
: runStatus === 'failed' || runStatus === 'cancelled'
|
||||||
? 'badge badge-err'
|
? 'badge badge-err'
|
||||||
|
: runStatus === 'running' || runStatus === 'queued'
|
||||||
|
? 'badge badge-warn'
|
||||||
: 'badge',
|
: 'badge',
|
||||||
},
|
},
|
||||||
entry.latestRun?.status ?? 'idle',
|
runStatus,
|
||||||
);
|
);
|
||||||
const runTaskBtn = el('button', { type: 'button', class: 'btn btn-sm btn-primary' }, 'Run Task');
|
const runTaskBtn = el('button', { type: 'button', class: 'btn btn-sm btn-primary' }, 'Run Task');
|
||||||
runTaskBtn.addEventListener('click', async () => {
|
runTaskBtn.addEventListener('click', async () => {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@ export class TransferEngine {
|
||||||
|
|
||||||
const errBuf: Buffer[] = [];
|
const errBuf: Buffer[] = [];
|
||||||
let errLen = 0;
|
let errLen = 0;
|
||||||
|
handle.channel.on('data', (chunk: Buffer) => {
|
||||||
|
opts.onProgress?.(chunk.toString('utf8'));
|
||||||
|
});
|
||||||
handle.channel.stderr?.on('data', (chunk: Buffer) => {
|
handle.channel.stderr?.on('data', (chunk: Buffer) => {
|
||||||
if (errLen < 16_384) {
|
if (errLen < 16_384) {
|
||||||
errBuf.push(chunk);
|
errBuf.push(chunk);
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,37 @@ export function computeOpenSshFingerprint(publicKeyLine: string): string {
|
||||||
return `SHA256:${hash}`;
|
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;
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
||||||
|
|
||||||
export type VaultCredentialInput = DistributiveOmit<
|
export type VaultCredentialInput = DistributiveOmit<
|
||||||
|
|
@ -483,25 +514,16 @@ export class VaultService {
|
||||||
this.assertWriteUnlocked();
|
this.assertWriteUnlocked();
|
||||||
this.autoInitializedEmpty = false;
|
this.autoInitializedEmpty = false;
|
||||||
|
|
||||||
const keyPair = options.passphrase
|
const { privateKey, publicKey, fingerprint } = generateValidEd25519KeyPair({
|
||||||
? ssh2.utils.generateKeyPairSync('ed25519', {
|
|
||||||
comment: options.comment ?? options.id,
|
comment: options.comment ?? options.id,
|
||||||
passphrase: options.passphrase,
|
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({
|
return this.upsertCredential({
|
||||||
id: options.id,
|
id: options.id,
|
||||||
name: options.name,
|
name: options.name,
|
||||||
type: 'ssh-key',
|
type: 'ssh-key',
|
||||||
privateKey: keyPair.private,
|
privateKey,
|
||||||
publicKey,
|
publicKey,
|
||||||
passphrase: options.passphrase || undefined,
|
passphrase: options.passphrase || undefined,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue