@cratis/pi 7.131.5 → 7.131.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.
@@ -48,7 +48,7 @@ probe_lower="$(printf '%s' "$probe" | tr '[:upper:]' '[:lower:]')" || parser_fai
48
48
  case "$probe_lower" in
49
49
  *kubectl*|*printenv*|*env*|*docker*|*podman*|*"gh "*|*vault*|*pulumi*|*show-secret*|*aws*|*"az "*|*gcloud*|*kubeconfig*|*.kube*|\
50
50
  *sh*|*extglob*|*set*|*emulate*|*'-o'*|*'+o'*|*globignore*|*export*|*declare*|*id_rsa*|*id_ed25519*|*id_ecdsa*|*id_dsa*|*.pem*|*.p12*|*.pfx*|*token*|*.netrc*|*.npmrc*|\
51
- *credentials*|*.pgpass*|*pypirc*|*secrets*) ;;
51
+ *credentials*|*.pgpass*|*pypirc*|*secrets*|*oc*) ;;
52
52
  *)
53
53
  case "$command_text" in
54
54
  *'$'*|*'*'*|*'?'*|*'['*|*'{'*|*'('*|*'^'*|*'~'*|*'`'*) ;;
@@ -462,7 +462,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
462
462
  # ── option parsing shared by the CLIs: positionals P/PI, output format, -f/--format value, --raw ──
463
463
  function kparse(A, s, n, shortvals, i, w, eq, key, val, f, rest) {
464
464
  delete P; delete PI
465
- np = 0; outfmt = ""; fmtval = ""; tmpl = ""; dd = 0; raw = 0
465
+ np = 0; outfmt = ""; fmtval = ""; tmpl = ""; tmplfile = 0; dd = 0; raw = 0
466
466
  for (i = s; i <= n; i++) {
467
467
  w = A[i]
468
468
  if (w == "--") { dd = i; break }
@@ -471,7 +471,11 @@ function kparse(A, s, n, shortvals, i, w, eq, key, val, f, rest) {
471
471
  if (eq) { key = substr(w, 1, eq - 1); val = substr(w, eq + 1) }
472
472
  if (key == "--output") { if (!eq) { i++; val = A[i] } outfmt = tolower(val) }
473
473
  else if (key == "--format") { if (!eq) { i++; val = A[i] } fmtval = val }
474
- else if (key == "--template") { if (!eq) { i++; val = A[i] } tmpl = val }
474
+ else if (key == "--template") {
475
+ if (!eq) { i++; val = A[i] } tmpl = val
476
+ if (val ~ /^[[:space:]]*@/ || val !~ /[{]/) tmplfile = 1
477
+ }
478
+ else if (key == "--template-file") { if (!eq) i++; tmplfile = 1 }
475
479
  else if (key == "--raw") raw = 1
476
480
  else if (!eq && (key in LV)) i++
477
481
  continue
@@ -490,10 +494,60 @@ function kparse(A, s, n, shortvals, i, w, eq, key, val, f, rest) {
490
494
  np++; P[np] = w; PI[np] = i
491
495
  }
492
496
  }
493
- # `-o jsonpath={.}` and `-o go-template={{.}}` print the whole object, exactly like -o json.
494
- function proj_leaks(t) {
495
- t = tolower(t); gsub(/[ \t]/, "", t)
496
- return t ~ /[{](\.|@|\.items|\.items\[\*\])[}]/
497
+ # Projection paths pass only through these explicit field shapes.
498
+ function proj_path_allowed(t, inrange) {
499
+ if (!inrange) sub(/^\.items\[(\*|[0-9]+)\]/, "", t)
500
+ if (t ~ /^\.(kind|apiversion)$/) return 1
501
+ if (t ~ /^\.metadata\.(name|namespace|uid|creationtimestamp|resourceversion|generation|deletiontimestamp)$/) return 1
502
+ if (t ~ /^\.metadata\.labels(\.[a-z0-9_-]+)?$/) return 1
503
+ if (t ~ /^\.metadata\.ownerreferences\[(\*|[0-9]+)\]\.(name|kind|uid)$/) return 1
504
+ if (t ~ /^\.status(\.[a-z0-9_-]+|\[(\*|[0-9]+)\])*$/) return 1
505
+ if (t ~ /^\.spec(\.template\.spec)?\.(containers|initcontainers|ephemeralcontainers)\[(\*|[0-9]+)\]\.(name|image|imagepullpolicy)$/) return 1
506
+ return t ~ /^\.spec\.(nodename|replicas|serviceaccountname|schedulername|restartpolicy|type|clusterip)$/
507
+ }
508
+ function proj_columns_allowed(t, columns, n, k, p, colon) {
509
+ n = split(tolower(t), columns, ","); if (!n) return 0
510
+ for (k = 1; k <= n; k++) {
511
+ p = columns[k]; gsub(/[[:space:]]/, "", p)
512
+ colon = index(p, ":"); if (colon <= 1) return 0
513
+ p = substr(p, colon + 1)
514
+ if (p !~ /^\./) p = "." p
515
+ if (!proj_path_allowed(p, 0)) return 0
516
+ }
517
+ return 1
518
+ }
519
+ function proj_jsonpath_allowed(t, i, c, segment, active, quote, escaped, literal, depth) {
520
+ t = tolower(t)
521
+ for (i = 1; i <= length(t); i++) {
522
+ c = substr(t, i, 1)
523
+ if (!active) {
524
+ if (c == "}") return 0
525
+ if (c == "{") { active = 1; segment = ""; literal = 0 }
526
+ continue
527
+ }
528
+ if (c == "{") return 0
529
+ if (c == "}") {
530
+ if (quote != "") return 0
531
+ if (!literal) {
532
+ if (segment == "range.items[*]") depth++
533
+ else if (segment == "end") { if (!depth) return 0; depth-- }
534
+ else if (!proj_path_allowed(segment, depth > 0)) return 0
535
+ }
536
+ active = 0; continue
537
+ }
538
+ if (quote != "") {
539
+ if (escaped) escaped = 0
540
+ else if (c == "\\") escaped = 1
541
+ else if (c == quote) { quote = ""; literal = 1 }
542
+ } else if (c !~ /[[:space:]]/) {
543
+ if (literal) return 0
544
+ if (c == "\"" || c == SQ) {
545
+ if (segment != "") return 0
546
+ quote = c
547
+ } else segment = segment c
548
+ }
549
+ }
550
+ return !active && !depth
497
551
  }
498
552
  function skipopts(A, s, n, vals) {
499
553
  while (s <= n && substr(A[s], 1, 1) == "-") {
@@ -920,8 +974,9 @@ function dyn_command(A, s, n, j, na, b, d, S, unresolved, rx) {
920
974
  }
921
975
 
922
976
  # ── tools ──
923
- function kube(A, s, n, verb, m, parts, k, r, rlist) {
977
+ function kube(A, s, n, verb, m, parts, k, r, rlist, projection) {
924
978
  kparse(A, s + 1, n, "nlcsfkLR")
979
+ projection = index(outfmt, "=") ? substr(outfmt, index(outfmt, "=") + 1) : ""
925
980
  verb = P[1]
926
981
  if (verb == "exec") {
927
982
  if (dd) analyze(A, dd + 1, n)
@@ -946,10 +1001,14 @@ function kube(A, s, n, verb, m, parts, k, r, rlist) {
946
1001
  } else if (r in SENS) {
947
1002
  if (verb == "describe")
948
1003
  report("kubectl describe " r " prints the full container spec, including inline credentials", "kubectl get " r " -o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, or kubectl get events / kubectl logs; say which field you need")
949
- else if (outfmt == "json" || outfmt == "yaml")
1004
+ else if (outfmt != "" && outfmt !~ /^(wide|name|jsonpath|jsonpath-as-json|custom-columns|go-template|template|templatefile|go-template-file|jsonpath-file|custom-columns-file)(=|$)/)
950
1005
  report("kubectl get " r " -o " outfmt " prints the full container spec, including inline credentials", "-o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, -o wide, or the status fields you need")
951
- else if ((outfmt ~ /^(jsonpath|go-template|jsonpath-as-json)=/ || tmpl != "") && proj_leaks(tmpl outfmt))
952
- report("kubectl get " r " with a projection that selects the whole object prints the full container spec, including inline credentials", "-o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, -o wide, or the status fields you need")
1006
+ else if (tmplfile || outfmt ~ /^(templatefile|go-template-file|jsonpath-file|custom-columns-file)(=|$)/)
1007
+ report("kubectl get " r " with a file-based projection may print the full container spec, including inline credentials", "use an inline projection of the needed fields: -o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, -o wide, or the status fields you need")
1008
+ else if (outfmt ~ /^(go-template|template)(=|$)/ || (tmpl != "" && outfmt !~ /^(jsonpath|jsonpath-as-json)(=|$)/))
1009
+ report("kubectl get " r " with a projection that selects the container spec prints the full container spec, including inline credentials", "-o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, -o wide, or the status fields you need")
1010
+ else if ((outfmt ~ /^(jsonpath|jsonpath-as-json)(=|$)/ && (!proj_jsonpath_allowed(projection) || !proj_jsonpath_allowed(tmpl))) || (outfmt ~ /^custom-columns(=|$)/ && !proj_columns_allowed(projection)))
1011
+ report("kubectl get " r " with a projection that selects the container spec prints the full container spec, including inline credentials", "-o jsonpath=" SQ "{.items[*].spec.containers[*].image}" SQ ", -o custom-columns=NAME:.metadata.name,STATUS:.status.phase, -o name, -o wide, or the status fields you need")
953
1012
  }
954
1013
  }
955
1014
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.131.5",
3
+ "version": "7.131.6",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [