/** * @example * shellQuote("/path/to/file with spaces") // → "'/path/to/file with spaces'" * shellQuote("it's here") // → "'it'\\''s here'" * shellQuote("") // → "''" */ export declare function shellQuote(value: string | null | undefined): string; /** * @example * neutralizeCommandSubstitution("-DFOO=$(whoami)") // → "-DFOO=\\$\\(whoami\\)" * neutralizeCommandSubstitution("-DFOO=`id`") // → "-DFOO=\\`id\\`" * neutralizeCommandSubstitution("-DPATH=$HOME/bin") // → "-DPATH=$HOME/bin" (preserved) * neutralizeCommandSubstitution("-DPATH=${HOME}/bin") // → "-DPATH=${HOME}/bin" (preserved) * neutralizeCommandSubstitution("test;whoami") // → "test\\;whoami" * neutralizeCommandSubstitution("test|curl evil.com") // → "test\\|curl evil.com" * neutralizeCommandSubstitution("'; whoami; echo '") // → "\\'\\;\\ whoami\\;\\ echo\\ \\'" * * NOTE: This function deliberately preserves shell variable expansion ($VAR and * ${VAR}) and therefore does NOT neutralize brace expansion ({a,b} / {1..5}), * pathname globbing (* ? [ ]) or tilde expansion (~). For example bash expands * an unquoted multi-key JSON value '{"a":"b","c":"d"}' via brace expansion into * two words, corrupting the value. When the argument is fully untrusted and no * variable expansion is required (e.g. an Ansible --extra-vars JSON blob), wrap * each token with shellQuote() instead — single quoting keeps the value intact * and inert against every form of shell interpretation. */ export declare function neutralizeCommandSubstitution(value: string | null | undefined): string | null | undefined; /** * @example * shellSplit('-DFOO=bar -DBAZ="hello world"') * // → ['-DFOO=bar', '-DBAZ=hello world'] * * shellSplit("-DPATH='/usr/local/my app' -DVER=1.0") * // → ['-DPATH=/usr/local/my app', '-DVER=1.0'] * * shellSplit(`--extra-vars '{"a":"b"}'`) * // → ['--extra-vars', '{"a":"b"}'] (nested double quotes preserved) * * // Safe workflow for fully-untrusted, multi-param inputs — re-quote every token * // so the shell treats each one as a single, literal argument: * shellSplit(args).map(shellQuote).join(' ') * * // Use .map(neutralizeCommandSubstitution) instead only when shell variable * // expansion ($VAR/${VAR}) must be preserved AND the input cannot contain * // brace/glob/tilde metacharacters (see neutralizeCommandSubstitution notes). */ export declare function shellSplit(value: string | null | undefined): string[];