@codyswann/lisa 8.7.0 → 8.7.1

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.
Files changed (162) hide show
  1. package/README.md +9 -0
  2. package/all/copy-overwrite/scripts/lib/changed-paths.mjs +146 -0
  3. package/all/copy-overwrite/scripts/lib/completion-proof-content.mjs +6 -2
  4. package/all/copy-overwrite/scripts/lisa-gates.mjs +16 -1
  5. package/all/copy-overwrite/scripts/lisa-hooks/block-direct-issue-create.sh +297 -177
  6. package/all/copy-overwrite/scripts/lisa-run-gates.mjs +24 -0
  7. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +7 -6
  8. package/all/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
  9. package/dist/cli/apply-cmd.d.ts +10 -0
  10. package/dist/cli/apply-cmd.d.ts.map +1 -0
  11. package/dist/cli/apply-cmd.js +28 -0
  12. package/dist/cli/apply-cmd.js.map +1 -0
  13. package/dist/cli/index.d.ts.map +1 -1
  14. package/dist/cli/index.js +3 -12
  15. package/dist/cli/index.js.map +1 -1
  16. package/dist/core/lisa-owned-hash-ledger.json +56 -4
  17. package/dist/core/nightly-e2e-guard-behavior-certificate.d.ts +5 -5
  18. package/dist/core/nightly-e2e-guard-behavior-certificate.js +7 -7
  19. package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
  20. package/dist/core/upstream-evidence-manifest.json +65 -24
  21. package/expo/copy-overwrite/scripts/check-bdd-coverage.mjs +4 -1
  22. package/expo/create-only/tsconfig.local.json +6 -1
  23. package/package.json +4 -4
  24. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  26. package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +43 -18
  27. package/plugins/lisa/.codex-plugin/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  28. package/plugins/lisa/.codex-plugin/skills/lisa-linear-write-issue/SKILL.md +6 -1
  29. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +9 -2
  30. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  31. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  32. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  33. package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  34. package/plugins/lisa/hooks/block-direct-issue-create.sh +297 -177
  35. package/plugins/lisa/hooks/threshold-ratchet-compare.mjs +18 -12
  36. package/plugins/lisa/rules/reference/config-resolution.md +2 -2
  37. package/plugins/lisa/scripts/ready-queue-order.mjs +43 -18
  38. package/plugins/lisa/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  39. package/plugins/lisa/skills/lisa-linear-write-issue/SKILL.md +6 -1
  40. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +9 -2
  41. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  42. package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  43. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  44. package/plugins/lisa/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  45. package/plugins/lisa-agy/hooks/block-direct-issue-create.sh +297 -177
  46. package/plugins/lisa-agy/plugin.json +1 -1
  47. package/plugins/lisa-agy/scripts/ready-queue-order.mjs +43 -18
  48. package/plugins/lisa-agy/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  49. package/plugins/lisa-agy/skills/lisa-linear-write-issue/SKILL.md +6 -1
  50. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +9 -2
  51. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  52. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  53. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  54. package/plugins/lisa-agy/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  55. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  57. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  58. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  62. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-copilot/hooks/block-direct-issue-create.sh +297 -177
  64. package/plugins/lisa-copilot/hooks/threshold-ratchet-compare.mjs +18 -12
  65. package/plugins/lisa-copilot/rules/reference/config-resolution.md +2 -2
  66. package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +43 -18
  67. package/plugins/lisa-copilot/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  68. package/plugins/lisa-copilot/skills/lisa-linear-write-issue/SKILL.md +6 -1
  69. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +9 -2
  70. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  71. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  72. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  73. package/plugins/lisa-copilot/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  74. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-cursor/hooks/block-direct-issue-create.sh +297 -177
  76. package/plugins/lisa-cursor/hooks/threshold-ratchet-compare.mjs +18 -12
  77. package/plugins/lisa-cursor/rules/config-resolution-reference.mdc +2 -2
  78. package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +43 -18
  79. package/plugins/lisa-cursor/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  80. package/plugins/lisa-cursor/skills/lisa-linear-write-issue/SKILL.md +6 -1
  81. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +9 -2
  82. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  83. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  84. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  85. package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  86. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  88. package/plugins/lisa-devin/hooks/block-direct-issue-create.sh +297 -177
  89. package/plugins/lisa-devin/hooks/threshold-ratchet-compare.mjs +18 -12
  90. package/plugins/lisa-devin/rules/reference/config-resolution.md +2 -2
  91. package/plugins/lisa-devin/scripts/ready-queue-order.mjs +43 -18
  92. package/plugins/lisa-devin/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  93. package/plugins/lisa-devin/skills/lisa-linear-write-issue/SKILL.md +6 -1
  94. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +9 -2
  95. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  96. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  97. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  98. package/plugins/lisa-devin/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  99. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  101. package/plugins/lisa-expo-agy/plugin.json +1 -1
  102. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  103. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  104. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  106. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  107. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  108. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  109. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  111. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  113. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  114. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  115. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  116. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  118. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  119. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  120. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  121. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  122. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  123. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  124. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  125. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  127. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  128. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  129. package/plugins/lisa-rails-agy/plugin.json +1 -1
  130. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  131. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  132. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  134. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  135. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  136. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  137. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  138. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  139. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  140. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  141. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  142. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  143. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  144. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  145. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  146. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  147. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  148. package/plugins/src/base/hooks/block-direct-issue-create.sh +297 -177
  149. package/plugins/src/base/hooks/threshold-ratchet-compare.mjs +18 -12
  150. package/plugins/src/base/rules/reference/config-resolution.md +2 -2
  151. package/plugins/src/base/scripts/ready-queue-order.mjs +43 -18
  152. package/plugins/src/base/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
  153. package/plugins/src/base/skills/lisa-linear-write-issue/SKILL.md +6 -1
  154. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +9 -2
  155. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
  156. package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
  157. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
  158. package/plugins/src/base/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
  159. package/rails/copy-overwrite/scripts/check-nightly-e2e-health.mjs +28 -2
  160. package/rails/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
  161. package/typescript/copy-overwrite/scripts/check-nightly-e2e-health.mjs +28 -2
  162. package/typescript/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
@@ -240,11 +240,17 @@ if [ "$tool_name" != "Bash" ]; then
240
240
  fi
241
241
 
242
242
  command_str=""
243
+ tool_cwd=""
243
244
  if [ -z "$structured_call" ]; then
244
245
  command_str="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null || true)"
245
246
  if [ -z "$command_str" ]; then
246
247
  exit 0
247
248
  fi
249
+ tool_cwd="$(printf '%s' "$input" | jq -r '
250
+ [.tool_input.workdir, .tool_input.cwd, .cwd]
251
+ | map(select(type == "string" and length > 0))
252
+ | .[0] // empty
253
+ ' 2>/dev/null || true)"
248
254
  fi
249
255
 
250
256
  project_dir="${CLAUDE_PROJECT_DIR:-}"
@@ -434,16 +440,29 @@ EOF
434
440
  esac
435
441
  }
436
442
 
443
+ refusal_detail() {
444
+ if [ -n "${1:-}" ]; then
445
+ printf 'The body file %s could not be read, so its declaration was not seen. Name it by an absolute path.\n' "$1"
446
+ else
447
+ printf '%s\n' 'this filing declares no readiness.'
448
+ fi
449
+ }
450
+
437
451
  refuse() {
438
452
  local signature="$1"
439
453
  local roles="$2"
440
454
  local target="$3"
441
455
  local remedy="${4:-}"
456
+ local body_file="${5:-}"
457
+ if [ "$remedy" = "unresolved-script" ]; then
458
+ printf '%s\n' 'BLOCKED: Lisa could not determine the working directory of a script this command runs. Use an absolute script path or a literal directory change joined with &&.' >&2
459
+ exit 2
460
+ fi
442
461
  if [ -n "$target" ]; then
443
- refuse_cross_repo "$signature" "$roles" "$target"
462
+ refuse_cross_repo "$signature" "$roles" "$target" "$body_file"
444
463
  fi
445
464
  cat >&2 <<EOF
446
- BLOCKED: refusing \`$signature\` — this filing declares no readiness.
465
+ BLOCKED: refusing \`$signature\` — $(refusal_detail "$body_file")
447
466
 
448
467
  WHY: a work item filed without the build-ready role is an incomplete handoff.
449
468
  Build-intake scans the ready lane and nothing else, so nothing will ever pick
@@ -538,8 +557,9 @@ refuse_cross_repo() {
538
557
  local signature="$1"
539
558
  local roles="$2"
540
559
  local target="$3"
560
+ local body_file="${4:-}"
541
561
  cat >&2 <<EOF
542
- BLOCKED: refusing \`$signature\` — this filing declares no readiness.
562
+ BLOCKED: refusing \`$signature\` — $(refusal_detail "$body_file")
543
563
 
544
564
  WHY: a work item filed without the build-ready role is an incomplete handoff.
545
565
  Build-intake scans the ready lane and nothing else, so nothing will ever pick
@@ -593,6 +613,7 @@ EOF
593
613
  # exit as a non-blocking hook error, so the command runs unchecked.
594
614
  classifier=""
595
615
  read -r -d '' classifier <<'PY' || true
616
+ import json
596
617
  import os
597
618
  import re
598
619
  import shlex
@@ -608,6 +629,7 @@ upstream_ready_role = os.environ.get("LISA_GUARD_UPSTREAM_READY_ROLE", "")
608
629
  caller_is_github = os.environ.get("LISA_GUARD_CALLER_IS_GITHUB", "") == "1"
609
630
  tracker = os.environ.get("LISA_GUARD_TRACKER", "").strip().lower()
610
631
  project_dir = os.environ.get("LISA_GUARD_PROJECT_DIR", "")
632
+ tool_cwd = os.path.join(project_dir, os.environ.get("LISA_GUARD_TOOL_CWD", ""))
611
633
 
612
634
  OVERRIDE_NAME = "LISA_ALLOW_DIRECT_ISSUE_CREATE"
613
635
  HUMAN_GATE_MARKER = "[lisa-human-gate]"
@@ -741,7 +763,17 @@ UNPARSEABLE_CREATION = re.compile(
741
763
  re.IGNORECASE,
742
764
  )
743
765
 
744
- BODY_FILE_FLAGS = {"--body-file", "-F", "--input", "--data-binary"}
766
+ BODY_FILE_FLAGS = {"--body-file"}
767
+ GITHUB_ISSUE_VALUE_FLAGS = {
768
+ "--assignee", "--blocked-by", "--blocking", "--body", "--body-file",
769
+ "--label", "--milestone", "--parent", "--project", "--recover", "--repo",
770
+ "--template", "--title", "--type",
771
+ }
772
+ GITHUB_ISSUE_SHORT_VALUES = {
773
+ "a": "--assignee", "b": "--body", "F": "--body-file", "l": "--label",
774
+ "m": "--milestone", "p": "--project", "R": "--repo", "T": "--template",
775
+ "t": "--title",
776
+ }
745
777
  LABEL_FLAGS = {"--label", "--labels", "--add-label", "--status", "--state"}
746
778
 
747
779
  # ---------------------------------------------------------------------------
@@ -883,7 +915,6 @@ GRAPHQL_CREATE = re.compile(r"createIssue|issueCreate")
883
915
  # documented direction of failure: an operator who hits a false refusal says
884
916
  # so, an agent who hits a false allow says nothing.
885
917
  FILE_OPERAND_MAX_BYTES = 262144
886
- FILE_OPERANDS_PER_SEGMENT = 8
887
918
  # Payload sources. A creation's mutation text may arrive inline, from a file,
888
919
  # or over stdin from an earlier stage of the same pipeline.
889
920
  PAYLOAD_SOURCE_FLAGS = {
@@ -1144,25 +1175,55 @@ def explode_operators(tokens, text=""):
1144
1175
  return exploded
1145
1176
 
1146
1177
 
1147
- def segment(tokens):
1148
- """Split a token stream into individual commands at shell operators.
1149
-
1150
- Args:
1151
- tokens: Exploded tokens.
1152
-
1153
- Returns:
1154
- A list of argv lists.
1155
- """
1156
- segments = []
1178
+ def connected_segments(tokens):
1179
+ """Yield each argv with the unquoted shell operator that follows it."""
1157
1180
  current = []
1158
1181
  for token in tokens:
1159
1182
  if token in SEGMENT_BOUNDARIES and not isinstance(token, LiteralToken):
1160
- segments.append(current)
1183
+ yield current, token
1161
1184
  current = []
1162
- continue
1163
- current.append(token)
1164
- segments.append(current)
1165
- return [item for item in segments if item]
1185
+ else:
1186
+ current.append(token)
1187
+ if current:
1188
+ yield current, ""
1189
+
1190
+
1191
+ def directory_after_cd(argv, cwd):
1192
+ """Resolve a single literal cd operand without evaluating shell syntax."""
1193
+ args = argv[1:]
1194
+ physical = args[:1] == ["-P"]
1195
+ if physical or args[:1] == ["-L"]:
1196
+ args = args[1:]
1197
+ if args[:1] == ["--"]:
1198
+ args = args[1:]
1199
+ if len(args) != 1:
1200
+ return None
1201
+ target = args[0]
1202
+ if not target or target.startswith("-") or re.search(r"[\x24\x60~*?\[\]{}\n\r]", target):
1203
+ return None
1204
+ target = absolute_operand(target, cwd)
1205
+ if target is None:
1206
+ return None
1207
+ return os.path.realpath(target) if physical else os.path.normpath(target)
1208
+
1209
+
1210
+ def segments_with_directory(tokens, cwd):
1211
+ """Follow literal directory changes while success is required by &&."""
1212
+ preceding = ""
1213
+ changed = False
1214
+ for argv, following in connected_segments(tokens):
1215
+ if argv and argv[0] == "cd":
1216
+ cwd = (
1217
+ directory_after_cd(argv, cwd)
1218
+ if following == "&&" and preceding in {"", "&&", ";", "(", "{"}
1219
+ else None
1220
+ )
1221
+ changed = True
1222
+ elif argv:
1223
+ yield argv, cwd
1224
+ if changed and following not in {"", "&&"}:
1225
+ cwd = None
1226
+ preceding = following
1166
1227
 
1167
1228
 
1168
1229
  def basename(token):
@@ -1332,7 +1393,14 @@ def endpoint_paths(args, pattern):
1332
1393
  return found
1333
1394
 
1334
1395
 
1335
- def resolve_operand(token):
1396
+ def absolute_operand(path, cwd):
1397
+ """A literal absolute operand or a path relative to a known directory."""
1398
+ if os.path.isabs(path):
1399
+ return path
1400
+ return os.path.join(cwd, path) if cwd else None
1401
+
1402
+
1403
+ def resolve_operand(token, cwd):
1336
1404
  """A readable regular file named by one token, or None.
1337
1405
 
1338
1406
  Bounded on purpose. The size cap keeps a PreToolUse hook off a multi-
@@ -1341,32 +1409,20 @@ def resolve_operand(token):
1341
1409
  confident ALLOW about text it never saw.
1342
1410
 
1343
1411
  Args:
1344
- token: One argument, possibly quoted or `@`-prefixed for curl.
1412
+ token: One decoded path argument.
1413
+ cwd: The working directory, or None when it cannot be determined.
1345
1414
 
1346
1415
  Returns:
1347
1416
  An existing path, or None.
1348
1417
  """
1349
- text = token.strip().strip("'\"")
1350
- # `-d@payload.json` names a file just as plainly as `@payload.json` does.
1351
- attached = attached_value(text)
1352
- if attached is not None:
1353
- text = attached
1354
- if text.startswith("@"):
1355
- text = text[1:]
1356
- if not text or text in STDIN_PAYLOAD_TOKENS:
1418
+ if not token or token in STDIN_PAYLOAD_TOKENS:
1357
1419
  return None
1358
- candidates = [text]
1359
- if project_dir and not os.path.isabs(text):
1360
- candidates.append(os.path.join(project_dir, text))
1361
- for candidate in candidates:
1362
- try:
1363
- if not os.path.isfile(candidate):
1364
- continue
1365
- if os.path.getsize(candidate) > FILE_OPERAND_MAX_BYTES:
1366
- continue
1367
- except OSError:
1368
- continue
1369
- return candidate
1420
+ candidate = absolute_operand(token, cwd)
1421
+ try:
1422
+ if candidate and os.path.isfile(candidate) and os.path.getsize(candidate) <= FILE_OPERAND_MAX_BYTES:
1423
+ return candidate
1424
+ except (OSError, ValueError):
1425
+ pass
1370
1426
  return None
1371
1427
 
1372
1428
 
@@ -1377,17 +1433,17 @@ def read_operand(path):
1377
1433
  path: A path from `resolve_operand`.
1378
1434
 
1379
1435
  Returns:
1380
- The contents, or an empty string when unreadable.
1436
+ The contents, or None when unreadable.
1381
1437
  """
1382
1438
  try:
1383
1439
  with open(path, encoding="utf-8", errors="replace") as handle:
1384
1440
  return handle.read(FILE_OPERAND_MAX_BYTES)
1385
- except OSError:
1386
- return ""
1441
+ except (OSError, TypeError):
1442
+ return None
1387
1443
 
1388
1444
 
1389
- def attached_value(token):
1390
- """A payload flag's value when it is GLUED to the flag.
1445
+ def attached_payload(token):
1446
+ """A payload flag and its value when it is GLUED to the flag.
1391
1447
 
1392
1448
  `curl -d@payload.json` and `curl -d'{"query":…}'` are one token each, so a
1393
1449
  parser that only looks at `args[i + 1]` and at `flag=value` sees neither —
@@ -1403,7 +1459,7 @@ def attached_value(token):
1403
1459
  token: One argument.
1404
1460
 
1405
1461
  Returns:
1406
- The attached value, or None.
1462
+ The flag and its attached value, or a pair of None values.
1407
1463
  """
1408
1464
  for flag in sorted(PAYLOAD_SOURCE_FLAGS, key=len, reverse=True):
1409
1465
  if not token.startswith(flag) or len(token) == len(flag):
@@ -1413,11 +1469,11 @@ def attached_value(token):
1413
1469
  rest = rest[1:]
1414
1470
  if not rest or rest.startswith("-"):
1415
1471
  continue
1416
- return rest
1417
- return None
1472
+ return flag, rest
1473
+ return None, None
1418
1474
 
1419
1475
 
1420
- def payload_text(args, whole_command):
1476
+ def payload_text(args, whole_command, cwd):
1421
1477
  """The body this command will submit, wherever it is coming from.
1422
1478
 
1423
1479
  Three sources, because a request body has three places to live and the
@@ -1427,39 +1483,45 @@ def payload_text(args, whole_command):
1427
1483
 
1428
1484
  The stdin case takes the WHOLE command text rather than the segment,
1429
1485
  because `jq -n … | curl … --data-binary @-` is one logical command that
1430
- `segment` has already split in two — the payload literally is the other
1486
+ the scanner has already split in two — the payload literally is the other
1431
1487
  half. That is the shape `lisa-linear-access` mandates, so it has to be
1432
1488
  readable rather than invisible.
1433
1489
 
1434
1490
  Args:
1435
1491
  args: A command's arguments.
1436
1492
  whole_command: The full intercepted command string.
1493
+ cwd: The working directory, or None when it cannot be determined.
1437
1494
 
1438
1495
  Returns:
1439
- The payload text, possibly empty.
1496
+ The payload text and paths of unreadable payload files.
1440
1497
  """
1441
1498
  parts = []
1499
+ unreadable = []
1500
+ args = before_end_of_options(args)
1442
1501
  for index, token in enumerate(args):
1443
- value = None
1444
1502
  if token in PAYLOAD_SOURCE_FLAGS and index + 1 < len(args):
1503
+ flag = token
1445
1504
  value = args[index + 1]
1446
- elif "=" in token:
1447
- head, rhs = token.split("=", 1)
1448
- if head in PAYLOAD_SOURCE_FLAGS:
1449
- value = rhs
1450
- if value is None:
1451
- value = attached_value(token)
1505
+ else:
1506
+ flag, value = attached_payload(token)
1452
1507
  if value is None:
1453
1508
  continue
1454
- stripped = value.strip().strip("'\"")
1455
- if stripped in STDIN_PAYLOAD_TOKENS:
1509
+ if flag == "--data-raw" or not (
1510
+ value.startswith("@") or flag in {"--input", "--upload-file", "-T"}
1511
+ ):
1512
+ parts.append(value)
1513
+ continue
1514
+ if value in STDIN_PAYLOAD_TOKENS:
1456
1515
  parts.append(whole_command)
1457
1516
  continue
1458
- parts.append(stripped)
1459
- path = resolve_operand(stripped)
1460
- if path is not None:
1461
- parts.append(read_operand(path))
1462
- return "\n".join(parts)
1517
+ operand = value[1:] if value.startswith("@") else value
1518
+ path = resolve_operand(operand, cwd)
1519
+ contents = read_operand(path) if path else None
1520
+ if contents is None:
1521
+ unreadable.append(operand)
1522
+ else:
1523
+ parts.append(contents)
1524
+ return "\n".join(parts), unreadable
1463
1525
 
1464
1526
 
1465
1527
  def text_declares_readiness(text):
@@ -1527,13 +1589,14 @@ def scope_declaration(text, state_role_ok):
1527
1589
  return bool(state_role_ok and LIFECYCLE_ROLE_READY.search(text))
1528
1590
 
1529
1591
 
1530
- def creation_signature(name, args, extra=""):
1592
+ def creation_signature(name, args, extra="", unreadable_payload=False):
1531
1593
  """Classify a tracker CLI invocation as a creation.
1532
1594
 
1533
1595
  Args:
1534
1596
  name: The CLI basename.
1535
1597
  args: Every token after it in this segment.
1536
1598
  extra: Payload text this command submits, from a file or stdin.
1599
+ unreadable_payload: Whether a named request body could not be read.
1537
1600
 
1538
1601
  Returns:
1539
1602
  A short human-readable signature, or None.
@@ -1552,6 +1615,8 @@ def creation_signature(name, args, extra=""):
1552
1615
  if "api" in args:
1553
1616
  if GRAPHQL_CREATE.search(joined):
1554
1617
  return "gh api graphql issue creation"
1618
+ if unreadable_payload and "graphql" in args and is_write_request(args):
1619
+ return "gh api graphql with an unreadable request body"
1555
1620
  if endpoint_paths(args, GITHUB_ISSUES_PATH) and is_write_request(args):
1556
1621
  return "gh api POST .../issues"
1557
1622
  return None
@@ -1574,8 +1639,11 @@ def creation_signature(name, args, extra=""):
1574
1639
  return "%s POST api.github.com/…/issues" % name
1575
1640
  if JIRA_ISSUE_URL.search(token):
1576
1641
  return "%s POST …/rest/api/…/issue" % name
1577
- if "api.linear.app/graphql" in token and GRAPHQL_CREATE.search(joined):
1578
- return "%s POST api.linear.app/graphql issueCreate" % name
1642
+ if "api.linear.app/graphql" in token:
1643
+ if GRAPHQL_CREATE.search(joined):
1644
+ return "%s POST api.linear.app/graphql issueCreate" % name
1645
+ if unreadable_payload:
1646
+ return "%s POST api.linear.app/graphql with an unreadable request body" % name
1579
1647
  return None
1580
1648
 
1581
1649
  return None
@@ -1603,26 +1671,65 @@ def before_end_of_options(args):
1603
1671
  return args[: args.index("--")] if "--" in args else args
1604
1672
 
1605
1673
 
1606
- def body_file_paths(args):
1607
- """Paths the command will submit as the item body.
1608
-
1609
- Args:
1610
- args: A command's arguments.
1611
-
1612
- Returns:
1613
- Candidate file paths, unverified.
1614
- """
1615
- paths = []
1616
- for index, token in enumerate(args):
1617
- if token in BODY_FILE_FLAGS and index + 1 < len(args):
1618
- paths.append(args[index + 1])
1619
- if "=" in token:
1620
- head, value = token.split("=", 1)
1621
- if head in BODY_FILE_FLAGS:
1622
- paths.append(value)
1623
- if token.startswith("@") and len(token) > 1:
1624
- paths.append(token[1:])
1625
- return paths
1674
+ def github_issue_value_flag(token):
1675
+ """Identify a GitHub issue option that consumes a value."""
1676
+ if token.startswith("--"):
1677
+ name, equals, value = token.partition("=")
1678
+ if name in GITHUB_ISSUE_VALUE_FLAGS:
1679
+ return name, value if equals else None
1680
+ elif token.startswith("-"):
1681
+ # GitHub CLI's short flags can carry the value directly, including
1682
+ # after a boolean shorthand such as -e or -w.
1683
+ for index, shorthand in enumerate(token[1:], 1):
1684
+ if shorthand in GITHUB_ISSUE_SHORT_VALUES:
1685
+ suffix = token[index + 1 :]
1686
+ value = suffix[1:] if suffix.startswith("=") else suffix or None
1687
+ return GITHUB_ISSUE_SHORT_VALUES[shorthand], value
1688
+ if shorthand not in {"e", "w"}:
1689
+ break
1690
+ return None, None
1691
+
1692
+
1693
+ def github_issue_declarations(args):
1694
+ """Separate GitHub options from issue text and the selected body file."""
1695
+ remaining = iter(args)
1696
+ options = []
1697
+ title = None
1698
+ inline_body = None
1699
+ body_file = None
1700
+ for token in remaining:
1701
+ name, attached = github_issue_value_flag(token)
1702
+ value = next(remaining, None) if name and attached is None else attached
1703
+ if value is None:
1704
+ continue
1705
+ if name == "--body-file":
1706
+ body_file = value
1707
+ elif name == "--body":
1708
+ inline_body = value
1709
+ elif name == "--title":
1710
+ title = value
1711
+ elif name in {"--label", "--type", "--repo"}:
1712
+ options.append("%s=%s" % (name, value))
1713
+ # gh uses the last value for each body option. The selected file or stdin
1714
+ # takes precedence over the inline text.
1715
+ texts = [value for value in (title, inline_body if not body_file else None) if value]
1716
+ return options, texts, [body_file] if body_file else []
1717
+
1718
+
1719
+ def read_body_files(paths, cwd):
1720
+ """Read the body files actually named in this command's working folder."""
1721
+ texts = []
1722
+ unreadable = []
1723
+ for path in paths:
1724
+ if path in STDIN_PAYLOAD_TOKENS:
1725
+ continue
1726
+ candidate = resolve_operand(path, cwd)
1727
+ contents = read_operand(candidate) if candidate else None
1728
+ if contents is None:
1729
+ unreadable.append(path)
1730
+ else:
1731
+ texts.append(contents)
1732
+ return texts, unreadable
1626
1733
 
1627
1734
 
1628
1735
  def normalise_repo(value):
@@ -1730,12 +1837,13 @@ def roles_for(target):
1730
1837
  return [ready_role, role], None
1731
1838
 
1732
1839
 
1733
- def declares_readiness(raw_args, roles, extra="", state_role_ok=False):
1840
+ def declares_readiness(raw_args, roles, body_texts, extra="", state_role_ok=False):
1734
1841
  """Whether the create carries one of the required declarations.
1735
1842
 
1736
1843
  Args:
1737
1844
  raw_args: The creating command's arguments.
1738
1845
  roles: The build-ready role tokens that satisfy this filing.
1846
+ body_texts: Issue text from inline arguments and named body files.
1739
1847
  extra: Payload text this command submits, from a file or stdin.
1740
1848
  state_role_ok: Whether a lifecycle-role declaration answers here. True
1741
1849
  only for a state-based tracker filing into its own tracker, where
@@ -1761,13 +1869,8 @@ def declares_readiness(raw_args, roles, extra="", state_role_ok=False):
1761
1869
  # guard reads them and the intake matcher does not.
1762
1870
  if any(declares_human_gate(value) for value in args):
1763
1871
  return True
1764
- for path in body_file_paths(args):
1765
- try:
1766
- with open(path, encoding="utf-8", errors="replace") as handle:
1767
- if declares_human_gate(handle.read()):
1768
- return True
1769
- except OSError:
1770
- continue
1872
+ if any(declares_human_gate(body) for body in body_texts):
1873
+ return True
1771
1874
  if declares_human_gate(extra):
1772
1875
  return True
1773
1876
  # The state-based path. Scoped by `state_role_ok` rather than checked
@@ -1814,7 +1917,7 @@ def declares_container(raw_args, texts=()):
1814
1917
 
1815
1918
  Args:
1816
1919
  raw_args: The creating command's arguments.
1817
- texts: Payload or script text this command submits or runs.
1920
+ texts: Inline issue text, body files, payload or script text.
1818
1921
 
1819
1922
  Returns:
1820
1923
  True when the container declaration is present and uncontradicted.
@@ -1827,13 +1930,6 @@ def declares_container(raw_args, texts=()):
1827
1930
  return False
1828
1931
  if CONTAINER_DECLARATION.search(" ".join(args)):
1829
1932
  return True
1830
- for path in body_file_paths(args):
1831
- try:
1832
- with open(path, encoding="utf-8", errors="replace") as handle:
1833
- if CONTAINER_DECLARATION.search(handle.read()):
1834
- return True
1835
- except OSError:
1836
- continue
1837
1933
  for text in texts:
1838
1934
  if text and CONTAINER_DECLARATION.search(text):
1839
1935
  return True
@@ -2136,7 +2232,7 @@ def unparseable_reads_only(text):
2136
2232
  return bool(words) and all(word in READ_ONLY_PROGRAMS for word in words)
2137
2233
 
2138
2234
 
2139
- def executed_operand(argv):
2235
+ def executed_operand(argv, cwd):
2140
2236
  """The path this command EXECUTES, or None.
2141
2237
 
2142
2238
  THIS IS THE COMMAND-POSITION QUESTION, and declining to ask it is what
@@ -2168,6 +2264,7 @@ def executed_operand(argv):
2168
2264
 
2169
2265
  Args:
2170
2266
  argv: One command's tokens.
2267
+ cwd: The working directory, or None when it cannot be determined.
2171
2268
 
2172
2269
  Returns:
2173
2270
  The operand token naming a program that will run, or None.
@@ -2182,7 +2279,10 @@ def executed_operand(argv):
2182
2279
  return args[0] if args else None
2183
2280
  # A command word that is ITSELF a readable file is being executed by its
2184
2281
  # shebang — `./create.sh` names no interpreter and runs all the same.
2185
- if program not in EXECUTING_INTERPRETERS and resolve_operand(token) is not None:
2282
+ if program not in EXECUTING_INTERPRETERS and (
2283
+ resolve_operand(token, cwd) is not None
2284
+ or (cwd is None and not os.path.isabs(token) and "/" in token)
2285
+ ):
2186
2286
  return token
2187
2287
  # Reached by a known interpreter AND by a program this parser cannot name.
2188
2288
  # The unknown case is followed on purpose — see READ_ONLY_PROGRAMS.
@@ -2236,40 +2336,29 @@ def executed_operand(argv):
2236
2336
  return redirected
2237
2337
 
2238
2338
 
2239
- def file_operands(argv):
2240
- """The file this command EXECUTES, if it executes one.
2241
-
2242
- Deciding WHICH programs execute their operands is the question this file
2243
- used to refuse to ask, and refusing it is what made the guard read a path
2244
- quoted as prose inside a `--body-file` markdown and attribute its contents
2245
- to the command. It is answered in `executed_operand` now.
2246
-
2247
- Args:
2248
- argv: One command's tokens.
2249
-
2250
- Returns:
2251
- Existing paths, deduplicated across the whole scan and capped.
2252
- """
2253
- paths = []
2254
- operand = executed_operand(argv)
2255
- for token in [operand] if operand is not None else []:
2256
- if len(paths) >= FILE_OPERANDS_PER_SEGMENT:
2257
- break
2258
- path = resolve_operand(token)
2259
- if path is None:
2260
- continue
2261
- try:
2262
- key = os.path.realpath(path)
2263
- except OSError:
2264
- key = path
2265
- if key in inspected_files:
2266
- continue
2267
- inspected_files.add(key)
2268
- paths.append(path)
2269
- return paths
2339
+ def file_operand(argv, cwd):
2340
+ """Find the executable file and distinguish an indeterminate relative path."""
2341
+ token = executed_operand(argv, cwd)
2342
+ if token is None:
2343
+ return None, False
2344
+ path = resolve_operand(token, cwd)
2345
+ if path is None:
2346
+ command, program, _ = executing_command(argv)
2347
+ script_operand = program in EXECUTING_INTERPRETERS or program in SOURCE_BUILTINS
2348
+ explicit_path = token == command or "/" in token
2349
+ unresolved = cwd is None and not os.path.isabs(token) and (script_operand or explicit_path)
2350
+ return None, unresolved
2351
+ try:
2352
+ key = (os.path.realpath(path), cwd)
2353
+ except OSError:
2354
+ key = (path, cwd)
2355
+ if key in inspected_files:
2356
+ return None, False
2357
+ inspected_files.add(key)
2358
+ return path, False
2270
2359
 
2271
2360
 
2272
- def file_creation(text, depth):
2361
+ def file_creation(text, depth, cwd):
2273
2362
  """An undeclared tracker creation inside a file's contents, or None.
2274
2363
 
2275
2364
  Two recognisers, because a creation inside a file is not always shell.
@@ -2284,11 +2373,12 @@ def file_creation(text, depth):
2284
2373
  Args:
2285
2374
  text: The file's contents.
2286
2375
  depth: Current nesting depth.
2376
+ cwd: The folder the script runs in.
2287
2377
 
2288
2378
  Returns:
2289
- A (signature, roles, cross_repo_target) triple, or None.
2379
+ A (signature, roles, cross_repo_target, missing_body) tuple, or None.
2290
2380
  """
2291
- nested = scan(text, depth + 1, from_file=True)
2381
+ nested = scan(text, depth + 1, from_file=True, cwd=cwd)
2292
2382
  if nested is not None:
2293
2383
  return nested
2294
2384
  # The coarse path answers to a coarse declaration check, and the precise
@@ -2303,11 +2393,11 @@ def file_creation(text, depth):
2303
2393
  # `payload_is_inert` for why the absence of egress alone is not enough.
2304
2394
  and not payload_is_inert(text)
2305
2395
  ):
2306
- return "a tracker creation", [ready_role], None
2396
+ return "a tracker creation", [ready_role], None, None
2307
2397
  return None
2308
2398
 
2309
2399
 
2310
- def scan(text, depth, from_file=False):
2400
+ def scan(text, depth, from_file=False, cwd=tool_cwd):
2311
2401
  """Find the first undeclared tracker creation in a command string.
2312
2402
 
2313
2403
  Args:
@@ -2315,9 +2405,10 @@ def scan(text, depth, from_file=False):
2315
2405
  depth: Current nesting depth.
2316
2406
  from_file: Whether `text` is a file's contents rather than a typed
2317
2407
  command.
2408
+ cwd: The working folder before this command runs.
2318
2409
 
2319
2410
  Returns:
2320
- A (signature, roles, cross_repo_target) triple, or None when nothing
2411
+ A (signature, roles, cross_repo_target, missing_body) tuple, or None when nothing
2321
2412
  creation-shaped was found.
2322
2413
  """
2323
2414
  try:
@@ -2368,17 +2459,18 @@ def scan(text, depth, from_file=False):
2368
2459
  "an unparseable command that reads as a tracker creation",
2369
2460
  [ready_role],
2370
2461
  None,
2462
+ None,
2371
2463
  )
2372
2464
  return None
2373
2465
 
2374
- for argv in segment(tokens):
2466
+ for argv, cwd in segments_with_directory(tokens, cwd):
2375
2467
  for index, token in enumerate(argv):
2376
2468
  name = basename(token)
2377
2469
  if name not in TRACKER_CLIS and name not in HTTP_CLIS:
2378
2470
  continue
2379
2471
  args = argv[index + 1 :]
2380
- submitted = payload_text(args, text)
2381
- signature = creation_signature(name, args, submitted)
2472
+ submitted, missing_payload = payload_text(args, text, cwd)
2473
+ signature = creation_signature(name, args, submitted, bool(missing_payload))
2382
2474
  if signature is None:
2383
2475
  continue
2384
2476
  # The ambient override is the human operator's. An inline
@@ -2386,30 +2478,46 @@ def scan(text, depth, from_file=False):
2386
2478
  # disqualifies the override rather than supplying it.
2387
2479
  if ambient_override and not inline_override:
2388
2480
  continue
2389
- roles, target = roles_for(target_repository(args))
2390
- state_role_ok = tracker in STATE_ROLE_TRACKERS and target is None
2391
- if declares_readiness(args, roles, submitted, state_role_ok):
2481
+ declaration_args = before_end_of_options(args)
2482
+ inline_texts = []
2483
+ github_issue = signature == "gh issue create"
2484
+ if github_issue:
2485
+ declaration_args, inline_texts, body_paths = github_issue_declarations(declaration_args)
2486
+ # GitHub issue creation uses the selected body, not the HTTP
2487
+ # request options shared by other tracker commands.
2488
+ submitted, missing_payload = "", []
2489
+ repositories = flag_values(declaration_args, REPO_FLAGS)
2490
+ target_repo = normalise_repo(repositories[-1]) if repositories else None
2491
+ else:
2492
+ body_paths = flag_values(declaration_args, BODY_FILE_FLAGS)
2493
+ target_repo = target_repository(args)
2494
+ roles, target = roles_for(target_repo)
2495
+ state_role_ok = (
2496
+ not github_issue and tracker in STATE_ROLE_TRACKERS and target is None
2497
+ )
2498
+ file_texts, unreadable = read_body_files(body_paths, cwd)
2499
+ body_texts = [*inline_texts, *file_texts]
2500
+ if declares_readiness(declaration_args, roles, body_texts, submitted, state_role_ok):
2392
2501
  continue
2393
2502
  # The container arm. Checked after readiness, so it adds a
2394
2503
  # compliant filing where none existed and takes none away where one
2395
2504
  # already did. `text` joins the scan only for a creation found
2396
2505
  # INSIDE a file, where the declaration lives in the same file as
2397
2506
  # the create it answers for.
2398
- if declares_container(
2399
- args, (submitted, text) if from_file else (submitted,)
2400
- ):
2507
+ texts = (*body_texts, submitted, text) if from_file else (*body_texts, submitted)
2508
+ if declares_container(declaration_args, texts):
2401
2509
  continue
2402
2510
  # `LIFECYCLE_ROLE=ready curl …` puts the declaration BEFORE the
2403
2511
  # client, which is where an inline assignment has to go, so the
2404
2512
  # role is read from the whole segment rather than from the client's
2405
2513
  # own arguments. Scoped to the segment and not the command, so a
2406
2514
  # declaration cannot be shouted from an unrelated pipeline stage.
2407
- if state_role_ok and LIFECYCLE_ROLE_READY.search(" ".join(argv)):
2515
+ if state_role_ok and LIFECYCLE_ROLE_READY.search(" ".join(argv[:index])):
2408
2516
  continue
2409
2517
  # A script declares once, for itself. See `scope_declaration`.
2410
2518
  if from_file and scope_declaration(text, state_role_ok):
2411
2519
  continue
2412
- return signature, roles, target
2520
+ return signature, roles, target, next(iter([*missing_payload, *unreadable]), None)
2413
2521
 
2414
2522
  for operand in nested_operands(argv):
2415
2523
  if depth >= MAX_NESTING_DEPTH:
@@ -2421,9 +2529,10 @@ def scan(text, depth, from_file=False):
2421
2529
  "a tracker creation nested past the inspection depth",
2422
2530
  [ready_role],
2423
2531
  None,
2532
+ None,
2424
2533
  )
2425
2534
  continue
2426
- nested = scan(operand, depth + 1)
2535
+ nested = scan(operand, depth + 1, cwd=cwd)
2427
2536
  if nested is not None:
2428
2537
  return nested
2429
2538
 
@@ -2438,24 +2547,29 @@ def scan(text, depth, from_file=False):
2438
2547
  # review before it shipped.
2439
2548
  if ambient_override and not inline_override:
2440
2549
  continue
2441
- for path in file_operands(argv):
2442
- contents = read_operand(path)
2443
- if not contents:
2444
- continue
2445
- if depth >= MAX_NESTING_DEPTH:
2446
- if GRAPHQL_CREATE.search(contents) or UNPARSEABLE_CREATION.search(
2447
- contents
2448
- ):
2449
- return (
2450
- "a tracker creation inside %s, nested past the "
2451
- "inspection depth" % path,
2452
- [ready_role],
2453
- None,
2454
- )
2455
- continue
2456
- found = file_creation(contents, depth)
2457
- if found is not None:
2458
- return ("%s inside %s" % (found[0], path), found[1], found[2])
2550
+ path, unresolved = file_operand(argv, cwd)
2551
+ if unresolved:
2552
+ return "a script whose working directory could not be determined", [], None, None
2553
+ if path is None:
2554
+ continue
2555
+ contents = read_operand(path)
2556
+ if not contents:
2557
+ continue
2558
+ if depth >= MAX_NESTING_DEPTH:
2559
+ if GRAPHQL_CREATE.search(contents) or UNPARSEABLE_CREATION.search(
2560
+ contents
2561
+ ):
2562
+ return (
2563
+ "a tracker creation inside %s, nested past the "
2564
+ "inspection depth" % path,
2565
+ [ready_role],
2566
+ None,
2567
+ None,
2568
+ )
2569
+ continue
2570
+ found = file_creation(contents, depth, cwd)
2571
+ if found is not None:
2572
+ return ("%s inside %s" % (found[0], path), *found[1:])
2459
2573
  return None
2460
2574
 
2461
2575
 
@@ -2484,6 +2598,8 @@ def remedy_for(signature):
2484
2598
  Returns:
2485
2599
  A key the shell half maps to a paragraph, or an empty string.
2486
2600
  """
2601
+ if signature.startswith("a script whose working directory"):
2602
+ return "unresolved-script"
2487
2603
  if signature.startswith("an unparseable command"):
2488
2604
  return "unparseable"
2489
2605
  if " inside " in signature:
@@ -2493,7 +2609,7 @@ def remedy_for(signature):
2493
2609
 
2494
2610
  found = scan(command, 0)
2495
2611
  if found is not None:
2496
- signature, roles, target = found
2612
+ signature, roles, target, missing_body = found
2497
2613
  # Key=value lines rather than one delimited string: a signature contains
2498
2614
  # spaces and slashes, and a role may contain a colon, so anything the shell
2499
2615
  # would have to split on appears inside a value already.
@@ -2502,6 +2618,8 @@ if found is not None:
2502
2618
  print("roles=%s" % ", ".join(role for role in roles if role))
2503
2619
  print("target=%s" % (target or ""))
2504
2620
  print("remedy=%s" % remedy_for(signature))
2621
+ if missing_body is not None:
2622
+ print("body_file=%s" % json.dumps(missing_body))
2505
2623
  sys.exit(0)
2506
2624
 
2507
2625
  print("ALLOW")
@@ -2585,6 +2703,7 @@ verdict="$(
2585
2703
  LISA_GUARD_CALLER_IS_GITHUB="$caller_is_github" \
2586
2704
  LISA_GUARD_TRACKER="$tracker" \
2587
2705
  LISA_GUARD_PROJECT_DIR="$project_dir" \
2706
+ LISA_GUARD_TOOL_CWD="$tool_cwd" \
2588
2707
  python3 -
2589
2708
  )"
2590
2709
  python_status=$?
@@ -2607,7 +2726,8 @@ case "$verdict" in
2607
2726
  "$(verdict_field signature)" \
2608
2727
  "$(verdict_field roles)" \
2609
2728
  "$(verdict_field target)" \
2610
- "$(verdict_field remedy)"
2729
+ "$(verdict_field remedy)" \
2730
+ "$(verdict_field body_file)"
2611
2731
  ;;
2612
2732
  esac
2613
2733