Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

652 B
Raw Blame
/** Quote a literal argument for the user's shell (PowerShell on Windows). */
export function quoteCliPath(value: string): string {
  if (/^[A-Za-z0-9_./:-]+$/u.test(value)) return value;
  if (process.platform === "win32" && /^[A-Za-z0-9_./:\\-]+$/u.test(value))
    return value;
  const escaped =
    process.platform === "win32"
      ? value.replace(/['\u2018\u2019\u201a\u201b]/gu, (quote) => quote + quote)
      : value.replaceAll("'", `'"'"'`);
  return `'${escaped}'`;
}

export function cliShellLabel(quotedArgument: string): string {
  return process.platform === "win32" && quotedArgument.startsWith("'")
    ? " (PowerShell)"
    : "";
}