fullcourtdefense 2.3.1 → 2.3.2

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.
@@ -2863,7 +2863,7 @@ function isSensitivePathContext(toolName, candidate) {
2863
2863
  // or when a language interpreter does and the program spawns a process.
2864
2864
  // `$( )` / a backtick pair in a double-quoted program still runs first.
2865
2865
  // Top-level stages only (not inside $( ) or backticks). See editCommandParts.
2866
- const DATA_TO_INTERPRETER = /\b(?:iex|icm|invoke-expression|invoke-command)\b|\[scriptblock\]::create\b|(?<![\w./\\]|[\w.]-)eval(?![\w./\\]|-\w)|\bxargs\b(?!(?:\s+(?:-[0prtx]+|--(?:null|no-run-if-empty|verbose|exit)|-[ILnPsdE]\s*[^\s;&|-][^\s;&|]*|--(?:replace|max-lines|max-args|max-procs|max-chars|delimiter|eof)=[^\s;&|]+))*\s+(?:sudo\s+)?(?:(?:e|f|z|ze|zf)?grep|rg|ugrep|ag|ack)(?:\.exe)?(?=\s|$))|\bbase64\b[^\n]*(?:-d\b|--decode\b)|frombase64string|-encodedcommand\b|\s-enc\s|(?<!\|)\|(?!\|)\s*&?\s*(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\.exe)?|cmd(?:\.exe)?|node|python[0-9.]*|perl|ruby)\b|\b(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\.exe)?|cmd(?:\.exe)?)\s+(?:-c|\/c|-e|-command|-scriptblock)\b|\b(?:ssh|wsl(?:\.exe)?|chroot)\b|\b(?:docker|kubectl|podman|nerdctl)(?:\.exe)?\s+(?:exec|run)\b/i;
2866
+ const DATA_TO_INTERPRETER = /\b(?:iex|icm|invoke-expression|invoke-command)\b|\[scriptblock\]::create\b|(?<![\w./\\]|[\w.]-)eval(?![\w./\\]|-\w)|\bxargs\b(?!(?:\s+(?:-[0prtx]+|--(?:null|no-run-if-empty|verbose|exit)|-[ILnPsdE]\s*[^\s;&|-][^\s;&|]*|--(?:replace|max-lines|max-args|max-procs|max-chars|delimiter|eof)=[^\s;&|]+))*\s+(?:sudo\s+)?(?:(?:e|f|z|ze|zf)?grep|rg|ugrep|ag|ack)(?:\.exe)?(?=\s|$))|\bbase64\b[^\n]*(?:-d\b|--decode\b)|frombase64string|-encodedcommand\b|\s-enc\s|(?<!\|)\|(?!\|)\s*&?\s*(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\.exe)?|cmd(?:\.exe)?|node|python[0-9.]*|perl|ruby|psql|mysql|mariadb|sqlite3|sqlcmd)\b|\b(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\.exe)?|cmd(?:\.exe)?)\s+(?:-c|\/c|-e|-command|-scriptblock)\b|\b(?:ssh|wsl(?:\.exe)?|chroot)\b|\b(?:docker|kubectl|podman|nerdctl)(?:\.exe)?\s+(?:exec|run)\b/i;
2867
2867
  // A LANGUAGE interpreter's `-c` / `-e` argument is CODE in another language, not
2868
2868
  // a shell command line. `node -e "console.log('rm -rf /')"` prints a string;
2869
2869
  // `python -c "print('DROP TABLE')"` prints a string. That code only reaches the
@@ -2967,6 +2967,42 @@ const INERT_DATA = ' fcd_inert_data ';
2967
2967
  // Code position immediately before a quoted span: interpreter code flags or a
2968
2968
  // remote/nested executor earlier in the same statement (no ; & | between).
2969
2969
  const CODE_CONTEXT_BEFORE = /(?:(?:^|[;&|(]|\s)(?:-c|\/c|-e|-command|-scriptblock|-filter|-q|--query|-query|--execute|--command|--eval)[= ]\s*|(?:^|[;&|(]\s*)(?:\S*[\\/])?(?:sudo\s+|doas\s+)?(?:ssh|wsl(?:\.exe)?|chroot|su|screen|tmux)(?:\s[^;&|"']*)?\s|(?:\S*[\\/])?(?:docker|kubectl|podman|nerdctl)(?:\.exe)?\s+(?:exec|run)\b[^;&|"']*\s)$/i;
2970
+ /** Programs whose bundled short flags end in their inline-code flag: shells and `su` (`-c`), SQL clients (`-c`, mysql `-e`). */
2971
+ const BUNDLED_CODE_FLAG_PROGRAMS = new Set(['sh', 'bash', 'zsh', 'dash', 'ksh', 'su', 'psql', 'mysql', 'mariadb', 'sqlite3', 'sqlcmd']);
2972
+ /**
2973
+ * A bundled short-flag group ending in the inline-code flag right before a quoted span, on a shell or SQL client
2974
+ * (`psql -Atc "…"`, `bash -ec '…'`, `mysql -Ne "…"`): the same code position as `-c` (sdk-albtech 2026-11-22: a
2975
+ * customer's `psql -Atc "DROP DATABASE …"` read as prose). Only those programs, so a word flag (`find -exec`,
2976
+ * `pwsh -enc`) never qualifies. Plain character reads, no regex: a class added to CODE_CONTEXT_BEFORE costs the Rust
2977
+ * twin its fast path on hostile lines. Twin of `ends_with_bundled_code_flag` (inert.rs).
2978
+ */
2979
+ function endsWithBundledCodeFlag(before) {
2980
+ const space = (c) => c === ' ' || c === '\t' || c === '\n' || c === '\r' || c === '\v' || c === '\f';
2981
+ let end = before.length;
2982
+ while (end > 0 && space(before[end - 1]))
2983
+ end--;
2984
+ if (end > 0 && before[end - 1] === '=')
2985
+ end--;
2986
+ else if (end === before.length || before[end] !== ' ')
2987
+ return false;
2988
+ let start = end;
2989
+ while (start > 0 && /^[A-Za-z]$/.test(before[start - 1]))
2990
+ start--;
2991
+ const letters = before.slice(start, end).toLowerCase();
2992
+ if (letters.length < 2 || letters.length > 5 || start === 0 || before[start - 1] !== '-')
2993
+ return false;
2994
+ const dash = start - 1;
2995
+ if (dash > 0 && !';&|('.includes(before[dash - 1]) && !space(before[dash - 1]))
2996
+ return false;
2997
+ let from = dash;
2998
+ while (from > 0 && !';&|(\n'.includes(before[from - 1]))
2999
+ from--;
3000
+ const programs = before.slice(from, dash).split(/[ \t\r\v\f]+/).map(word => word.replace(/^.*[\\/]/, '').replace(/\.exe$/i, '').toLowerCase());
3001
+ const program = programs.find(word => BUNDLED_CODE_FLAG_PROGRAMS.has(word));
3002
+ if (!program)
3003
+ return false;
3004
+ return letters.endsWith('c') || ((program === 'mysql' || program === 'mariadb') && letters.endsWith('e'));
3005
+ }
2970
3006
  // ---- search programs: the pattern operand is search text (invariant 6) ------
2971
3007
  /** Programs whose pattern operand is text to look for, never a command or a file. */
2972
3008
  const SEARCH_PATTERN_PROGRAMS = new Set(['grep', 'egrep', 'fgrep', 'zgrep', 'zegrep', 'zfgrep', 'rg', 'ugrep', 'ag', 'ack', 'findstr', 'select-string', 'sls']);
@@ -4401,7 +4437,7 @@ function stripQuotedData(text) {
4401
4437
  if (LANG_INTERPRETER_CODE_BEFORE.test(before))
4402
4438
  return interpreterCodeSpawnsProcess(before, body) || interpreterCodeRequestsMetadata(body) ? whole : INERT_DATA;
4403
4439
  // Code position: executes — unless it is a search program's own pattern operand (invariant 6).
4404
- if (CODE_CONTEXT_BEFORE.test(before) && !searchPatterns.isPattern(offset))
4440
+ if ((CODE_CONTEXT_BEFORE.test(before) || endsWithBundledCodeFlag(before)) && !searchPatterns.isPattern(offset))
4405
4441
  return whole;
4406
4442
  if (dq !== undefined && doubleQuotedInterpolates(body, powershell))
4407
4443
  return whole; // $( )/`cmd` executes first
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullcourtdefense",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Control what your AI agents do: check every tool call against your company's FullCourtDefense policy (Monitor or Enforce).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",