Skip to content

Commit

Permalink
fix(egf): update GPG invocation to avoid arb code exec
Browse files Browse the repository at this point in the history
- use `execFileSync()` to avoid shell and pass encrypted body
  • Loading branch information
postspectacular committed Mar 26, 2021
1 parent 3376b45 commit 3e14765
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/egf/src/tags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IObjectOf } from "@thi.ng/api";
import { maybeParseFloat, maybeParseInt, unescape } from "@thi.ng/strings";
import { base64Decode } from "@thi.ng/transducers-binary";
import { execSync } from "child_process";
import { execFileSync } from "child_process";
import { readFileSync } from "fs";
import { resolve as resolvePath } from "path";
import { IS_NODE, NODE_ONLY, TagParser } from "./api";
Expand All @@ -24,7 +24,9 @@ export const BUILTINS: IObjectOf<TagParser> = {
gpg: IS_NODE
? (_, body, ctx) =>
(ctx.opts.decrypt
? execSync(`echo "${body}" | gpg --decrypt`).toString()
? execFileSync("gpg", ["--decrypt"], {
input: body,
}).toString()
: body
).trim()
: NODE_ONLY,
Expand Down

0 comments on commit 3e14765

Please sign in to comment.