fffleet 2.5.1 → 2.6.0
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/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/contract.js +6 -0
- package/src/executor.js +10 -1
- package/src/types.js +1 -0
package/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export interface JobSpecInput {
|
|
|
47
47
|
stdin?: boolean;
|
|
48
48
|
/** Stream jobs only: ffmpeg's `pipe:1` is readable through `job.stdout()`. No `-progress` is reported. */
|
|
49
49
|
stdout?: boolean;
|
|
50
|
+
/** Secret values replaced by *** in stderr tails and job events (4-512 characters, at most 10). The spec itself keeps them. */
|
|
51
|
+
redact?: string[];
|
|
50
52
|
inputs?: Endpoint[];
|
|
51
53
|
outputs?: Endpoint[];
|
|
52
54
|
ffmpeg?: { args: string[]; durationMs?: number | null };
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -92,6 +92,11 @@ export function validateSpec(input) {
|
|
|
92
92
|
if (typeof stdout !== 'boolean') err('stdout', 'must be a boolean');
|
|
93
93
|
else if (stdout && s.kind !== 'stream') err('stdout', 'is only allowed for stream jobs');
|
|
94
94
|
|
|
95
|
+
const redact = s.redact ?? [];
|
|
96
|
+
if (!Array.isArray(redact) || redact.length > 10 || redact.some(r => typeof r !== 'string' || r.length < 4 || r.length > 512)) {
|
|
97
|
+
err('redact', 'must be an array of at most 10 strings of 4-512 characters');
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
const requires = s.requires ?? [];
|
|
96
101
|
if (!Array.isArray(requires) || requires.some(r => typeof r !== 'string' || !r)) err('requires', 'must be an array of capability strings');
|
|
97
102
|
|
|
@@ -136,6 +141,7 @@ export function validateSpec(input) {
|
|
|
136
141
|
inputs,
|
|
137
142
|
outputs,
|
|
138
143
|
};
|
|
144
|
+
if (redact.length) spec.redact = [...new Set(redact)];
|
|
139
145
|
if (ffmpeg) spec.ffmpeg = ffmpeg;
|
|
140
146
|
else if (s[type] !== undefined) spec[type] = s[type];
|
|
141
147
|
return { ok: true, spec };
|
package/src/executor.js
CHANGED
|
@@ -245,9 +245,11 @@ function runProcess(cmd, args, spec, rt) {
|
|
|
245
245
|
child.stdout.setEncoding('utf8');
|
|
246
246
|
child.stdout.on('data', parse);
|
|
247
247
|
}
|
|
248
|
+
const secrets = spec.redact ?? [];
|
|
248
249
|
child.stderr.setEncoding('utf8');
|
|
249
250
|
child.stderr.on('data', d => {
|
|
250
|
-
|
|
251
|
+
// Redact the whole buffer before trimming, so a secret split across two chunks is still caught.
|
|
252
|
+
tail = redactSecrets(tail + d, secrets).slice(-STDERR_TAIL_BYTES);
|
|
251
253
|
rt.stderr?.(tail.trim());
|
|
252
254
|
});
|
|
253
255
|
if (child.stdin) {
|
|
@@ -289,6 +291,13 @@ function runProcess(cmd, args, spec, rt) {
|
|
|
289
291
|
});
|
|
290
292
|
}
|
|
291
293
|
|
|
294
|
+
/** Replaces every occurrence of a caller-supplied secret with "***" (spec.redact). */
|
|
295
|
+
export function redactSecrets(text, secrets) {
|
|
296
|
+
let out = text;
|
|
297
|
+
for (const secret of secrets) out = out.split(secret).join('***');
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
|
|
292
301
|
/** Windows: ends a process and everything it started. Falls back to killing just the child. */
|
|
293
302
|
function killTree(child) {
|
|
294
303
|
try {
|
package/src/types.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* @property {number | null} timeoutMs
|
|
23
23
|
* @property {boolean} stdin Keep ffmpeg's stdin open for POST /v1/jobs/:id/stdin.
|
|
24
24
|
* @property {boolean} stdout Hand ffmpeg's stdout (`pipe:1`) to GET /v1/jobs/:id/stdout. Stream jobs only; no `-progress` is reported then.
|
|
25
|
+
* @property {string[]} [redact] Secret values (4-512 characters, at most 10) replaced by *** in stderr tails and job events.
|
|
25
26
|
* @property {Endpoint[]} inputs
|
|
26
27
|
* @property {Endpoint[]} outputs
|
|
27
28
|
* @property {{ args: string[], durationMs: number | null }} [ffmpeg]
|