@openai/codex-security 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +20 -3
  2. package/_bundled_plugin/.mcp.json +16 -0
  3. package/_bundled_plugin/mcp/server.mjs +1 -1
  4. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/preflight/capability-profiles.toml +2 -2
  7. package/_bundled_plugin/references/config-preflight.md +6 -6
  8. package/_bundled_plugin/references/desktop-config-preflight.md +11 -0
  9. package/_bundled_plugin/references/final-report.md +10 -14
  10. package/_bundled_plugin/references/scan-artifacts.md +17 -17
  11. package/_bundled_plugin/references/shared-hard-rules.md +2 -2
  12. package/_bundled_plugin/scripts/deep_scan_workbench.py +422 -48
  13. package/_bundled_plugin/scripts/generate_rank_input.py +91 -0
  14. package/_bundled_plugin/scripts/workbench_cli.py +1 -50
  15. package/_bundled_plugin/scripts/workbench_constants.py +0 -2
  16. package/_bundled_plugin/scripts/workbench_db.py +7 -289
  17. package/_bundled_plugin/scripts/workbench_progress.py +11 -0
  18. package/_bundled_plugin/scripts/workbench_scan_history.py +0 -54
  19. package/_bundled_plugin/scripts/workbench_target.py +2 -6
  20. package/_bundled_plugin/scripts/workbench_validation.py +0 -211
  21. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +10 -10
  22. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +25 -43
  23. package/_bundled_plugin/skills/finding-discovery/SKILL.md +2 -4
  24. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +11 -23
  25. package/_bundled_plugin/skills/security-scan/SKILL.md +89 -26
  26. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +25 -0
  27. package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +11 -38
  28. package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +5 -6
  29. package/_bundled_plugin/skills/triage-finding/SKILL.md +6 -14
  30. package/_bundled_plugin/skills/validation/SKILL.md +9 -9
  31. package/dist/api.d.ts +6 -0
  32. package/dist/api.d.ts.map +1 -1
  33. package/dist/api.js +111 -31
  34. package/dist/api.js.map +1 -1
  35. package/dist/cli.d.ts +1 -1
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +77 -17
  38. package/dist/cli.js.map +1 -1
  39. package/dist/config.d.ts +1 -0
  40. package/dist/config.d.ts.map +1 -1
  41. package/dist/config.js +18 -10
  42. package/dist/config.js.map +1 -1
  43. package/dist/cost.d.ts.map +1 -1
  44. package/dist/cost.js +4 -1
  45. package/dist/cost.js.map +1 -1
  46. package/dist/multiscan.d.ts +5 -1
  47. package/dist/multiscan.d.ts.map +1 -1
  48. package/dist/multiscan.js +206 -26
  49. package/dist/multiscan.js.map +1 -1
  50. package/dist/runtime.d.ts +13 -1
  51. package/dist/runtime.d.ts.map +1 -1
  52. package/dist/runtime.js +122 -92
  53. package/dist/runtime.js.map +1 -1
  54. package/package.json +2 -2
  55. package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
package/dist/cli.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare function readSkillCommandOutput(stream: AsyncIterable<Buffer | st
59
59
  malformed: boolean;
60
60
  }>;
61
61
  export declare function skillCommandFailure(command: "validate" | "patch", status: number, detail: string): string;
62
- export declare function parseCodexOverrides(values: readonly string[], model?: string, effort?: ModelReasoningEffort, provider?: "openai" | ExternalModelProvider): JsonObject;
62
+ export declare function parseCodexOverrides(values: readonly string[], model?: string, effort?: ModelReasoningEffort, provider?: "openai" | "amazon-bedrock" | ExternalModelProvider): JsonObject;
63
63
  export declare class Progress {
64
64
  #private;
65
65
  constructor(stream?: Writable, dependencies?: Pick<CliDependencies, "now" | "setInterval" | "clearInterval">, interactive?: boolean);
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","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B,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAkHnE;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,GAAG,OAAO,EAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAyBR;AAuhCD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,oBAAoB,EAC7B,QAAQ,CAAC,EAAE,QAAQ,GAAG,gBAAgB,GAAG,qBAAqB,GAC7D,UAAU,CAwFZ;AAwBD,qBAAa,QAAQ;;gBAcjB,MAAM,GAAE,QAAyB,EACjC,YAAY,GAAE,IAAI,CAChB,eAAe,EACf,KAAK,GAAG,aAAa,GAAG,eAAe,CACjB,EACxB,WAAW,UAAO;IAQpB,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,cAAc,IAAI,MAAM,CAKlC;IAEM,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAejC,SAAS,IAAI,IAAI;IAgBjB,eAAe,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI;CA2BhD"}
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import { parse as parseToml } from "smol-toml";
12
12
  import { classifyConnectionFailure, CodexSecurity, scanAuthentication, } from "./api.js";
13
13
  import { accountStatus } from "./auth.js";
14
14
  import { createBulkScanDiscoveryDependencies, runBulkScanWizard, } from "./bulk-scan-discovery.js";
15
- import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergedCodexConfig, scanModelConfiguration, } from "./config.js";
15
+ import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergedCodexConfig, scanModelConfiguration, scanModelProvider, } from "./config.js";
16
16
  import { formatUsd } from "./cost.js";
17
17
  import { CodexSecurityError, ConfigurationError, InvalidTargetError, OutputDirectoryError, OutputInsideProtectedRootError, PluginPythonUnavailableError, redactedErrorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
18
18
  import { runMultiscan } from "./multiscan.js";
@@ -67,6 +67,8 @@ const VALUE_OPTIONS = new Set([
67
67
  "--auth",
68
68
  "--path",
69
69
  "--knowledge-base",
70
+ "--scan-prompt-file",
71
+ "--post-scan-prompt-file",
70
72
  "--diff",
71
73
  "--head",
72
74
  "--base",
@@ -96,7 +98,7 @@ const VALUE_OPTIONS = new Set([
96
98
  "--reason",
97
99
  ]);
98
100
  const PROVIDER_OPTION = z
99
- .enum(["openai", "openrouter", "fireworks"])
101
+ .enum(["openai", "openrouter", "fireworks", "amazon-bedrock"])
100
102
  .default("openai")
101
103
  .describe("Inference provider for scans.");
102
104
  function optionValue(flag) {
@@ -136,6 +138,20 @@ const DEEP_SCAN_OPTION_SCHEMAS = {
136
138
  .optional()
137
139
  .describe("Maximum deep-scan discovery runs."),
138
140
  };
141
+ async function readPromptFiles(directory, scanPromptFile, postScanPromptFile) {
142
+ const [scanPrompt, postScanPrompt] = await Promise.all([
143
+ scanPromptFile === undefined
144
+ ? undefined
145
+ : readFile(resolve(directory, scanPromptFile), "utf8"),
146
+ postScanPromptFile === undefined
147
+ ? undefined
148
+ : readFile(resolve(directory, postScanPromptFile), "utf8"),
149
+ ]);
150
+ return {
151
+ ...(scanPrompt?.trim() ? { scanPrompt } : {}),
152
+ ...(postScanPrompt?.trim() ? { postScanPrompt } : {}),
153
+ };
154
+ }
139
155
  const DEFAULT_DEPENDENCIES = {
140
156
  createSecurity: (config) => new CodexSecurity(config),
141
157
  environment: process.env,
@@ -727,6 +743,12 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
727
743
  .array(optionValue("--knowledge-base"))
728
744
  .default([])
729
745
  .describe("Add security-context files or directories; repeat for multiple paths."),
746
+ scanPromptFile: optionValue("--scan-prompt-file")
747
+ .optional()
748
+ .describe("Append scan instructions from FILE."),
749
+ postScanPromptFile: optionValue("--post-scan-prompt-file")
750
+ .optional()
751
+ .describe("Run instructions from FILE after a validated scan."),
730
752
  diff: optionValue("--diff")
731
753
  .optional()
732
754
  .describe("Scan committed Git changes from BASE to --head."),
@@ -832,6 +854,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
832
854
  repository: args.repository,
833
855
  paths: options.path,
834
856
  knowledgeBasePaths: options.knowledgeBase,
857
+ scanPromptFile: options.scanPromptFile,
858
+ postScanPromptFile: options.postScanPromptFile,
835
859
  diff: options.diff,
836
860
  workingTree: options.workingTree,
837
861
  head: options.head,
@@ -968,6 +992,12 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
968
992
  .enum(["standard", "deep"])
969
993
  .default("standard")
970
994
  .describe("Default scan mode for repositories without a CSV mode."),
995
+ scanPromptFile: optionValue("--scan-prompt-file")
996
+ .optional()
997
+ .describe("Append instructions from FILE to every scan."),
998
+ postScanPromptFile: optionValue("--post-scan-prompt-file")
999
+ .optional()
1000
+ .describe("Run FILE after each completed, validated scan."),
971
1001
  model: optionValue("--model")
972
1002
  .optional()
973
1003
  .describe(`OpenAI model for each repository (default: ${DEFAULT_SCAN_MODEL_CONFIGURATION.model}).`),
@@ -1014,6 +1044,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1014
1044
  dependencies.addSignalListener("SIGTERM", onTerminate);
1015
1045
  try {
1016
1046
  const currentDirectory = dependencies.currentDirectory();
1047
+ const prompts = await readPromptFiles(currentDirectory, options.scanPromptFile, options.postScanPromptFile);
1017
1048
  let inputPath;
1018
1049
  let outputDir;
1019
1050
  let githubHost;
@@ -1025,14 +1056,18 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1025
1056
  argument === "--effort" ||
1026
1057
  argument === "--provider" ||
1027
1058
  argument === "--codex" ||
1028
- argument === "--knowledge-base") {
1059
+ argument === "--knowledge-base" ||
1060
+ argument === "--scan-prompt-file" ||
1061
+ argument === "--post-scan-prompt-file") {
1029
1062
  optionIndex += 2;
1030
1063
  }
1031
1064
  else if (argument.startsWith("--model=") ||
1032
1065
  argument.startsWith("--effort=") ||
1033
1066
  argument.startsWith("--provider=") ||
1034
1067
  argument.startsWith("--codex=") ||
1035
- argument.startsWith("--knowledge-base=")) {
1068
+ argument.startsWith("--knowledge-base=") ||
1069
+ argument.startsWith("--scan-prompt-file=") ||
1070
+ argument.startsWith("--post-scan-prompt-file=")) {
1036
1071
  optionIndex += 1;
1037
1072
  }
1038
1073
  else {
@@ -1069,6 +1104,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1069
1104
  mode: options.mode,
1070
1105
  maxAttempts: options.maxAttempts,
1071
1106
  knowledgeBasePaths: options.knowledgeBase,
1107
+ ...prompts,
1072
1108
  config: {
1073
1109
  pluginPath: options.pluginPath,
1074
1110
  pythonPath: options.python,
@@ -1076,11 +1112,14 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1076
1112
  },
1077
1113
  createSecurity: dependencies.createSecurity,
1078
1114
  signal: controller.signal,
1079
- onProgress: ({ repository, status, attempt, error }) => {
1080
- errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${error === undefined ? "" : `: ${redactedErrorMessage(error)}`}\n`);
1115
+ onProgress: ({ repository, status, attempt, error, warning }) => {
1116
+ const detail = error ?? warning;
1117
+ errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${redactedErrorMessage(detail)}`}\n`);
1081
1118
  },
1082
1119
  });
1083
- exitCode = interruptedExitCode() ?? (result.failed > 0 ? 2 : 0);
1120
+ exitCode =
1121
+ interruptedExitCode() ??
1122
+ (result.failed > 0 || result.incomplete > 0 ? 2 : 0);
1084
1123
  return { ...result };
1085
1124
  }
1086
1125
  catch (error) {
@@ -2040,6 +2079,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2040
2079
  try {
2041
2080
  const repository = arguments_.repository ?? dependencies.currentDirectory();
2042
2081
  const target = targetFromArguments(arguments_);
2082
+ const prompts = await readPromptFiles(dependencies.currentDirectory(), arguments_.scanPromptFile, arguments_.postScanPromptFile);
2043
2083
  const config = {
2044
2084
  pluginPath: arguments_.pluginPath,
2045
2085
  pythonPath: arguments_.pythonPath,
@@ -2047,13 +2087,14 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2047
2087
  parseCodexOverrides(arguments_.codex, arguments_.model, arguments_.effort, arguments_.provider),
2048
2088
  };
2049
2089
  const selectedProfileName = config.codexOverrides?.["profile"];
2090
+ const effectiveConfiguration = {
2091
+ ...DEFAULT_CODEX_CONFIG,
2092
+ ...config.codexOverrides,
2093
+ };
2050
2094
  ({ model: effectiveModel, reasoningEffort: effectiveReasoningEffort } =
2051
- scanModelConfiguration({
2052
- ...DEFAULT_CODEX_CONFIG,
2053
- ...config.codexOverrides,
2054
- }));
2095
+ scanModelConfiguration(effectiveConfiguration));
2055
2096
  let auth = arguments_.auth;
2056
- const provider = config.codexOverrides?.["model_provider"];
2097
+ const provider = scanModelProvider(effectiveConfiguration);
2057
2098
  selectedAuthentication = scanAuthentication(dependencies.environment, auth, provider);
2058
2099
  if (!isExternalModelProvider(provider) &&
2059
2100
  (auth === undefined || auth === "auto") &&
@@ -2155,6 +2196,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2155
2196
  auth,
2156
2197
  target,
2157
2198
  knowledgeBasePaths: arguments_.knowledgeBasePaths,
2199
+ ...prompts,
2158
2200
  mode: arguments_.mode,
2159
2201
  workers: arguments_.workers,
2160
2202
  subagents: arguments_.subagents,
@@ -2217,7 +2259,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2217
2259
  diagnostic("authentication.selected", {
2218
2260
  requested: auth ?? "auto",
2219
2261
  method: authentication.method,
2220
- source: authentication.method === "api_key"
2262
+ source: authentication.method !== "stored_credentials"
2221
2263
  ? authentication.source
2222
2264
  : undefined,
2223
2265
  verified: authentication.verified,
@@ -2225,7 +2267,9 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2225
2267
  if (dashboard !== null) {
2226
2268
  dashboard.note(authentication.method === "api_key"
2227
2269
  ? `Using API key from ${authentication.source}`
2228
- : "Using stored Codex credentials");
2270
+ : authentication.method === "aws_credentials"
2271
+ ? `Using AWS credentials from ${authentication.source}`
2272
+ : "Using stored Codex credentials");
2229
2273
  return;
2230
2274
  }
2231
2275
  progress?.stopTimer();
@@ -2233,6 +2277,9 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2233
2277
  progress?.stage(`Authentication: API key from ${authentication.source}.`);
2234
2278
  progress?.stage("To use your ChatGPT sign-in, retry with --auth chatgpt.");
2235
2279
  }
2280
+ else if (authentication.method === "aws_credentials") {
2281
+ progress?.stage(`Authentication: AWS credentials from ${authentication.source}.`);
2282
+ }
2236
2283
  else {
2237
2284
  progress?.stage("Authentication: stored Codex credentials.");
2238
2285
  }
@@ -2446,7 +2493,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2446
2493
  model: effectivePreflight.model,
2447
2494
  reasoning_effort: effectivePreflight.reasoningEffort,
2448
2495
  method: effectivePreflight.authentication.method,
2449
- source: effectivePreflight.authentication.method === "api_key"
2496
+ source: effectivePreflight.authentication.method !== "stored_credentials"
2450
2497
  ? effectivePreflight.authentication.source
2451
2498
  : undefined,
2452
2499
  verified: effectivePreflight.authentication.verified,
@@ -2542,6 +2589,10 @@ function scanFailureMessage(error, authentication) {
2542
2589
  return sanitizeDiagnosticValue(error);
2543
2590
  switch (classifyConnectionFailure(error)) {
2544
2591
  case "unauthorized":
2592
+ if (authentication?.method === "aws_credentials") {
2593
+ return (`Authentication failed using AWS credentials from ${authentication.source}. ` +
2594
+ "Check your Amazon Bedrock bearer token or AWS credential chain.");
2595
+ }
2545
2596
  return authentication?.method === "api_key"
2546
2597
  ? `Authentication failed using ${authentication.source}. ` +
2547
2598
  "Your ChatGPT sign-in was not used. " +
@@ -2549,6 +2600,10 @@ function scanFailureMessage(error, authentication) {
2549
2600
  : "Authentication failed using stored ChatGPT credentials. " +
2550
2601
  "Sign in again with 'codex-security login' or provide a valid API key.";
2551
2602
  case "forbidden":
2603
+ if (authentication?.method === "aws_credentials") {
2604
+ return (`The AWS credentials from ${authentication.source} cannot access the configured Amazon Bedrock model. ` +
2605
+ "Check your AWS identity and Bedrock model permissions.");
2606
+ }
2552
2607
  return authentication?.method === "api_key"
2553
2608
  ? `The API key from ${authentication.source} cannot access the configured model. ` +
2554
2609
  "Retry with '--auth chatgpt' or use an API key with model access."
@@ -2742,6 +2797,9 @@ export function parseCodexOverrides(values, model, effort, provider) {
2742
2797
  [provider]: { ...EXTERNAL_CODEX_PROVIDERS[provider] },
2743
2798
  };
2744
2799
  }
2800
+ else if (provider === "amazon-bedrock") {
2801
+ result["model_provider"] = provider;
2802
+ }
2745
2803
  for (const value of values) {
2746
2804
  const separator = value.indexOf("=");
2747
2805
  const key = separator < 0 ? "" : value.slice(0, separator);
@@ -2791,14 +2849,16 @@ export function parseCodexOverrides(values, model, effort, provider) {
2791
2849
  if (effort !== undefined && key === "model_reasoning_effort") {
2792
2850
  throw new CodexSecurityError("--effort conflicts with --codex model_reasoning_effort");
2793
2851
  }
2794
- if (isExternalModelProvider(provider) && key === "model_provider") {
2852
+ if ((isExternalModelProvider(provider) || provider === "amazon-bedrock") &&
2853
+ key === "model_provider") {
2795
2854
  throw new CodexSecurityError("--provider conflicts with --codex model_provider");
2796
2855
  }
2797
2856
  throw new CodexSecurityError("Duplicate --codex key");
2798
2857
  }
2799
2858
  cursor[final] = parsed;
2800
2859
  }
2801
- if (isExternalModelProvider(provider) && !("model" in result)) {
2860
+ if ((isExternalModelProvider(provider) || provider === "amazon-bedrock") &&
2861
+ !("model" in result)) {
2802
2862
  throw new CodexSecurityError(`--model is required when using --provider ${provider}`);
2803
2863
  }
2804
2864
  return result;