@akasecurity/ai-tc-codex 0.9.5 → 0.9.6

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.
@@ -26077,6 +26077,40 @@ function escapeRegExp2(value) {
26077
26077
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26078
26078
  }
26079
26079
 
26080
+ // ../../packages/detections/src/regex-cache.ts
26081
+ var singles = /* @__PURE__ */ new WeakMap();
26082
+ var keywordLists = /* @__PURE__ */ new WeakMap();
26083
+ var labelLists = /* @__PURE__ */ new WeakMap();
26084
+ function listCache(kind) {
26085
+ return kind === "keyword" ? keywordLists : labelLists;
26086
+ }
26087
+ function memoizedRegExp(owner, build) {
26088
+ const cached2 = singles.get(owner);
26089
+ if (cached2 !== void 0) {
26090
+ cached2.lastIndex = 0;
26091
+ return cached2;
26092
+ }
26093
+ const compiled = build();
26094
+ singles.set(owner, compiled);
26095
+ return compiled;
26096
+ }
26097
+ function memoizedRegExpList(kind, owner, build) {
26098
+ const cache = listCache(kind);
26099
+ const cached2 = cache.get(owner);
26100
+ if (cached2 !== void 0) {
26101
+ if (cached2.stateful) {
26102
+ for (const re of cached2.entries) if (re !== void 0) re.lastIndex = 0;
26103
+ }
26104
+ return cached2.entries;
26105
+ }
26106
+ const entries = build();
26107
+ cache.set(owner, {
26108
+ entries,
26109
+ stateful: entries.some((re) => re !== void 0 && (re.global || re.sticky))
26110
+ });
26111
+ return entries;
26112
+ }
26113
+
26080
26114
  // ../../packages/detections/src/matchers/limits.ts
26081
26115
  var MAX_MATCHES_PER_RULE = 1e4;
26082
26116
  var MAX_REGEX_INPUT_LENGTH = 2e5;
@@ -26087,10 +26121,17 @@ var KeywordMatcher2 = class {
26087
26121
  if (rule.matcher.type !== "keyword") return [];
26088
26122
  const { keywords, caseSensitive } = rule.matcher;
26089
26123
  const spans = [];
26090
- for (const kw of keywords) {
26091
- if (kw.length === 0) continue;
26124
+ const compiled = memoizedRegExpList(
26125
+ "keyword",
26126
+ rule.matcher,
26127
+ () => keywords.map((kw) => {
26128
+ if (kw.length === 0) return void 0;
26129
+ return new RegExp(escapeRegExp2(kw), caseSensitive ? "gu" : "giu");
26130
+ })
26131
+ );
26132
+ for (const re of compiled) {
26133
+ if (re === void 0) continue;
26092
26134
  if (spans.length >= MAX_MATCHES_PER_RULE) break;
26093
- const re = new RegExp(escapeRegExp2(kw), caseSensitive ? "gu" : "giu");
26094
26135
  let m;
26095
26136
  while ((m = re.exec(text)) !== null) {
26096
26137
  spans.push({ start: m.index, end: m.index + m[0].length });
@@ -26106,7 +26147,10 @@ var RegexMatcher2 = class {
26106
26147
  match(text, rule) {
26107
26148
  if (rule.matcher.type !== "regex") return [];
26108
26149
  const { pattern, flags, captureGroup } = rule.matcher;
26109
- const re = new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`);
26150
+ const re = memoizedRegExp(
26151
+ rule.matcher,
26152
+ () => new RegExp(pattern, flags.includes("d") ? flags : `${flags}d`)
26153
+ );
26110
26154
  const scanText2 = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
26111
26155
  const spans = [];
26112
26156
  let m;
@@ -26214,11 +26258,15 @@ function isCorroborated(candidate, candidates, text) {
26214
26258
  const labels = req.labels;
26215
26259
  if (labels && labels.length > 0) {
26216
26260
  const haystack = text.slice(Math.max(0, winStart), winEnd);
26217
- for (const label of labels) {
26218
- const trimmed = label.trim();
26219
- if (trimmed.length === 0) continue;
26220
- const re = new RegExp(`(?<![A-Za-z0-9])${escapeRegExp2(trimmed)}(?![A-Za-z0-9])`, "i");
26221
- if (re.test(haystack)) return true;
26261
+ for (const re of memoizedRegExpList(
26262
+ "label",
26263
+ req,
26264
+ () => labels.map((label) => {
26265
+ const trimmed = label.trim();
26266
+ return trimmed.length === 0 ? void 0 : new RegExp(`(?<![A-Za-z0-9])${escapeRegExp2(trimmed)}(?![A-Za-z0-9])`, "i");
26267
+ })
26268
+ )) {
26269
+ if (re?.test(haystack)) return true;
26222
26270
  }
26223
26271
  }
26224
26272
  return false;
@@ -26486,13 +26534,14 @@ function probesFor(rule) {
26486
26534
  const derived = rule.matcher.type === "regex" ? derivedProbes(rule.matcher.pattern) : [];
26487
26535
  return [...derived, ...EXPONENTIAL_PROBES, ...POLYNOMIAL_PROBES];
26488
26536
  }
26489
- function worstProbeMs(rule) {
26537
+ var wallClock = () => performance.now();
26538
+ function worstProbeMs(rule, now = wallClock) {
26490
26539
  let ms = 0;
26491
26540
  let probe = "";
26492
26541
  for (const text of probesFor(rule)) {
26493
- const start = performance.now();
26542
+ const start = now();
26494
26543
  scan(text, [rule]);
26495
- const elapsed = performance.now() - start;
26544
+ const elapsed = now() - start;
26496
26545
  if (elapsed > ms) {
26497
26546
  ms = elapsed;
26498
26547
  probe = text;
@@ -29131,7 +29180,7 @@ import { basename as basename4, dirname as dirname3, sep as sep3 } from "path";
29131
29180
  // ../../packages/plugin-sdk/src/project-files.ts
29132
29181
  var import_ignore = __toESM(require_ignore(), 1);
29133
29182
  import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "fs";
29134
- import { basename as basename5, join as join12, relative, sep as sep4 } from "path";
29183
+ import { basename as basename5, join as join12 } from "path";
29135
29184
 
29136
29185
  // ../../packages/plugin-sdk/src/provider-env-antigravity.ts
29137
29186
  var optionalBaseUrl2 = external_exports.preprocess((v) => {
@@ -828,3 +828,20 @@ pointer inside a Bash command is denied rather than executed or substituted.
828
828
  If the user asks about recovering a redacted value, point them at the vault
829
829
  surfaces that do exist on this machine (`aka vault show`, the dashboard's
830
830
  Vault page) rather than implying this plugin can reveal anything.
831
+
832
+ **The model-judge step cannot run on native Windows.** The judge spawns the
833
+ `codex` CLI through a shell-free `execFileSync`, and an npm-installed CLI is a
834
+ `.cmd` shim on Windows, which Node has refused to spawn without a shell since
835
+ the CVE-2024-27980 fix. So a user who grants model-judge consent gets a spawn
836
+ failure at that step rather than a rated set of findings, and the step exits
837
+ non-zero instead of completing. Everything before it is unaffected — the
838
+ calibration questions, the consent-gated historical read, and the local ruleset
839
+ scan all run, and every finding is still detected and redacted locally. What is
840
+ unavailable is only the model pass that rates false positives and severity.
841
+
842
+ Say this plainly if a Windows user asks why setup stopped there, and do not
843
+ offer to retry it: the fix is a code change, tracked separately. Two things
844
+ worth getting right if it comes up — running under WSL2 is Linux rather than
845
+ Windows and is not affected, and declining model-judge consent is not a
846
+ workaround so much as the other supported path, since the local scan is what
847
+ produces the findings in the first place.