@cratis/pi 7.153.0 → 7.153.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.
@@ -69,7 +69,33 @@ best-effort lexical check, not enforcement: a variable holding the whole path st
69
69
  The shell-write reference scan keeps conservative leading-dot intersections: a tool named `Bash`,
70
70
  `SHELL`, and the hook process's options do not establish the execution shell's options. Globbed writes
71
71
  therefore remain blocked. Read operands under protected paths are not write targets: `rg -n`/`-l`,
72
- quoted `--glob`/`-g` filters, and numeric/last-line `sed -n …p` scripts are recognized as read-only.
72
+ quoted `--glob`/`-g` filters, `grep`/`egrep`/`fgrep` filename filters (`--include`/`--exclude` with a non-empty
73
+ `=value` or separate literal value, never an unquoted glob), and numeric/last-line `sed -n …p` scripts are recognized as read-only.
74
+ Plain `git branch --list` and `git tag -l`/`--list` accept literal pattern operands, including quoted globs;
75
+ option-looking operands, mutation flags and extra options are not admitted. These list forms retain the
76
+ `&&`-only chain restriction. `git branch -l` is not a list exemption.
77
+ Reference extraction discards only the non-value-bearing match text of simple `${NAME%pattern}`,
78
+ `${NAME%%pattern}`, `${NAME#pattern}`, `${NAME##pattern}`, case-conversion operators (`^`, `^^`, `,`, `,,`),
79
+ and numeric offset/length forms. An opaque placeholder preserves the expansion marker and unknown path-prefix
80
+ and segment views of a plain parameter; an additional empty-value view retains adjacent literal spellings.
81
+ This is not shell evaluation: nested, malformed, default/assignment, replacement and command-substitution
82
+ bodies remain visible, and the command lexer still rejects expansions. Literal or decoded placeholder
83
+ collisions disable the rewrite.
84
+
85
+ `cp`, `rsync` and `install` have a separate, closed destination grammar. Reviewed options must precede
86
+ operands; unknown/abbreviated options, options after operands, remote rsync destinations, directory changes
87
+ and input redirects fall back to whole-command classification. Explicit destinations, redirects, and
88
+ implicit directory/basename write targets remain classified by the Write/Edit guard. Directory destinations
89
+ include `-t`, trailing slashes, existing directories and multiple-source copies; uncertain destinations are
90
+ checked as both files and directories. `-T` selects a file destination. Existing file destinations permit
91
+ renames. Protected source paths themselves are reads (the secrets guard still applies); for example,
92
+ `cp .mcp.json /tmp/backup.json` is admitted, but `cp .env .` is not. Source globs may copy to literal external
93
+ directories such as `cp Source/Foo/*.md /tmp/cratis-out/`. Their real matched basenames are still classified:
94
+ protected environment names remain writes even outside repositories. Missing or uncertain matches retain
95
+ conservative glob classification. Inside repositories, possibly protected implicit
96
+ glob basenames and rsync directory contents fail closed; leading wildcard basenames conservatively include
97
+ dotfiles. Globs that can supply option-shaped source filenames are not admitted. No copy command is executed
98
+ by the check; only literal path metadata is queried.
73
99
  `sed -n` scripts with writes, execution or extra options are not exempt. `cd` permits `&&`
74
100
  read/search chains, including pipelines of reviewed readers, but never a piped `cd` or index-changing
75
101
  command. `git branch --show-current` retains the `&&`-only restriction; semicolons and other
@@ -278,7 +304,7 @@ arguments are operands. A lone `-` is a stdin operand. Value-free short flags ma
278
304
  | `ls` | `-l -a -A -1 -h -d -R -t -r -F` |
279
305
  | `df` | `-h` |
280
306
  | `rg` | `-n -l -i`, `--files`; literal `--glob`/`-g` filters |
281
- | `grep`, `egrep`, `fgrep` | `-n -i -r -R -l -L -c -v -w -x -F -E -H -h -o -q -s`; `-e PATTERN`, `-A N`, `-B N`, `-C N`; no long options |
307
+ | `grep`, `egrep`, `fgrep` | `-n -i -r -R -l -L -c -v -w -x -F -E -H -h -o -q -s`; `-e PATTERN`, `-A N`, `-B N`, `-C N`; `--include=PATTERN`, `--exclude=PATTERN` or a separate literal pattern value; a search pattern is still required |
282
308
  | `echo` | `-n -e -E` |
283
309
  | `printf`, `test`, `[`, `true`, `false`, `pwd` | None (in particular, no `printf -v`) |
284
310
  | `git status` | `-s -b --short --porcelain` |
@@ -288,6 +314,11 @@ arguments are operands. A lone `-` is a stdin operand. Value-free short flags ma
288
314
  | `git add` | `-A -u -p -v --all`, including path globs for installed prompts |
289
315
  | `git commit` | `-m MSG`, `--message MSG`, `-mMSG`, `-a`, `-q`; `-F FILE` only for a literal non-protected file; no `--no-verify` |
290
316
  | `git blame`, `ls-files`, `rev-parse`, `check-ignore`, `grep` | None |
317
+ | `git branch` | Exactly `--show-current`, or `--list` followed only by literal patterns |
318
+ | `git tag` | `-l` or `--list`, followed only by literal patterns |
319
+ | `cp` | `-r -R -p -a -f -v -n -i -u -T -L -P -H`; `--recursive --force --verbose --no-clobber --archive --no-target-directory`; `-t DIR`, `-tDIR`, `--target-directory DIR`, `--target-directory=DIR` (also in short-flag groups) |
320
+ | `rsync` | `-a -r -v -n -u -z -t -p`; `--archive --recursive --verbose --dry-run --update --compress --times --perms` |
321
+ | `install` | `-c -v -C -p`; `-d` directory operands; `-m MODE`/`-mMODE` (three or four octal digits); the same target-directory forms as `cp` |
291
322
 
292
323
  The only global Git option exemption is a single separate `-C <dir>` with a literal,
293
324
  non-empty directory word not starting with `-`, followed by exactly one of these tails:
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # Whole-command reference filter, not a shell interpreter or sandbox.
3
3
  # The Write/Edit guard is the only protected-path policy. With any protected reference,
4
- # accept only the small read-only command language below; never infer write destinations.
4
+ # accept only the reviewed command language below and its explicit copy-destination grammar.
5
5
  set -euo pipefail
6
6
  export LC_ALL=C
7
7
  script_directory="${BASH_SOURCE[0]%/*}"
@@ -35,9 +35,17 @@ cwd="${cwd:-$PWD}"
35
35
 
36
36
  IFS= read -r -d '' program <<'AWK' || true
37
37
  function candidate(s) {
38
- if (s == "" || s ~ /[\n\r\t]/ || (s in seen)) return
39
- if (++candidates > 256 || length(s) > 4096) exit 2
40
- seen[s] = 1; print s
38
+ if (checking_marker) return
39
+ if (s == "" || s ~ /[\n\r\t]/) return
40
+ if (collecting) {
41
+ if (s in collected) return
42
+ if (++collected_count > 256 || length(s) > 4096) exit 2
43
+ collected[s] = 1
44
+ } else {
45
+ if (s in seen) return
46
+ if (++candidates > 256 || length(s) > 4096) exit 2
47
+ seen[s] = 1; print s
48
+ }
41
49
  if (s != tolower(s)) candidate(tolower(s))
42
50
  # A generic attached option prefix must not hide a path spelling (-t.pi/...).
43
51
  if (s ~ /^-/ && match(s, /[.\/]/) && RSTART > 1) candidate(substr(s, RSTART))
@@ -99,6 +107,15 @@ function scan(s, n, i, c, word, whole, flat, expanded, chunk) {
99
107
  if (flat != s) scan(flat)
100
108
  n = length(s)
101
109
  for (i = 1; i <= n; i++) {
110
+ # The placeholder is one opaque expansion, not a variable name or literal path segment.
111
+ # Preserve the same unknown-prefix suffix views as ${NAME}, without its operator operand.
112
+ if (match_placeholders && substr(s, i, length(MATCH_MARKER)) == MATCH_MARKER) {
113
+ candidate(word); candidate(whole)
114
+ if (expanded || word ~ /^~/) remainder(word)
115
+ word = whole = ""; expanded = 1; chunk = chunk "$"
116
+ i += length(MATCH_MARKER) - 1
117
+ continue
118
+ }
102
119
  c = substr(s, i, 1)
103
120
  if (c ~ /[ \t\n\r;|&<>]/) { chunk_suffixes(chunk); chunk = "" }
104
121
  else chunk = chunk c
@@ -161,7 +178,49 @@ function protected(s) { return s in protected_paths }
161
178
  # Only when every command is accepted are the words of pure readers dropped from classification.
162
179
  function fail() { bad = unparsed = 1 }
163
180
  # Reference extraction for one stretch of raw command text.
164
- function emit_text(t) { scan(t); scan(unquote(t)); raw_brace_scan(t) }
181
+ # Rewrite extraction data only; the lexer still rejects expansions. Nested and value-bearing
182
+ # bodies stay visible because their text can supply a protected path or execute another command.
183
+ function strip_expansion_operators(t, out, start, rest, body, name, op, depth, i, c, count) {
184
+ match_placeholders = 0
185
+ if (!match_rewrite_safe || index(t, MATCH_MARKER)) return t
186
+ while ((start = index(t, "${")) && ++count <= 256) {
187
+ out = out substr(t, 1, start - 1); rest = substr(t, start + 2); depth = 1
188
+ for (i = 1; i <= length(rest); i++) {
189
+ c = substr(rest, i, 1)
190
+ if (c == "{") depth++
191
+ if (c == "}") { depth--; if (!depth) break }
192
+ }
193
+ if (depth) return out substr(t, start)
194
+ body = substr(rest, 1, i - 1); name = op = ""
195
+ if (match(body, /^[A-Za-z_][A-Za-z0-9_]*/)) {
196
+ name = substr(body, 1, RLENGTH); op = substr(body, RLENGTH + 1)
197
+ }
198
+ if (name != "" && (op ~ /^(##?|%%?|\^\^?|,,?)[^$`(){}"\047\\;|&<>[:space:]]*$/ ||
199
+ op ~ /^:([0-9]+| -?[0-9]+)(:([0-9]+| -?[0-9]+))?$/)) {
200
+ out = out MATCH_MARKER; match_placeholders = 1
201
+ } else out = out "${" body "}"
202
+ t = substr(rest, i + 1)
203
+ }
204
+ return out t
205
+ }
206
+ function emit_text(t) {
207
+ t = strip_expansion_operators(t)
208
+ scan(t); scan(unquote(t)); raw_brace_scan(t)
209
+ if (match_placeholders) {
210
+ # Also retain the possible empty-value spelling, e.g. .e${x%y}nv -> .env. It supplements,
211
+ # never replaces, the expanded/unknown-prefix view above.
212
+ gsub(/\$__CRATIS_MATCH__/, "", t); match_placeholders = 0
213
+ scan(t); scan(unquote(t)); raw_brace_scan(t)
214
+ }
215
+ }
216
+ function destination_allowed(w, implicit, s) {
217
+ if (!implicit && w ~ /[$`*?\[{~()]/) return 0
218
+ delete collected; collected_count = 0; collecting = 1
219
+ candidate(w); emit_text(w)
220
+ collecting = 0
221
+ for (s in collected) if (protected(s)) return 0
222
+ return 1
223
+ }
165
224
  function endword() {
166
225
  if (!inword) return
167
226
  if (redirect) {
@@ -194,11 +253,11 @@ function short_flags(w, flags, k) {
194
253
  return 1
195
254
  }
196
255
  function number(s) { return s ~ /^[+-]?[0-9]+$/ }
197
- function options_allowed(verb, first, i, w) {
256
+ function options_allowed(verb, first, i, w, filters, patterns) {
198
257
  for (i = first; i <= argc; i++) {
199
258
  w = W[i]
200
259
  if (w == "--") return 1
201
- if (w !~ /^-/ || w == "-") continue
260
+ if (w !~ /^-/ || w == "-") { patterns++; continue }
202
261
  if ((verb, w) in long_options) continue
203
262
  if (verb == "head" || verb == "tail" || verb == "git log") {
204
263
  if (w == "-n" || (verb != "git log" && w == "-c")) {
@@ -208,7 +267,12 @@ function options_allowed(verb, first, i, w) {
208
267
  if (w ~ /^-n[+-]?[0-9]+$/ || w ~ /^-[0-9]+$/) continue
209
268
  }
210
269
  if (verb == "grep" || verb == "egrep" || verb == "fgrep") {
211
- if (w == "-e") { if (++i > argc) return 0; continue }
270
+ if (w == "-e") { if (++i > argc) return 0; patterns++; continue }
271
+ if (w ~ /^--(include|exclude)=./) { filters++; continue }
272
+ if (w == "--include" || w == "--exclude") {
273
+ if (++i > argc || W[i] == "" || globbed[i]) return 0
274
+ filters++; continue
275
+ }
212
276
  if (w == "-A" || w == "-B" || w == "-C") {
213
277
  if (++i > argc || !number(W[i])) return 0
214
278
  continue
@@ -236,7 +300,7 @@ function options_allowed(verb, first, i, w) {
236
300
  }
237
301
  if (!short_flags(w, short_options[verb])) return 0
238
302
  }
239
- return 1
303
+ return !filters || patterns > 0
240
304
  }
241
305
  # awk is read-only only for the shape awk [-F sep] 'program' operands. Every other option (-f, -v, -e, -i,
242
306
  # --include, --, ...) is refused. awk output, execution and file reads need one of > | system getline close
@@ -319,12 +383,18 @@ function print_only_sed( i, ended) {
319
383
  # Verbs whose reviewed options are display flags only: a word-leading glob that expands to an option-shaped
320
384
  # file name can change what they print, never what they write or run. Every other verb refuses a leading glob.
321
385
  function shell_quote(s) { gsub(/\047/, "\047\\\047\047", s); return "\047" s "\047" }
386
+ # Bash 3.2 initializes compgen glob flags only after pathname expansion. Prime that state in
387
+ # the same shell after setting and verifying every required option; never enumerate unchecked.
388
+ function glob_enumeration_script() {
389
+ return "cd -- \"$1\" && [ -r . ] && [ -x . ] || exit 3; unset GLOBIGNORE; " \
390
+ "shopt -s nullglob dotglob nocaseglob && shopt -q nullglob dotglob nocaseglob || exit 3; : *; " \
391
+ "n=0; while IFS= read -r f; do n=$((n+1)); [ \"$n\" -le 200 ] || exit 3; " \
392
+ "case $f in -*|*[!a-zA-Z0-9._/@+=,:%-]*) exit 3;; esac; printf \"F:%s\\n\" \"$f\"; done < <(compgen -G \"$2\"); echo OK"
393
+ }
322
394
  # rg can execute --pre supplied by a filename. Check real leading-glob matches, never command text.
323
395
  function reader_globs( i, cmd, line, count, ok, script) {
324
396
  if (changed_cwd || ENVIRON["GSW_GLOB_SAFE"] != "1") return 0
325
- script = "cd -- \"$1\" && [ -r . ] && [ -x . ] || exit 3; unset GLOBIGNORE; shopt -s nullglob dotglob nocaseglob; " \
326
- "n=0; while IFS= read -r f; do n=$((n+1)); [ \"$n\" -le 200 ] || exit 3; " \
327
- "case $f in -*|*[!a-zA-Z0-9._/@+=,:%-]*) exit 3;; esac; printf \"F:%s\\n\" \"$f\"; done < <(compgen -G \"$2\"); echo OK"
397
+ script = glob_enumeration_script()
328
398
  for (i = 2; i <= argc; i++) {
329
399
  if (W[i] == "--") return 1
330
400
  if (!leading[i]) continue
@@ -339,7 +409,7 @@ function reader_globs( i, cmd, line, count, ok, script) {
339
409
  return 1
340
410
  }
341
411
  function glob_safe() {
342
- return W[1] ~ /^(cat|head|tail|wc|ls|grep|egrep|fgrep|shellcheck)$/ || (W[1] == "rg" && reader_globs()) || (W[1] == "git" && W[2] == "ls-files")
412
+ return W[1] ~ /^(cat|head|tail|wc|ls|grep|egrep|fgrep|shellcheck)$/ || (W[1] ~ /^(rg|cp|rsync|install)$/ && reader_globs()) || (W[1] == "git" && W[2] == "ls-files")
343
413
  }
344
414
  function find_allowed( i, w, predicates) {
345
415
  for (i = 2; i <= argc; i++) {
@@ -387,6 +457,130 @@ function managed_script( i) {
387
457
  }
388
458
  return 0
389
459
  }
460
+ function list_pattern_allowed(verb, first, i) {
461
+ if (W[first] != "--list" && !(verb == "git tag" && W[first] == "-l")) return 0
462
+ for (i = first + 1; i <= argc; i++) if (W[i] == "" || W[i] ~ /^-/ || globbed[i]) return 0
463
+ return 1
464
+ }
465
+ # Query literal paths only, never command text. Unknown destinations are directory candidates too.
466
+ # Looking up the nearest existing ancestor also handles missing directories and directory symlinks.
467
+ function copy_path_kind(w, script, cmd, kind) {
468
+ if (w in PATH_KIND) return PATH_KIND[w]
469
+ script = "cd -- \"$1\" || exit 3; p=$2; case $p in /*) ;; *) p=$PWD/$p;; esac; " \
470
+ "if [ -f \"$p\" ]; then echo file; exit; fi; " \
471
+ "while [ ! -d \"$p\" ]; do p=${p%/*}; [ -n \"$p\" ] || p=/; done; " \
472
+ "if git -C \"$p\" rev-parse --show-toplevel >/dev/null 2>&1; then echo inside; else echo outside; fi"
473
+ cmd = "bash -c " shell_quote(script) " guard-copy " shell_quote(ENVIRON["GSW_CWD"]) " " shell_quote(w) " 2>/dev/null"
474
+ if ((cmd | getline kind) != 1) kind = ""
475
+ if (close(cmd) != 0 || kind !~ /^(file|inside|outside)$/) return ""
476
+ PATH_KIND[w] = kind
477
+ return kind
478
+ }
479
+ function copy_write_target(w, implicit) {
480
+ # Keep exact decoded words (including spaces and quotes), as well as the normal suffix views.
481
+ # A later parser failure still emits the whole command; these extra destinations only narrow it.
482
+ if (ENVIRON["GSW_MODE"] == "targets") { candidate(w); emit_text(w) }
483
+ return destination_allowed(w, implicit)
484
+ }
485
+ # External copies still write environment files. Expand source globs as literal metadata, judging
486
+ # each effective basename; if there are no matches, retain the conservative glob-path classifier.
487
+ function copy_external_glob(dest, source, base, script, cmd, line, count, ok, valid, path) {
488
+ if (ENVIRON["GSW_GLOB_SAFE"] != "1") return 0
489
+ script = glob_enumeration_script()
490
+ cmd = "bash -c " shell_quote(script) " guard-copy-glob " shell_quote(ENVIRON["GSW_CWD"]) " " shell_quote(source) " 2>/dev/null"
491
+ valid = 1
492
+ while ((cmd | getline line) > 0) {
493
+ if (line == "OK") { ok = 1; continue }
494
+ if (ok || substr(line, 1, 2) != "F:" || ++count > 200) { valid = 0; break }
495
+ path = substr(line, 3); sub(/^.*\//, "", path)
496
+ if (path == "" || !copy_write_target(dest "/" path, 1)) { valid = 0; break }
497
+ }
498
+ if (close(cmd) != 0 || !ok || !valid) return 0
499
+ return count ? 1 : copy_write_target(dest "/" base, 1)
500
+ }
501
+ # Judge both explicit destinations and the basenames utilities append to directory destinations.
502
+ # rsync directory contents may introduce protected names; do not infer a safe listing inside a repo.
503
+ function copy_effective_targets(verb, targets, sources, dirs, no_target, explicit_dirs, i, j, dest, kind, base) {
504
+ for (i = 1; i <= targets; i++) {
505
+ dest = destinations[i]
506
+ if (!copy_write_target(dest, 0)) return 0
507
+ if (dirs) continue
508
+ kind = copy_path_kind(dest)
509
+ if (kind == "") return 0
510
+ if (no_target || (kind == "file" && !explicit_dirs && sources == 1 && dest !~ /\/$/)) continue
511
+ for (j = 1; j <= sources; j++) {
512
+ if (verb == "rsync" && copy_sources[j] ~ /\/$/ && kind == "inside") {
513
+ if (!copy_write_target(dest "/.*", 1)) return 0
514
+ }
515
+ base = copy_sources[j]; sub(/\/+$/, "", base); sub(/^.*\//, "", base)
516
+ if (base == "") return 0
517
+ # Keep possible dotfiles separate from dependency-manifest exemptions. External glob
518
+ # matches are classified too: environment filenames are protected outside repositories.
519
+ if (base ~ /[*?\[]/) {
520
+ if (kind == "outside") {
521
+ if (!copy_external_glob(dest, copy_sources[j], base)) return 0
522
+ continue
523
+ }
524
+ if (base ~ /^[*?\[]/ && !copy_write_target(dest "/.*", 1)) return 0
525
+ }
526
+ if (!copy_write_target(dest "/" base, 1)) return 0
527
+ }
528
+ }
529
+ return 1
530
+ }
531
+ # Options precede operands so BSD and GNU agree about the destination. Source paths themselves
532
+ # are reads; only explicit and effective destinations are collected for the write classifier.
533
+ function copy_targets(verb, i, w, j, ch, tail, value, targets, dirs, no_target, operands, last, flags, longs, explicit_dirs) {
534
+ if (changed_cwd || input_redirect) return 0
535
+ flags = verb == "cp" ? "rRpafvniuTLPH" : (verb == "rsync" ? "arvnuztp" : "cvCp")
536
+ longs = verb == "cp" ? " --recursive --force --verbose --no-clobber --archive --no-target-directory " : \
537
+ (verb == "rsync" ? " --archive --recursive --verbose --dry-run --update --compress --times --perms " : " ")
538
+ delete destinations; delete copy_sources
539
+ for (i = 2; i <= argc; i++) {
540
+ w = W[i]
541
+ if (w == "--") { i++; break }
542
+ if (w == "-" || w !~ /^-/) break
543
+ if (globbed[i]) return 0
544
+ if (verb != "rsync" && w ~ /^--target-directory(=|$)/) {
545
+ value = substr(w, 20)
546
+ if (w == "--target-directory") { if (++i > argc) return 0; value = W[i] }
547
+ if (value == "" || value ~ /^-/ || globbed[i]) return 0
548
+ destinations[++targets] = value; continue
549
+ }
550
+ if (w ~ /^--/) {
551
+ if (index(longs, " " w " ") == 0) return 0
552
+ if (w == "--no-target-directory") no_target = 1
553
+ continue
554
+ }
555
+ for (j = 2; j <= length(w); j++) {
556
+ ch = substr(w, j, 1)
557
+ if (verb != "rsync" && (ch == "t" || (verb == "install" && ch == "m"))) {
558
+ tail = substr(w, j + 1); value = tail
559
+ if (tail == "") { if (++i > argc) return 0; value = W[i] }
560
+ if (value == "" || value ~ /^-/ || globbed[i]) return 0
561
+ if (ch == "m") { if (value !~ /^[0-7][0-7][0-7][0-7]?$/) return 0 }
562
+ else destinations[++targets] = value
563
+ break
564
+ }
565
+ if (verb == "install" && ch == "d") { dirs = 1; continue }
566
+ if (index(flags, ch) == 0) return 0
567
+ if (ch == "T") no_target = 1
568
+ }
569
+ }
570
+ for (; i <= argc; i++) {
571
+ if (W[i] == "" || W[i] ~ /^-/) return 0
572
+ operands++; last = W[i]; copy_sources[operands] = W[i]
573
+ if (dirs) destinations[operands] = W[i]
574
+ }
575
+ if ((targets && (dirs || no_target)) || !operands) return 0
576
+ explicit_dirs = targets > 0
577
+ if (dirs) targets = operands
578
+ else if (!targets) {
579
+ if (operands < 2 || (verb == "rsync" && index(last, ":"))) return 0
580
+ destinations[++targets] = last; operands--
581
+ }
582
+ return copy_effective_targets(verb, targets, operands, dirs, no_target, explicit_dirs)
583
+ }
390
584
  function allow_command( verb, first, i) {
391
585
  if (!argc) return
392
586
  if (++commands > 64) { fail(); return }
@@ -399,6 +593,7 @@ function allow_command( verb, first, i) {
399
593
  changed_cwd = 1
400
594
  return
401
595
  }
596
+ if (verb ~ /^(cp|rsync|install)$/) { if (!copy_targets(verb)) cmd_failed = 1; return }
402
597
  if (verb == "sed") { if (!print_only_sed()) cmd_failed = 1; return }
403
598
  if (verb == "find") { if (!find_allowed()) cmd_failed = 1; return }
404
599
  if (verb == "gh") { if (!gh_allowed()) cmd_failed = 1; return }
@@ -413,8 +608,10 @@ function allow_command( verb, first, i) {
413
608
  if (verb == "git add" || verb == "git commit") changed_index = 1
414
609
  if (verb == "git branch") {
415
610
  conditional_only = 1
416
- if (argc != 3 || W[3] != "--show-current") { cmd_failed = 1; return }
611
+ if (!(argc == 3 && W[3] == "--show-current") && !list_pattern_allowed(verb, first)) cmd_failed = 1
612
+ return
417
613
  }
614
+ if (verb == "git tag") { conditional_only = 1; if (!list_pattern_allowed(verb, first)) cmd_failed = 1; return }
418
615
  if (verb == "awk") { if (!awk_allowed()) cmd_failed = 1; return }
419
616
  if (!(verb in verbs) || !options_allowed(verb, first)) cmd_failed = 1
420
617
  }
@@ -503,6 +700,11 @@ BEGIN {
503
700
  for (i = 0; i < 16; i++) HEX[substr("0123456789abcdef", i + 1, 1)] = i
504
701
  ESC["n"] = 10; ESC["r"] = 13; ESC["t"] = 9; ESC["\\"] = 92; ESC["\047"] = 39; ESC["\""] = 34
505
702
  text = ENVIRON["GSW_COMMAND"]
703
+ MATCH_MARKER = "$__CRATIS_MATCH__"
704
+ # Never interpret user-supplied or ANSI-decoded marker text as an internal token. Collisions
705
+ # disable admission rather than assigning special meaning to an existing parameter or literal.
706
+ checking_marker = 1; decoded = unquote(text); checking_marker = 0
707
+ match_rewrite_safe = !index(text, MATCH_MARKER) && !index(decoded, MATCH_MARKER)
506
708
  if (ENVIRON["GSW_MODE"] == "references") { emit_text(text); exit 0 }
507
709
  if (ENVIRON["GSW_MODE"] == "targets") {
508
710
  readonly(text)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.153.0",
3
+ "version": "7.153.2",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [