@cratis/pi 7.170.9 → 7.170.10

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.
@@ -155,6 +155,8 @@ function ansi_c(s, i, n, c, c2, v, d, k, lim, stop, digits) {
155
155
  if (v == 0) stop = 1
156
156
  else if (!stop) addw(CH[v], "l")
157
157
  }
158
+ # An unterminated string leaves word boundaries uncertain: no test-filter exemption applies.
159
+ filter_compound = 1
158
160
  return i
159
161
  }
160
162
  # Output redirections are removed before a command is analyzed, so a redirect never shifts a CLI's subcommand
@@ -240,11 +242,54 @@ function stem_units(t, m, start, stem) {
240
242
  return stem_match(t, stem, start, 1, 0, 0)
241
243
  }
242
244
  function test_filter_option(w) {
243
- return w ~ /^(-method|-class|-namespace|-trait|--filter|--filter-method|--filter-class|--filter-namespace|--treenode-filter)$/
245
+ return w ~ /^(-method|-class|-namespace|-trait|-filterVSTest|--filter|--filter-method|--filter-class|--filter-namespace|--treenode-filter)$/
246
+ }
247
+ # Only inert type/namespace data can release credential vocabulary; literal secret filenames stay protected.
248
+ function inert_test_filter(w, m) {
249
+ return w != "" && length(w) == length(m) && w !~ /^[-.~@]/ &&
250
+ w !~ /[\/\\$`<>;|&[:cntrl:]]/ && !expands(w, m) && sensitive_path(w) == ""
251
+ }
252
+ # dotnet's own arguments can change what runs (-p:RunCommand=..., --launch-profile, adapter paths), so before `--`
253
+ # only the project, build switches and filters are accepted; everything after `--` goes to the test application.
254
+ # The command must be fully literal: an expansion or response file could supply any of those arguments.
255
+ function plain_dotnet_args(A, M, n, k, w) {
256
+ for (k = 1; k <= n; k++) if (expands(A[k], M[k]) || length(A[k]) != length(M[k])) return 0
257
+ for (k = 3; k <= n && A[k] != "--"; k++) {
258
+ w = A[k]
259
+ if (test_filter_option(w) || w ~ /^(--project|-c|--configuration|-f|--framework|-v|--verbosity)$/) {
260
+ if (++k <= n && A[k] ~ /^[-@]/) return 0
261
+ continue
262
+ }
263
+ if (w ~ /^--(no-build|no-restore|nologo|no-launch-profile)$/) continue
264
+ if (w ~ /^--(project|configuration|framework|verbosity)=[^-@]/) continue
265
+ if (w ~ /^--[^=]+=/ && test_filter_option(substr(w, 1, index(w, "=") - 1))) continue
266
+ if (k == 3 && w !~ /^[-\/@+]/ && w !~ /[=:]/) continue
267
+ return 0
268
+ }
269
+ return 1
270
+ }
271
+ function credential_filter_slots(A, M, n, k, w, eq) {
272
+ delete CF
273
+ # Compound commands keep the existing fail-closed credential verdict across command separators.
274
+ if (filter_compound) return
275
+ # Only the .NET test runner takes filter data; a reader's operand that looks like an option stays a path.
276
+ if (tolower(base(A[1])) != "dotnet" || A[2] !~ /^(test|run)$/ || !plain_dotnet_args(A, M, n)) return
277
+ # Start after the subcommand, and consume exactly one value even when it is another option or is unsafe.
278
+ for (k = 3; k <= n; k++) {
279
+ w = A[k]
280
+ if (test_filter_option(w)) {
281
+ k++
282
+ if (k <= n && inert_test_filter(A[k], M[k])) CF[k] = 1
283
+ } else if (w ~ /^--[^=]+=/ && test_filter_option(substr(w, 1, index(w, "=") - 1))) {
284
+ eq = index(w, "=")
285
+ if (inert_test_filter(substr(w, eq + 1), substr(M[k], eq + 1))) CF[k] = 1
286
+ }
287
+ }
244
288
  }
245
- function stem_scan(text, mode, nonliteral, test_filter, t, k, stem, pos, offset, first, found, end, p, candidate) {
289
+ function stem_scan(text, mode, nonliteral, test_filter, credential_filter, t, k, stem, pos, offset, first, found, end, p, candidate) {
246
290
  t = tolower(text)
247
291
  for (k = 1; k <= nstem; k++) {
292
+ if (credential_filter && STEM[k] ~ /^credentials?$/) continue
248
293
  stem = STEM[k]; offset = 0
249
294
  while ((pos = index(substr(t, offset + 1), stem)) > 0) {
250
295
  pos += offset; end = pos + length(stem) - 1
@@ -261,6 +306,7 @@ function stem_scan(text, mode, nonliteral, test_filter, t, k, stem, pos, offs
261
306
  candidate = substr(t, p, 1)
262
307
  for (k = 1; k <= nstem; k++) {
263
308
  stem = STEM[k]
309
+ if (credential_filter && stem ~ /^credentials?$/) continue
264
310
  if (candidate != substr(stem, 1, 1) && candidate !~ /[*?[(@+!~^]/) continue
265
311
  # Test-filter values are data; other programs can match globs across path separators.
266
312
  if (stem == "run/secrets" && test_filter && nonliteral != "expanding" && !index(t, "/")) continue
@@ -667,6 +713,7 @@ function end_cmd( k, m, w, j, hit, exempt, path_git, paths_only, test_filter)
667
713
  for (k = 1; k <= nw; k++) PROBE_WORDS[k] = W[k]
668
714
  paths_only = nonreader(W, WM, nw)
669
715
  regex_slots(W, 1, nw)
716
+ credential_filter_slots(W, WM, nw)
670
717
  path_git = git_paths(W, WM, nw)
671
718
  msg_shape = data_shape(W, WM, nw)
672
719
  for (k = 1; k <= nw; k++) {
@@ -678,7 +725,7 @@ function end_cmd( k, m, w, j, hit, exempt, path_git, paths_only, test_filter)
678
725
  if (exempt && RP[k] < 0) continue
679
726
  w = exempt ? substr(W[k], 1, RP[k]) : W[k]
680
727
  test_filter = test_filter_option(W[k - 1]) || (w ~ /^--[^=]+=/ && test_filter_option(substr(w, 1, index(w, "=") - 1)))
681
- hit = stem_scan(w, "raw", expands(w, WM[k]) ? "expanding" : 0, test_filter); if (TAINT == "") TAINT = hit
728
+ hit = stem_scan(w, "raw", expands(w, WM[k]) ? "expanding" : 0, test_filter, (k in CF)); if (TAINT == "") TAINT = hit
682
729
  # Command output may supply any text, including several names: judge it as an unresolved wildcard.
683
730
  if (!exempt && index(WM[k], "c") + index(WM[k], "C") > 0) {
684
731
  hit = stem_scan(output_wild(W[k], WM[k]), "raw", "expanding"); if (TAINT == "") TAINT = hit
@@ -791,7 +838,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
791
838
  delete CWD; ncd = QUEUE_COUNT[qi]
792
839
  for (i = 1; i <= ncd; i++) CWD[i] = QUEUE_DIR[qi, i]
793
840
  effective_dir = CWD[1]; cwd_depth = 0; cwd_conditional = 0; nwrap = 0
794
- clear_pipeline(); pipe_input = 0
841
+ clear_pipeline(); pipe_input = 0; filter_compound = 0
795
842
  n = length(s); i = 1; nw = 0; word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; wunquoted = 0; nheredoc = 0; hd_shell = 0; hd_interp = 0; quote_boundary = 0
796
843
  delete W; delete WP; delete WM
797
844
  while (i <= n) {
@@ -804,17 +851,17 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
804
851
  if (c == "\047") {
805
852
  wquoted = 1; inword = 1; quote_boundary = 1
806
853
  j = index(substr(s, i + 1), "\047")
807
- if (j == 0) { addw(substr(s, i + 1), "l"); i = n + 1; continue }
854
+ if (j == 0) { addw(substr(s, i + 1), "l"); filter_compound = 1; i = n + 1; continue }
808
855
  addw(substr(s, i + 1, j - 1), "l"); quote_boundary = 1; i += j + 1; continue
809
856
  }
810
857
  if (c == "$" && substr(s, i + 1, 1) == "\047") { wquoted = 1; inword = 1; quote_boundary = 1; i = ansi_c(s, i + 2, n); quote_boundary = 1; continue }
811
858
  if (c == "$" && substr(s, i + 1, 1) == "\"") { i++; c = "\"" }
812
859
  if (c == "\"") {
813
- wquoted = 1; inword = 1; quote_boundary = 1; i++
860
+ wquoted = 1; inword = 1; quote_boundary = 1; i++; dq_closed = 0
814
861
  while (i <= n) {
815
862
  c = substr(s, i, 1)
816
863
  if (c == "\\") { addw(substr(s, i + 1, 1), "l"); i += 2; continue }
817
- if (c == "\"") { quote_boundary = 1; i++; break }
864
+ if (c == "\"") { quote_boundary = 1; dq_closed = 1; i++; break }
818
865
  if (c == "$" && substr(s, i + 1, 1) == "(") { i = cmdsub(s, i + 2, n); addw("x", "c"); continue }
819
866
  if (c == "`") {
820
867
  complex = 1
@@ -824,6 +871,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
824
871
  }
825
872
  addw(c, "d"); i++
826
873
  }
874
+ if (!dq_closed) filter_compound = 1
827
875
  continue
828
876
  }
829
877
  if (c == "$" && substr(s, i + 1, 1) == "(") { wquoted = 1; inword = 1; wunquoted = 1; i = cmdsub(s, i + 2, n); addw("x", "c"); continue }
@@ -841,6 +889,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
841
889
  }
842
890
  if (c == " " || c == "\t" || c == "\r") { flush_word(); i++; continue }
843
891
  if (c == "\n") {
892
+ filter_compound = 1
844
893
  end_cmd(); clear_pipeline(); pipe_input = 0; cwd_conditional = 0; i++
845
894
  if (nheredoc > 0) i = read_heredocs(s, i, n)
846
895
  continue
@@ -852,6 +901,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
852
901
  inword = 1; addw(substr(s, i, j - i + 1), "u"); i = j + 1; continue
853
902
  }
854
903
  if (c == ";" || c == "&" || c == "|" || c == "(" || c == ")") {
904
+ filter_compound = 1
855
905
  end_cmd()
856
906
  c2 = substr(s, i + 1, 1)
857
907
  if (c == "(") push_cwd_scope()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.170.9",
3
+ "version": "7.170.10",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [