Merge pull request #599 from matthiasfehr/binary-secret-files
Some checks failed
publish / publish (push) Has been cancelled

Fix: Remove UTF-8 encoding to prevent mangling of binary secrets
This commit is contained in:
CrazyMax
2025-02-19 14:58:38 +01:00
committed by GitHub

View File

@@ -139,16 +139,16 @@ export class Build {
} }
public static resolveSecret(kvp: string, file: boolean): [string, string] { public static resolveSecret(kvp: string, file: boolean): [string, string] {
const [key, _value] = Build.parseSecretKvp(kvp); const [key, value] = Build.parseSecretKvp(kvp);
let value = _value; const secretFile = Context.tmpName({tmpdir: Context.tmpDir()});
if (file) { if (file) {
if (!fs.existsSync(value)) { if (!fs.existsSync(value)) {
throw new Error(`secret file ${value} not found`); throw new Error(`secret file ${value} not found`);
} }
value = fs.readFileSync(value, {encoding: 'utf-8'}); fs.copyFileSync(value, secretFile);
} else {
fs.writeFileSync(secretFile, value);
} }
const secretFile = Context.tmpName({tmpdir: Context.tmpDir()});
fs.writeFileSync(secretFile, value);
return [key, secretFile]; return [key, secretFile];
} }