fix(security): harden auth and outbound fetches

This commit is contained in:
SnapOtter
2026-06-29 17:54:12 +08:00
parent 6f85b3d12a
commit c6319cf8a9
34 changed files with 799 additions and 173 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ export {
type PdfCompressionPreset,
} from "./ghostscript.js";
export { type ConvertOptions, convertDocument, parseConvertTarget } from "./libreoffice.js";
export { type PandocOptions, pandocAvailable, runPandoc } from "./pandoc.js";
export { buildPandocArgs, type PandocOptions, pandocAvailable, runPandoc } from "./pandoc.js";
export {
assertValidRange,
qpdfDecrypt,
+16 -7
View File
@@ -45,6 +45,21 @@ export interface PandocOptions {
extraArgs?: string[];
}
export function buildPandocArgs(
inPath: string,
outPath: string,
opts: PandocOptions = {},
): string[] {
const args = ["--sandbox", inPath, "-o", outPath];
if (opts.selfContained) {
args.push(...selfContainedArgs());
}
if (opts.extraArgs) {
args.push(...opts.extraArgs);
}
return args;
}
/** Runs pandoc in -> out; rejects with the stderr tail on failure. */
export function runPandoc(
inPath: string,
@@ -52,13 +67,7 @@ export function runPandoc(
opts: PandocOptions = {},
): Promise<void> {
const timeoutMs = opts.timeoutMs ?? 120_000;
const args = [inPath, "-o", outPath];
if (opts.selfContained) {
args.push(...selfContainedArgs());
}
if (opts.extraArgs) {
args.push(...opts.extraArgs);
}
const args = buildPandocArgs(inPath, outPath, opts);
return new Promise<void>((resolvePromise, reject) => {
const child = spawn(pandocBin(), args, { stdio: ["ignore", "pipe", "pipe"] });
let err = "";