@codyswann/lisa 8.6.1 → 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.
- package/README.md +9 -0
- package/all/copy-overwrite/scripts/lib/changed-paths.mjs +146 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-content.mjs +6 -2
- package/all/copy-overwrite/scripts/lisa-gates.mjs +16 -1
- package/all/copy-overwrite/scripts/lisa-hooks/block-direct-issue-create.sh +297 -177
- package/all/copy-overwrite/scripts/lisa-run-gates.mjs +24 -0
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +7 -6
- package/all/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
- package/dist/cli/apply-cmd.d.ts +10 -0
- package/dist/cli/apply-cmd.d.ts.map +1 -0
- package/dist/cli/apply-cmd.js +28 -0
- package/dist/cli/apply-cmd.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/controls/attest-check.d.ts.map +1 -1
- package/dist/controls/attest-check.js +31 -18
- package/dist/controls/attest-check.js.map +1 -1
- package/dist/controls/attest-record.d.ts +3 -0
- package/dist/controls/attest-record.d.ts.map +1 -1
- package/dist/controls/attest-record.js +28 -5
- package/dist/controls/attest-record.js.map +1 -1
- package/dist/controls/checks-binding.d.ts.map +1 -1
- package/dist/controls/checks-binding.js +28 -1
- package/dist/controls/checks-binding.js.map +1 -1
- package/dist/controls/commands/attest-host-proof.d.ts +18 -0
- package/dist/controls/commands/attest-host-proof.d.ts.map +1 -0
- package/dist/controls/commands/attest-host-proof.js +168 -0
- package/dist/controls/commands/attest-host-proof.js.map +1 -0
- package/dist/controls/commands/attest-options.d.ts +4 -0
- package/dist/controls/commands/attest-options.d.ts.map +1 -1
- package/dist/controls/commands/attest.d.ts.map +1 -1
- package/dist/controls/commands/attest.js +52 -0
- package/dist/controls/commands/attest.js.map +1 -1
- package/dist/controls/commands/declaration-check.d.ts.map +1 -1
- package/dist/controls/commands/declaration-check.js +19 -5
- package/dist/controls/commands/declaration-check.js.map +1 -1
- package/dist/controls/commands/register.d.ts.map +1 -1
- package/dist/controls/commands/register.js +4 -1
- package/dist/controls/commands/register.js.map +1 -1
- package/dist/controls/evidence-document.d.ts.map +1 -1
- package/dist/controls/evidence-document.js +12 -0
- package/dist/controls/evidence-document.js.map +1 -1
- package/dist/controls/evidence-gather.d.ts +1 -0
- package/dist/controls/evidence-gather.d.ts.map +1 -1
- package/dist/controls/evidence-gather.js +5 -2
- package/dist/controls/evidence-gather.js.map +1 -1
- package/dist/controls/evidence-types.d.ts +19 -1
- package/dist/controls/evidence-types.d.ts.map +1 -1
- package/dist/controls/evidence-types.js +11 -0
- package/dist/controls/evidence-types.js.map +1 -1
- package/dist/controls/evidence-write.d.ts.map +1 -1
- package/dist/controls/evidence-write.js +7 -1
- package/dist/controls/evidence-write.js.map +1 -1
- package/dist/controls/exercise-declaration.d.ts +58 -0
- package/dist/controls/exercise-declaration.d.ts.map +1 -0
- package/dist/controls/exercise-declaration.js +138 -0
- package/dist/controls/exercise-declaration.js.map +1 -0
- package/dist/controls/exercise-observations.d.ts +32 -0
- package/dist/controls/exercise-observations.d.ts.map +1 -0
- package/dist/controls/exercise-observations.js +141 -0
- package/dist/controls/exercise-observations.js.map +1 -0
- package/dist/controls/exercise-record-shape.d.ts +10 -0
- package/dist/controls/exercise-record-shape.d.ts.map +1 -0
- package/dist/controls/exercise-record-shape.js +29 -0
- package/dist/controls/exercise-record-shape.js.map +1 -0
- package/dist/controls/exercise-records.d.ts +28 -0
- package/dist/controls/exercise-records.d.ts.map +1 -0
- package/dist/controls/exercise-records.js +113 -0
- package/dist/controls/exercise-records.js.map +1 -0
- package/dist/controls/exercise-result.d.ts +23 -0
- package/dist/controls/exercise-result.d.ts.map +1 -0
- package/dist/controls/exercise-result.js +186 -0
- package/dist/controls/exercise-result.js.map +1 -0
- package/dist/controls/host-proof-input.d.ts +53 -0
- package/dist/controls/host-proof-input.d.ts.map +1 -0
- package/dist/controls/host-proof-input.js +129 -0
- package/dist/controls/host-proof-input.js.map +1 -0
- package/dist/controls/host-proof-receipt.d.ts +47 -0
- package/dist/controls/host-proof-receipt.d.ts.map +1 -0
- package/dist/controls/host-proof-receipt.js +132 -0
- package/dist/controls/host-proof-receipt.js.map +1 -0
- package/dist/controls/host-proof-register.d.ts +37 -0
- package/dist/controls/host-proof-register.d.ts.map +1 -0
- package/dist/controls/host-proof-register.js +153 -0
- package/dist/controls/host-proof-register.js.map +1 -0
- package/dist/controls/host-proof-signature.d.ts +30 -0
- package/dist/controls/host-proof-signature.d.ts.map +1 -0
- package/dist/controls/host-proof-signature.js +49 -0
- package/dist/controls/host-proof-signature.js.map +1 -0
- package/dist/controls/host-proof-trust.d.ts +33 -0
- package/dist/controls/host-proof-trust.d.ts.map +1 -0
- package/dist/controls/host-proof-trust.js +124 -0
- package/dist/controls/host-proof-trust.js.map +1 -0
- package/dist/controls/pull-request-executor.d.ts +18 -6
- package/dist/controls/pull-request-executor.d.ts.map +1 -1
- package/dist/controls/pull-request-executor.js +19 -24
- package/dist/controls/pull-request-executor.js.map +1 -1
- package/dist/controls/register-types.d.ts +3 -4
- package/dist/controls/register-types.d.ts.map +1 -1
- package/dist/controls/register-types.js +3 -4
- package/dist/controls/register-types.js.map +1 -1
- package/dist/controls/register.d.ts +4 -7
- package/dist/controls/register.d.ts.map +1 -1
- package/dist/controls/register.js +17 -6
- package/dist/controls/register.js.map +1 -1
- package/dist/controls/verdict-answers.d.ts.map +1 -1
- package/dist/controls/verdict-answers.js +6 -2
- package/dist/controls/verdict-answers.js.map +1 -1
- package/dist/controls/verdict-types.d.ts +1 -1
- package/dist/controls/verdict-types.d.ts.map +1 -1
- package/dist/controls/verdict-types.js +2 -0
- package/dist/controls/verdict-types.js.map +1 -1
- package/dist/controls/verdict-wording.d.ts +2 -0
- package/dist/controls/verdict-wording.d.ts.map +1 -1
- package/dist/controls/verdict-wording.js +7 -0
- package/dist/controls/verdict-wording.js.map +1 -1
- package/dist/controls/verdict.d.ts +2 -0
- package/dist/controls/verdict.d.ts.map +1 -1
- package/dist/controls/verdict.js +17 -2
- package/dist/controls/verdict.js.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.json +56 -4
- package/dist/core/nightly-e2e-guard-behavior-certificate.d.ts +5 -5
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +7 -7
- package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
- package/dist/core/upstream-evidence-manifest.json +99 -27
- package/expo/copy-overwrite/scripts/check-bdd-coverage.mjs +4 -1
- package/expo/create-only/tsconfig.local.json +6 -1
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa/.codex-plugin/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa/.codex-plugin/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/lisa/hooks/threshold-ratchet-compare.mjs +18 -12
- package/plugins/lisa/rules/reference/config-resolution.md +2 -2
- package/plugins/lisa/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa-agy/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa-agy/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-agy/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-agy/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa-agy/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-agy/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/lisa-copilot/hooks/threshold-ratchet-compare.mjs +18 -12
- package/plugins/lisa-copilot/rules/reference/config-resolution.md +2 -2
- package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa-copilot/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-copilot/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-copilot/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa-copilot/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-copilot/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/lisa-cursor/hooks/threshold-ratchet-compare.mjs +18 -12
- package/plugins/lisa-cursor/rules/config-resolution-reference.mdc +2 -2
- package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa-cursor/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-cursor/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-cursor/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa-cursor/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-cursor/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/lisa-devin/hooks/threshold-ratchet-compare.mjs +18 -12
- package/plugins/lisa-devin/rules/reference/config-resolution.md +2 -2
- package/plugins/lisa-devin/scripts/ready-queue-order.mjs +43 -18
- package/plugins/lisa-devin/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/lisa-devin/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/lisa-devin/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/lisa-devin/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/lisa-devin/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/hooks/block-direct-issue-create.sh +297 -177
- package/plugins/src/base/hooks/threshold-ratchet-compare.mjs +18 -12
- package/plugins/src/base/rules/reference/config-resolution.md +2 -2
- package/plugins/src/base/scripts/ready-queue-order.mjs +43 -18
- package/plugins/src/base/skills/lisa-attest/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-configure/SKILL.md +3 -2
- package/plugins/src/base/skills/lisa-configure/references/exercised-artifacts.md +55 -0
- package/plugins/src/base/skills/lisa-enforce/references/missing-capability-tickets.md +44 -5
- package/plugins/src/base/skills/lisa-enforce/references/pull-request-executor.md +34 -10
- package/plugins/src/base/skills/lisa-linear-write-issue/SKILL.md +6 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +9 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +32 -8
- package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +44 -1
- package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +14 -3
- package/plugins/src/base/skills/lisa-tracker-evidence/references/completion-authorization.md +4 -0
- package/rails/copy-overwrite/scripts/check-nightly-e2e-health.mjs +28 -2
- package/rails/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
- package/schemas/control-evidence.schema.json +39 -1
- package/schemas/control-verdict.schema.json +1 -0
- package/typescript/copy-overwrite/scripts/check-nightly-e2e-health.mjs +28 -2
- package/typescript/copy-overwrite/scripts/threshold-ratchet-compare.mjs +18 -12
|
@@ -237,11 +237,17 @@ if [ "$tool_name" != "Bash" ]; then
|
|
|
237
237
|
fi
|
|
238
238
|
|
|
239
239
|
command_str=""
|
|
240
|
+
tool_cwd=""
|
|
240
241
|
if [ -z "$structured_call" ]; then
|
|
241
242
|
command_str="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null || true)"
|
|
242
243
|
if [ -z "$command_str" ]; then
|
|
243
244
|
exit 0
|
|
244
245
|
fi
|
|
246
|
+
tool_cwd="$(printf '%s' "$input" | jq -r '
|
|
247
|
+
[.tool_input.workdir, .tool_input.cwd, .cwd]
|
|
248
|
+
| map(select(type == "string" and length > 0))
|
|
249
|
+
| .[0] // empty
|
|
250
|
+
' 2>/dev/null || true)"
|
|
245
251
|
fi
|
|
246
252
|
|
|
247
253
|
project_dir="${CLAUDE_PROJECT_DIR:-}"
|
|
@@ -431,16 +437,29 @@ EOF
|
|
|
431
437
|
esac
|
|
432
438
|
}
|
|
433
439
|
|
|
440
|
+
refusal_detail() {
|
|
441
|
+
if [ -n "${1:-}" ]; then
|
|
442
|
+
printf 'The body file %s could not be read, so its declaration was not seen. Name it by an absolute path.\n' "$1"
|
|
443
|
+
else
|
|
444
|
+
printf '%s\n' 'this filing declares no readiness.'
|
|
445
|
+
fi
|
|
446
|
+
}
|
|
447
|
+
|
|
434
448
|
refuse() {
|
|
435
449
|
local signature="$1"
|
|
436
450
|
local roles="$2"
|
|
437
451
|
local target="$3"
|
|
438
452
|
local remedy="${4:-}"
|
|
453
|
+
local body_file="${5:-}"
|
|
454
|
+
if [ "$remedy" = "unresolved-script" ]; then
|
|
455
|
+
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
|
|
456
|
+
exit 2
|
|
457
|
+
fi
|
|
439
458
|
if [ -n "$target" ]; then
|
|
440
|
-
refuse_cross_repo "$signature" "$roles" "$target"
|
|
459
|
+
refuse_cross_repo "$signature" "$roles" "$target" "$body_file"
|
|
441
460
|
fi
|
|
442
461
|
cat >&2 <<EOF
|
|
443
|
-
BLOCKED: refusing \`$signature\` —
|
|
462
|
+
BLOCKED: refusing \`$signature\` — $(refusal_detail "$body_file")
|
|
444
463
|
|
|
445
464
|
WHY: a work item filed without the build-ready role is an incomplete handoff.
|
|
446
465
|
Build-intake scans the ready lane and nothing else, so nothing will ever pick
|
|
@@ -535,8 +554,9 @@ refuse_cross_repo() {
|
|
|
535
554
|
local signature="$1"
|
|
536
555
|
local roles="$2"
|
|
537
556
|
local target="$3"
|
|
557
|
+
local body_file="${4:-}"
|
|
538
558
|
cat >&2 <<EOF
|
|
539
|
-
BLOCKED: refusing \`$signature\` —
|
|
559
|
+
BLOCKED: refusing \`$signature\` — $(refusal_detail "$body_file")
|
|
540
560
|
|
|
541
561
|
WHY: a work item filed without the build-ready role is an incomplete handoff.
|
|
542
562
|
Build-intake scans the ready lane and nothing else, so nothing will ever pick
|
|
@@ -590,6 +610,7 @@ EOF
|
|
|
590
610
|
# exit as a non-blocking hook error, so the command runs unchecked.
|
|
591
611
|
classifier=""
|
|
592
612
|
read -r -d '' classifier <<'PY' || true
|
|
613
|
+
import json
|
|
593
614
|
import os
|
|
594
615
|
import re
|
|
595
616
|
import shlex
|
|
@@ -605,6 +626,7 @@ upstream_ready_role = os.environ.get("LISA_GUARD_UPSTREAM_READY_ROLE", "")
|
|
|
605
626
|
caller_is_github = os.environ.get("LISA_GUARD_CALLER_IS_GITHUB", "") == "1"
|
|
606
627
|
tracker = os.environ.get("LISA_GUARD_TRACKER", "").strip().lower()
|
|
607
628
|
project_dir = os.environ.get("LISA_GUARD_PROJECT_DIR", "")
|
|
629
|
+
tool_cwd = os.path.join(project_dir, os.environ.get("LISA_GUARD_TOOL_CWD", ""))
|
|
608
630
|
|
|
609
631
|
OVERRIDE_NAME = "LISA_ALLOW_DIRECT_ISSUE_CREATE"
|
|
610
632
|
HUMAN_GATE_MARKER = "[lisa-human-gate]"
|
|
@@ -738,7 +760,17 @@ UNPARSEABLE_CREATION = re.compile(
|
|
|
738
760
|
re.IGNORECASE,
|
|
739
761
|
)
|
|
740
762
|
|
|
741
|
-
BODY_FILE_FLAGS = {"--body-file"
|
|
763
|
+
BODY_FILE_FLAGS = {"--body-file"}
|
|
764
|
+
GITHUB_ISSUE_VALUE_FLAGS = {
|
|
765
|
+
"--assignee", "--blocked-by", "--blocking", "--body", "--body-file",
|
|
766
|
+
"--label", "--milestone", "--parent", "--project", "--recover", "--repo",
|
|
767
|
+
"--template", "--title", "--type",
|
|
768
|
+
}
|
|
769
|
+
GITHUB_ISSUE_SHORT_VALUES = {
|
|
770
|
+
"a": "--assignee", "b": "--body", "F": "--body-file", "l": "--label",
|
|
771
|
+
"m": "--milestone", "p": "--project", "R": "--repo", "T": "--template",
|
|
772
|
+
"t": "--title",
|
|
773
|
+
}
|
|
742
774
|
LABEL_FLAGS = {"--label", "--labels", "--add-label", "--status", "--state"}
|
|
743
775
|
|
|
744
776
|
# ---------------------------------------------------------------------------
|
|
@@ -880,7 +912,6 @@ GRAPHQL_CREATE = re.compile(r"createIssue|issueCreate")
|
|
|
880
912
|
# documented direction of failure: an operator who hits a false refusal says
|
|
881
913
|
# so, an agent who hits a false allow says nothing.
|
|
882
914
|
FILE_OPERAND_MAX_BYTES = 262144
|
|
883
|
-
FILE_OPERANDS_PER_SEGMENT = 8
|
|
884
915
|
# Payload sources. A creation's mutation text may arrive inline, from a file,
|
|
885
916
|
# or over stdin from an earlier stage of the same pipeline.
|
|
886
917
|
PAYLOAD_SOURCE_FLAGS = {
|
|
@@ -1141,25 +1172,55 @@ def explode_operators(tokens, text=""):
|
|
|
1141
1172
|
return exploded
|
|
1142
1173
|
|
|
1143
1174
|
|
|
1144
|
-
def
|
|
1145
|
-
"""
|
|
1146
|
-
|
|
1147
|
-
Args:
|
|
1148
|
-
tokens: Exploded tokens.
|
|
1149
|
-
|
|
1150
|
-
Returns:
|
|
1151
|
-
A list of argv lists.
|
|
1152
|
-
"""
|
|
1153
|
-
segments = []
|
|
1175
|
+
def connected_segments(tokens):
|
|
1176
|
+
"""Yield each argv with the unquoted shell operator that follows it."""
|
|
1154
1177
|
current = []
|
|
1155
1178
|
for token in tokens:
|
|
1156
1179
|
if token in SEGMENT_BOUNDARIES and not isinstance(token, LiteralToken):
|
|
1157
|
-
|
|
1180
|
+
yield current, token
|
|
1158
1181
|
current = []
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1182
|
+
else:
|
|
1183
|
+
current.append(token)
|
|
1184
|
+
if current:
|
|
1185
|
+
yield current, ""
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
def directory_after_cd(argv, cwd):
|
|
1189
|
+
"""Resolve a single literal cd operand without evaluating shell syntax."""
|
|
1190
|
+
args = argv[1:]
|
|
1191
|
+
physical = args[:1] == ["-P"]
|
|
1192
|
+
if physical or args[:1] == ["-L"]:
|
|
1193
|
+
args = args[1:]
|
|
1194
|
+
if args[:1] == ["--"]:
|
|
1195
|
+
args = args[1:]
|
|
1196
|
+
if len(args) != 1:
|
|
1197
|
+
return None
|
|
1198
|
+
target = args[0]
|
|
1199
|
+
if not target or target.startswith("-") or re.search(r"[\x24\x60~*?\[\]{}\n\r]", target):
|
|
1200
|
+
return None
|
|
1201
|
+
target = absolute_operand(target, cwd)
|
|
1202
|
+
if target is None:
|
|
1203
|
+
return None
|
|
1204
|
+
return os.path.realpath(target) if physical else os.path.normpath(target)
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
def segments_with_directory(tokens, cwd):
|
|
1208
|
+
"""Follow literal directory changes while success is required by &&."""
|
|
1209
|
+
preceding = ""
|
|
1210
|
+
changed = False
|
|
1211
|
+
for argv, following in connected_segments(tokens):
|
|
1212
|
+
if argv and argv[0] == "cd":
|
|
1213
|
+
cwd = (
|
|
1214
|
+
directory_after_cd(argv, cwd)
|
|
1215
|
+
if following == "&&" and preceding in {"", "&&", ";", "(", "{"}
|
|
1216
|
+
else None
|
|
1217
|
+
)
|
|
1218
|
+
changed = True
|
|
1219
|
+
elif argv:
|
|
1220
|
+
yield argv, cwd
|
|
1221
|
+
if changed and following not in {"", "&&"}:
|
|
1222
|
+
cwd = None
|
|
1223
|
+
preceding = following
|
|
1163
1224
|
|
|
1164
1225
|
|
|
1165
1226
|
def basename(token):
|
|
@@ -1329,7 +1390,14 @@ def endpoint_paths(args, pattern):
|
|
|
1329
1390
|
return found
|
|
1330
1391
|
|
|
1331
1392
|
|
|
1332
|
-
def
|
|
1393
|
+
def absolute_operand(path, cwd):
|
|
1394
|
+
"""A literal absolute operand or a path relative to a known directory."""
|
|
1395
|
+
if os.path.isabs(path):
|
|
1396
|
+
return path
|
|
1397
|
+
return os.path.join(cwd, path) if cwd else None
|
|
1398
|
+
|
|
1399
|
+
|
|
1400
|
+
def resolve_operand(token, cwd):
|
|
1333
1401
|
"""A readable regular file named by one token, or None.
|
|
1334
1402
|
|
|
1335
1403
|
Bounded on purpose. The size cap keeps a PreToolUse hook off a multi-
|
|
@@ -1338,32 +1406,20 @@ def resolve_operand(token):
|
|
|
1338
1406
|
confident ALLOW about text it never saw.
|
|
1339
1407
|
|
|
1340
1408
|
Args:
|
|
1341
|
-
token: One
|
|
1409
|
+
token: One decoded path argument.
|
|
1410
|
+
cwd: The working directory, or None when it cannot be determined.
|
|
1342
1411
|
|
|
1343
1412
|
Returns:
|
|
1344
1413
|
An existing path, or None.
|
|
1345
1414
|
"""
|
|
1346
|
-
|
|
1347
|
-
# `-d@payload.json` names a file just as plainly as `@payload.json` does.
|
|
1348
|
-
attached = attached_value(text)
|
|
1349
|
-
if attached is not None:
|
|
1350
|
-
text = attached
|
|
1351
|
-
if text.startswith("@"):
|
|
1352
|
-
text = text[1:]
|
|
1353
|
-
if not text or text in STDIN_PAYLOAD_TOKENS:
|
|
1415
|
+
if not token or token in STDIN_PAYLOAD_TOKENS:
|
|
1354
1416
|
return None
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
continue
|
|
1362
|
-
if os.path.getsize(candidate) > FILE_OPERAND_MAX_BYTES:
|
|
1363
|
-
continue
|
|
1364
|
-
except OSError:
|
|
1365
|
-
continue
|
|
1366
|
-
return candidate
|
|
1417
|
+
candidate = absolute_operand(token, cwd)
|
|
1418
|
+
try:
|
|
1419
|
+
if candidate and os.path.isfile(candidate) and os.path.getsize(candidate) <= FILE_OPERAND_MAX_BYTES:
|
|
1420
|
+
return candidate
|
|
1421
|
+
except (OSError, ValueError):
|
|
1422
|
+
pass
|
|
1367
1423
|
return None
|
|
1368
1424
|
|
|
1369
1425
|
|
|
@@ -1374,17 +1430,17 @@ def read_operand(path):
|
|
|
1374
1430
|
path: A path from `resolve_operand`.
|
|
1375
1431
|
|
|
1376
1432
|
Returns:
|
|
1377
|
-
The contents, or
|
|
1433
|
+
The contents, or None when unreadable.
|
|
1378
1434
|
"""
|
|
1379
1435
|
try:
|
|
1380
1436
|
with open(path, encoding="utf-8", errors="replace") as handle:
|
|
1381
1437
|
return handle.read(FILE_OPERAND_MAX_BYTES)
|
|
1382
|
-
except OSError:
|
|
1383
|
-
return
|
|
1438
|
+
except (OSError, TypeError):
|
|
1439
|
+
return None
|
|
1384
1440
|
|
|
1385
1441
|
|
|
1386
|
-
def
|
|
1387
|
-
"""A payload flag
|
|
1442
|
+
def attached_payload(token):
|
|
1443
|
+
"""A payload flag and its value when it is GLUED to the flag.
|
|
1388
1444
|
|
|
1389
1445
|
`curl -d@payload.json` and `curl -d'{"query":…}'` are one token each, so a
|
|
1390
1446
|
parser that only looks at `args[i + 1]` and at `flag=value` sees neither —
|
|
@@ -1400,7 +1456,7 @@ def attached_value(token):
|
|
|
1400
1456
|
token: One argument.
|
|
1401
1457
|
|
|
1402
1458
|
Returns:
|
|
1403
|
-
The attached value, or None.
|
|
1459
|
+
The flag and its attached value, or a pair of None values.
|
|
1404
1460
|
"""
|
|
1405
1461
|
for flag in sorted(PAYLOAD_SOURCE_FLAGS, key=len, reverse=True):
|
|
1406
1462
|
if not token.startswith(flag) or len(token) == len(flag):
|
|
@@ -1410,11 +1466,11 @@ def attached_value(token):
|
|
|
1410
1466
|
rest = rest[1:]
|
|
1411
1467
|
if not rest or rest.startswith("-"):
|
|
1412
1468
|
continue
|
|
1413
|
-
return rest
|
|
1414
|
-
return None
|
|
1469
|
+
return flag, rest
|
|
1470
|
+
return None, None
|
|
1415
1471
|
|
|
1416
1472
|
|
|
1417
|
-
def payload_text(args, whole_command):
|
|
1473
|
+
def payload_text(args, whole_command, cwd):
|
|
1418
1474
|
"""The body this command will submit, wherever it is coming from.
|
|
1419
1475
|
|
|
1420
1476
|
Three sources, because a request body has three places to live and the
|
|
@@ -1424,39 +1480,45 @@ def payload_text(args, whole_command):
|
|
|
1424
1480
|
|
|
1425
1481
|
The stdin case takes the WHOLE command text rather than the segment,
|
|
1426
1482
|
because `jq -n … | curl … --data-binary @-` is one logical command that
|
|
1427
|
-
|
|
1483
|
+
the scanner has already split in two — the payload literally is the other
|
|
1428
1484
|
half. That is the shape `lisa-linear-access` mandates, so it has to be
|
|
1429
1485
|
readable rather than invisible.
|
|
1430
1486
|
|
|
1431
1487
|
Args:
|
|
1432
1488
|
args: A command's arguments.
|
|
1433
1489
|
whole_command: The full intercepted command string.
|
|
1490
|
+
cwd: The working directory, or None when it cannot be determined.
|
|
1434
1491
|
|
|
1435
1492
|
Returns:
|
|
1436
|
-
The payload text
|
|
1493
|
+
The payload text and paths of unreadable payload files.
|
|
1437
1494
|
"""
|
|
1438
1495
|
parts = []
|
|
1496
|
+
unreadable = []
|
|
1497
|
+
args = before_end_of_options(args)
|
|
1439
1498
|
for index, token in enumerate(args):
|
|
1440
|
-
value = None
|
|
1441
1499
|
if token in PAYLOAD_SOURCE_FLAGS and index + 1 < len(args):
|
|
1500
|
+
flag = token
|
|
1442
1501
|
value = args[index + 1]
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
if head in PAYLOAD_SOURCE_FLAGS:
|
|
1446
|
-
value = rhs
|
|
1447
|
-
if value is None:
|
|
1448
|
-
value = attached_value(token)
|
|
1502
|
+
else:
|
|
1503
|
+
flag, value = attached_payload(token)
|
|
1449
1504
|
if value is None:
|
|
1450
1505
|
continue
|
|
1451
|
-
|
|
1452
|
-
|
|
1506
|
+
if flag == "--data-raw" or not (
|
|
1507
|
+
value.startswith("@") or flag in {"--input", "--upload-file", "-T"}
|
|
1508
|
+
):
|
|
1509
|
+
parts.append(value)
|
|
1510
|
+
continue
|
|
1511
|
+
if value in STDIN_PAYLOAD_TOKENS:
|
|
1453
1512
|
parts.append(whole_command)
|
|
1454
1513
|
continue
|
|
1455
|
-
|
|
1456
|
-
path = resolve_operand(
|
|
1457
|
-
if path
|
|
1458
|
-
|
|
1459
|
-
|
|
1514
|
+
operand = value[1:] if value.startswith("@") else value
|
|
1515
|
+
path = resolve_operand(operand, cwd)
|
|
1516
|
+
contents = read_operand(path) if path else None
|
|
1517
|
+
if contents is None:
|
|
1518
|
+
unreadable.append(operand)
|
|
1519
|
+
else:
|
|
1520
|
+
parts.append(contents)
|
|
1521
|
+
return "\n".join(parts), unreadable
|
|
1460
1522
|
|
|
1461
1523
|
|
|
1462
1524
|
def text_declares_readiness(text):
|
|
@@ -1524,13 +1586,14 @@ def scope_declaration(text, state_role_ok):
|
|
|
1524
1586
|
return bool(state_role_ok and LIFECYCLE_ROLE_READY.search(text))
|
|
1525
1587
|
|
|
1526
1588
|
|
|
1527
|
-
def creation_signature(name, args, extra=""):
|
|
1589
|
+
def creation_signature(name, args, extra="", unreadable_payload=False):
|
|
1528
1590
|
"""Classify a tracker CLI invocation as a creation.
|
|
1529
1591
|
|
|
1530
1592
|
Args:
|
|
1531
1593
|
name: The CLI basename.
|
|
1532
1594
|
args: Every token after it in this segment.
|
|
1533
1595
|
extra: Payload text this command submits, from a file or stdin.
|
|
1596
|
+
unreadable_payload: Whether a named request body could not be read.
|
|
1534
1597
|
|
|
1535
1598
|
Returns:
|
|
1536
1599
|
A short human-readable signature, or None.
|
|
@@ -1549,6 +1612,8 @@ def creation_signature(name, args, extra=""):
|
|
|
1549
1612
|
if "api" in args:
|
|
1550
1613
|
if GRAPHQL_CREATE.search(joined):
|
|
1551
1614
|
return "gh api graphql issue creation"
|
|
1615
|
+
if unreadable_payload and "graphql" in args and is_write_request(args):
|
|
1616
|
+
return "gh api graphql with an unreadable request body"
|
|
1552
1617
|
if endpoint_paths(args, GITHUB_ISSUES_PATH) and is_write_request(args):
|
|
1553
1618
|
return "gh api POST .../issues"
|
|
1554
1619
|
return None
|
|
@@ -1571,8 +1636,11 @@ def creation_signature(name, args, extra=""):
|
|
|
1571
1636
|
return "%s POST api.github.com/…/issues" % name
|
|
1572
1637
|
if JIRA_ISSUE_URL.search(token):
|
|
1573
1638
|
return "%s POST …/rest/api/…/issue" % name
|
|
1574
|
-
if "api.linear.app/graphql" in token
|
|
1575
|
-
|
|
1639
|
+
if "api.linear.app/graphql" in token:
|
|
1640
|
+
if GRAPHQL_CREATE.search(joined):
|
|
1641
|
+
return "%s POST api.linear.app/graphql issueCreate" % name
|
|
1642
|
+
if unreadable_payload:
|
|
1643
|
+
return "%s POST api.linear.app/graphql with an unreadable request body" % name
|
|
1576
1644
|
return None
|
|
1577
1645
|
|
|
1578
1646
|
return None
|
|
@@ -1600,26 +1668,65 @@ def before_end_of_options(args):
|
|
|
1600
1668
|
return args[: args.index("--")] if "--" in args else args
|
|
1601
1669
|
|
|
1602
1670
|
|
|
1603
|
-
def
|
|
1604
|
-
"""
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1671
|
+
def github_issue_value_flag(token):
|
|
1672
|
+
"""Identify a GitHub issue option that consumes a value."""
|
|
1673
|
+
if token.startswith("--"):
|
|
1674
|
+
name, equals, value = token.partition("=")
|
|
1675
|
+
if name in GITHUB_ISSUE_VALUE_FLAGS:
|
|
1676
|
+
return name, value if equals else None
|
|
1677
|
+
elif token.startswith("-"):
|
|
1678
|
+
# GitHub CLI's short flags can carry the value directly, including
|
|
1679
|
+
# after a boolean shorthand such as -e or -w.
|
|
1680
|
+
for index, shorthand in enumerate(token[1:], 1):
|
|
1681
|
+
if shorthand in GITHUB_ISSUE_SHORT_VALUES:
|
|
1682
|
+
suffix = token[index + 1 :]
|
|
1683
|
+
value = suffix[1:] if suffix.startswith("=") else suffix or None
|
|
1684
|
+
return GITHUB_ISSUE_SHORT_VALUES[shorthand], value
|
|
1685
|
+
if shorthand not in {"e", "w"}:
|
|
1686
|
+
break
|
|
1687
|
+
return None, None
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
def github_issue_declarations(args):
|
|
1691
|
+
"""Separate GitHub options from issue text and the selected body file."""
|
|
1692
|
+
remaining = iter(args)
|
|
1693
|
+
options = []
|
|
1694
|
+
title = None
|
|
1695
|
+
inline_body = None
|
|
1696
|
+
body_file = None
|
|
1697
|
+
for token in remaining:
|
|
1698
|
+
name, attached = github_issue_value_flag(token)
|
|
1699
|
+
value = next(remaining, None) if name and attached is None else attached
|
|
1700
|
+
if value is None:
|
|
1701
|
+
continue
|
|
1702
|
+
if name == "--body-file":
|
|
1703
|
+
body_file = value
|
|
1704
|
+
elif name == "--body":
|
|
1705
|
+
inline_body = value
|
|
1706
|
+
elif name == "--title":
|
|
1707
|
+
title = value
|
|
1708
|
+
elif name in {"--label", "--type", "--repo"}:
|
|
1709
|
+
options.append("%s=%s" % (name, value))
|
|
1710
|
+
# gh uses the last value for each body option. The selected file or stdin
|
|
1711
|
+
# takes precedence over the inline text.
|
|
1712
|
+
texts = [value for value in (title, inline_body if not body_file else None) if value]
|
|
1713
|
+
return options, texts, [body_file] if body_file else []
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
def read_body_files(paths, cwd):
|
|
1717
|
+
"""Read the body files actually named in this command's working folder."""
|
|
1718
|
+
texts = []
|
|
1719
|
+
unreadable = []
|
|
1720
|
+
for path in paths:
|
|
1721
|
+
if path in STDIN_PAYLOAD_TOKENS:
|
|
1722
|
+
continue
|
|
1723
|
+
candidate = resolve_operand(path, cwd)
|
|
1724
|
+
contents = read_operand(candidate) if candidate else None
|
|
1725
|
+
if contents is None:
|
|
1726
|
+
unreadable.append(path)
|
|
1727
|
+
else:
|
|
1728
|
+
texts.append(contents)
|
|
1729
|
+
return texts, unreadable
|
|
1623
1730
|
|
|
1624
1731
|
|
|
1625
1732
|
def normalise_repo(value):
|
|
@@ -1727,12 +1834,13 @@ def roles_for(target):
|
|
|
1727
1834
|
return [ready_role, role], None
|
|
1728
1835
|
|
|
1729
1836
|
|
|
1730
|
-
def declares_readiness(raw_args, roles, extra="", state_role_ok=False):
|
|
1837
|
+
def declares_readiness(raw_args, roles, body_texts, extra="", state_role_ok=False):
|
|
1731
1838
|
"""Whether the create carries one of the required declarations.
|
|
1732
1839
|
|
|
1733
1840
|
Args:
|
|
1734
1841
|
raw_args: The creating command's arguments.
|
|
1735
1842
|
roles: The build-ready role tokens that satisfy this filing.
|
|
1843
|
+
body_texts: Issue text from inline arguments and named body files.
|
|
1736
1844
|
extra: Payload text this command submits, from a file or stdin.
|
|
1737
1845
|
state_role_ok: Whether a lifecycle-role declaration answers here. True
|
|
1738
1846
|
only for a state-based tracker filing into its own tracker, where
|
|
@@ -1758,13 +1866,8 @@ def declares_readiness(raw_args, roles, extra="", state_role_ok=False):
|
|
|
1758
1866
|
# guard reads them and the intake matcher does not.
|
|
1759
1867
|
if any(declares_human_gate(value) for value in args):
|
|
1760
1868
|
return True
|
|
1761
|
-
for
|
|
1762
|
-
|
|
1763
|
-
with open(path, encoding="utf-8", errors="replace") as handle:
|
|
1764
|
-
if declares_human_gate(handle.read()):
|
|
1765
|
-
return True
|
|
1766
|
-
except OSError:
|
|
1767
|
-
continue
|
|
1869
|
+
if any(declares_human_gate(body) for body in body_texts):
|
|
1870
|
+
return True
|
|
1768
1871
|
if declares_human_gate(extra):
|
|
1769
1872
|
return True
|
|
1770
1873
|
# The state-based path. Scoped by `state_role_ok` rather than checked
|
|
@@ -1811,7 +1914,7 @@ def declares_container(raw_args, texts=()):
|
|
|
1811
1914
|
|
|
1812
1915
|
Args:
|
|
1813
1916
|
raw_args: The creating command's arguments.
|
|
1814
|
-
texts:
|
|
1917
|
+
texts: Inline issue text, body files, payload or script text.
|
|
1815
1918
|
|
|
1816
1919
|
Returns:
|
|
1817
1920
|
True when the container declaration is present and uncontradicted.
|
|
@@ -1824,13 +1927,6 @@ def declares_container(raw_args, texts=()):
|
|
|
1824
1927
|
return False
|
|
1825
1928
|
if CONTAINER_DECLARATION.search(" ".join(args)):
|
|
1826
1929
|
return True
|
|
1827
|
-
for path in body_file_paths(args):
|
|
1828
|
-
try:
|
|
1829
|
-
with open(path, encoding="utf-8", errors="replace") as handle:
|
|
1830
|
-
if CONTAINER_DECLARATION.search(handle.read()):
|
|
1831
|
-
return True
|
|
1832
|
-
except OSError:
|
|
1833
|
-
continue
|
|
1834
1930
|
for text in texts:
|
|
1835
1931
|
if text and CONTAINER_DECLARATION.search(text):
|
|
1836
1932
|
return True
|
|
@@ -2133,7 +2229,7 @@ def unparseable_reads_only(text):
|
|
|
2133
2229
|
return bool(words) and all(word in READ_ONLY_PROGRAMS for word in words)
|
|
2134
2230
|
|
|
2135
2231
|
|
|
2136
|
-
def executed_operand(argv):
|
|
2232
|
+
def executed_operand(argv, cwd):
|
|
2137
2233
|
"""The path this command EXECUTES, or None.
|
|
2138
2234
|
|
|
2139
2235
|
THIS IS THE COMMAND-POSITION QUESTION, and declining to ask it is what
|
|
@@ -2165,6 +2261,7 @@ def executed_operand(argv):
|
|
|
2165
2261
|
|
|
2166
2262
|
Args:
|
|
2167
2263
|
argv: One command's tokens.
|
|
2264
|
+
cwd: The working directory, or None when it cannot be determined.
|
|
2168
2265
|
|
|
2169
2266
|
Returns:
|
|
2170
2267
|
The operand token naming a program that will run, or None.
|
|
@@ -2179,7 +2276,10 @@ def executed_operand(argv):
|
|
|
2179
2276
|
return args[0] if args else None
|
|
2180
2277
|
# A command word that is ITSELF a readable file is being executed by its
|
|
2181
2278
|
# shebang — `./create.sh` names no interpreter and runs all the same.
|
|
2182
|
-
if program not in EXECUTING_INTERPRETERS and
|
|
2279
|
+
if program not in EXECUTING_INTERPRETERS and (
|
|
2280
|
+
resolve_operand(token, cwd) is not None
|
|
2281
|
+
or (cwd is None and not os.path.isabs(token) and "/" in token)
|
|
2282
|
+
):
|
|
2183
2283
|
return token
|
|
2184
2284
|
# Reached by a known interpreter AND by a program this parser cannot name.
|
|
2185
2285
|
# The unknown case is followed on purpose — see READ_ONLY_PROGRAMS.
|
|
@@ -2233,40 +2333,29 @@ def executed_operand(argv):
|
|
|
2233
2333
|
return redirected
|
|
2234
2334
|
|
|
2235
2335
|
|
|
2236
|
-
def
|
|
2237
|
-
"""
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
if path is None:
|
|
2257
|
-
continue
|
|
2258
|
-
try:
|
|
2259
|
-
key = os.path.realpath(path)
|
|
2260
|
-
except OSError:
|
|
2261
|
-
key = path
|
|
2262
|
-
if key in inspected_files:
|
|
2263
|
-
continue
|
|
2264
|
-
inspected_files.add(key)
|
|
2265
|
-
paths.append(path)
|
|
2266
|
-
return paths
|
|
2336
|
+
def file_operand(argv, cwd):
|
|
2337
|
+
"""Find the executable file and distinguish an indeterminate relative path."""
|
|
2338
|
+
token = executed_operand(argv, cwd)
|
|
2339
|
+
if token is None:
|
|
2340
|
+
return None, False
|
|
2341
|
+
path = resolve_operand(token, cwd)
|
|
2342
|
+
if path is None:
|
|
2343
|
+
command, program, _ = executing_command(argv)
|
|
2344
|
+
script_operand = program in EXECUTING_INTERPRETERS or program in SOURCE_BUILTINS
|
|
2345
|
+
explicit_path = token == command or "/" in token
|
|
2346
|
+
unresolved = cwd is None and not os.path.isabs(token) and (script_operand or explicit_path)
|
|
2347
|
+
return None, unresolved
|
|
2348
|
+
try:
|
|
2349
|
+
key = (os.path.realpath(path), cwd)
|
|
2350
|
+
except OSError:
|
|
2351
|
+
key = (path, cwd)
|
|
2352
|
+
if key in inspected_files:
|
|
2353
|
+
return None, False
|
|
2354
|
+
inspected_files.add(key)
|
|
2355
|
+
return path, False
|
|
2267
2356
|
|
|
2268
2357
|
|
|
2269
|
-
def file_creation(text, depth):
|
|
2358
|
+
def file_creation(text, depth, cwd):
|
|
2270
2359
|
"""An undeclared tracker creation inside a file's contents, or None.
|
|
2271
2360
|
|
|
2272
2361
|
Two recognisers, because a creation inside a file is not always shell.
|
|
@@ -2281,11 +2370,12 @@ def file_creation(text, depth):
|
|
|
2281
2370
|
Args:
|
|
2282
2371
|
text: The file's contents.
|
|
2283
2372
|
depth: Current nesting depth.
|
|
2373
|
+
cwd: The folder the script runs in.
|
|
2284
2374
|
|
|
2285
2375
|
Returns:
|
|
2286
|
-
A (signature, roles, cross_repo_target)
|
|
2376
|
+
A (signature, roles, cross_repo_target, missing_body) tuple, or None.
|
|
2287
2377
|
"""
|
|
2288
|
-
nested = scan(text, depth + 1, from_file=True)
|
|
2378
|
+
nested = scan(text, depth + 1, from_file=True, cwd=cwd)
|
|
2289
2379
|
if nested is not None:
|
|
2290
2380
|
return nested
|
|
2291
2381
|
# The coarse path answers to a coarse declaration check, and the precise
|
|
@@ -2300,11 +2390,11 @@ def file_creation(text, depth):
|
|
|
2300
2390
|
# `payload_is_inert` for why the absence of egress alone is not enough.
|
|
2301
2391
|
and not payload_is_inert(text)
|
|
2302
2392
|
):
|
|
2303
|
-
return "a tracker creation", [ready_role], None
|
|
2393
|
+
return "a tracker creation", [ready_role], None, None
|
|
2304
2394
|
return None
|
|
2305
2395
|
|
|
2306
2396
|
|
|
2307
|
-
def scan(text, depth, from_file=False):
|
|
2397
|
+
def scan(text, depth, from_file=False, cwd=tool_cwd):
|
|
2308
2398
|
"""Find the first undeclared tracker creation in a command string.
|
|
2309
2399
|
|
|
2310
2400
|
Args:
|
|
@@ -2312,9 +2402,10 @@ def scan(text, depth, from_file=False):
|
|
|
2312
2402
|
depth: Current nesting depth.
|
|
2313
2403
|
from_file: Whether `text` is a file's contents rather than a typed
|
|
2314
2404
|
command.
|
|
2405
|
+
cwd: The working folder before this command runs.
|
|
2315
2406
|
|
|
2316
2407
|
Returns:
|
|
2317
|
-
A (signature, roles, cross_repo_target)
|
|
2408
|
+
A (signature, roles, cross_repo_target, missing_body) tuple, or None when nothing
|
|
2318
2409
|
creation-shaped was found.
|
|
2319
2410
|
"""
|
|
2320
2411
|
try:
|
|
@@ -2365,17 +2456,18 @@ def scan(text, depth, from_file=False):
|
|
|
2365
2456
|
"an unparseable command that reads as a tracker creation",
|
|
2366
2457
|
[ready_role],
|
|
2367
2458
|
None,
|
|
2459
|
+
None,
|
|
2368
2460
|
)
|
|
2369
2461
|
return None
|
|
2370
2462
|
|
|
2371
|
-
for argv in
|
|
2463
|
+
for argv, cwd in segments_with_directory(tokens, cwd):
|
|
2372
2464
|
for index, token in enumerate(argv):
|
|
2373
2465
|
name = basename(token)
|
|
2374
2466
|
if name not in TRACKER_CLIS and name not in HTTP_CLIS:
|
|
2375
2467
|
continue
|
|
2376
2468
|
args = argv[index + 1 :]
|
|
2377
|
-
submitted = payload_text(args, text)
|
|
2378
|
-
signature = creation_signature(name, args, submitted)
|
|
2469
|
+
submitted, missing_payload = payload_text(args, text, cwd)
|
|
2470
|
+
signature = creation_signature(name, args, submitted, bool(missing_payload))
|
|
2379
2471
|
if signature is None:
|
|
2380
2472
|
continue
|
|
2381
2473
|
# The ambient override is the human operator's. An inline
|
|
@@ -2383,30 +2475,46 @@ def scan(text, depth, from_file=False):
|
|
|
2383
2475
|
# disqualifies the override rather than supplying it.
|
|
2384
2476
|
if ambient_override and not inline_override:
|
|
2385
2477
|
continue
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2478
|
+
declaration_args = before_end_of_options(args)
|
|
2479
|
+
inline_texts = []
|
|
2480
|
+
github_issue = signature == "gh issue create"
|
|
2481
|
+
if github_issue:
|
|
2482
|
+
declaration_args, inline_texts, body_paths = github_issue_declarations(declaration_args)
|
|
2483
|
+
# GitHub issue creation uses the selected body, not the HTTP
|
|
2484
|
+
# request options shared by other tracker commands.
|
|
2485
|
+
submitted, missing_payload = "", []
|
|
2486
|
+
repositories = flag_values(declaration_args, REPO_FLAGS)
|
|
2487
|
+
target_repo = normalise_repo(repositories[-1]) if repositories else None
|
|
2488
|
+
else:
|
|
2489
|
+
body_paths = flag_values(declaration_args, BODY_FILE_FLAGS)
|
|
2490
|
+
target_repo = target_repository(args)
|
|
2491
|
+
roles, target = roles_for(target_repo)
|
|
2492
|
+
state_role_ok = (
|
|
2493
|
+
not github_issue and tracker in STATE_ROLE_TRACKERS and target is None
|
|
2494
|
+
)
|
|
2495
|
+
file_texts, unreadable = read_body_files(body_paths, cwd)
|
|
2496
|
+
body_texts = [*inline_texts, *file_texts]
|
|
2497
|
+
if declares_readiness(declaration_args, roles, body_texts, submitted, state_role_ok):
|
|
2389
2498
|
continue
|
|
2390
2499
|
# The container arm. Checked after readiness, so it adds a
|
|
2391
2500
|
# compliant filing where none existed and takes none away where one
|
|
2392
2501
|
# already did. `text` joins the scan only for a creation found
|
|
2393
2502
|
# INSIDE a file, where the declaration lives in the same file as
|
|
2394
2503
|
# the create it answers for.
|
|
2395
|
-
if
|
|
2396
|
-
|
|
2397
|
-
):
|
|
2504
|
+
texts = (*body_texts, submitted, text) if from_file else (*body_texts, submitted)
|
|
2505
|
+
if declares_container(declaration_args, texts):
|
|
2398
2506
|
continue
|
|
2399
2507
|
# `LIFECYCLE_ROLE=ready curl …` puts the declaration BEFORE the
|
|
2400
2508
|
# client, which is where an inline assignment has to go, so the
|
|
2401
2509
|
# role is read from the whole segment rather than from the client's
|
|
2402
2510
|
# own arguments. Scoped to the segment and not the command, so a
|
|
2403
2511
|
# declaration cannot be shouted from an unrelated pipeline stage.
|
|
2404
|
-
if state_role_ok and LIFECYCLE_ROLE_READY.search(" ".join(argv)):
|
|
2512
|
+
if state_role_ok and LIFECYCLE_ROLE_READY.search(" ".join(argv[:index])):
|
|
2405
2513
|
continue
|
|
2406
2514
|
# A script declares once, for itself. See `scope_declaration`.
|
|
2407
2515
|
if from_file and scope_declaration(text, state_role_ok):
|
|
2408
2516
|
continue
|
|
2409
|
-
return signature, roles, target
|
|
2517
|
+
return signature, roles, target, next(iter([*missing_payload, *unreadable]), None)
|
|
2410
2518
|
|
|
2411
2519
|
for operand in nested_operands(argv):
|
|
2412
2520
|
if depth >= MAX_NESTING_DEPTH:
|
|
@@ -2418,9 +2526,10 @@ def scan(text, depth, from_file=False):
|
|
|
2418
2526
|
"a tracker creation nested past the inspection depth",
|
|
2419
2527
|
[ready_role],
|
|
2420
2528
|
None,
|
|
2529
|
+
None,
|
|
2421
2530
|
)
|
|
2422
2531
|
continue
|
|
2423
|
-
nested = scan(operand, depth + 1)
|
|
2532
|
+
nested = scan(operand, depth + 1, cwd=cwd)
|
|
2424
2533
|
if nested is not None:
|
|
2425
2534
|
return nested
|
|
2426
2535
|
|
|
@@ -2435,24 +2544,29 @@ def scan(text, depth, from_file=False):
|
|
|
2435
2544
|
# review before it shipped.
|
|
2436
2545
|
if ambient_override and not inline_override:
|
|
2437
2546
|
continue
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2547
|
+
path, unresolved = file_operand(argv, cwd)
|
|
2548
|
+
if unresolved:
|
|
2549
|
+
return "a script whose working directory could not be determined", [], None, None
|
|
2550
|
+
if path is None:
|
|
2551
|
+
continue
|
|
2552
|
+
contents = read_operand(path)
|
|
2553
|
+
if not contents:
|
|
2554
|
+
continue
|
|
2555
|
+
if depth >= MAX_NESTING_DEPTH:
|
|
2556
|
+
if GRAPHQL_CREATE.search(contents) or UNPARSEABLE_CREATION.search(
|
|
2557
|
+
contents
|
|
2558
|
+
):
|
|
2559
|
+
return (
|
|
2560
|
+
"a tracker creation inside %s, nested past the "
|
|
2561
|
+
"inspection depth" % path,
|
|
2562
|
+
[ready_role],
|
|
2563
|
+
None,
|
|
2564
|
+
None,
|
|
2565
|
+
)
|
|
2566
|
+
continue
|
|
2567
|
+
found = file_creation(contents, depth, cwd)
|
|
2568
|
+
if found is not None:
|
|
2569
|
+
return ("%s inside %s" % (found[0], path), *found[1:])
|
|
2456
2570
|
return None
|
|
2457
2571
|
|
|
2458
2572
|
|
|
@@ -2481,6 +2595,8 @@ def remedy_for(signature):
|
|
|
2481
2595
|
Returns:
|
|
2482
2596
|
A key the shell half maps to a paragraph, or an empty string.
|
|
2483
2597
|
"""
|
|
2598
|
+
if signature.startswith("a script whose working directory"):
|
|
2599
|
+
return "unresolved-script"
|
|
2484
2600
|
if signature.startswith("an unparseable command"):
|
|
2485
2601
|
return "unparseable"
|
|
2486
2602
|
if " inside " in signature:
|
|
@@ -2490,7 +2606,7 @@ def remedy_for(signature):
|
|
|
2490
2606
|
|
|
2491
2607
|
found = scan(command, 0)
|
|
2492
2608
|
if found is not None:
|
|
2493
|
-
signature, roles, target = found
|
|
2609
|
+
signature, roles, target, missing_body = found
|
|
2494
2610
|
# Key=value lines rather than one delimited string: a signature contains
|
|
2495
2611
|
# spaces and slashes, and a role may contain a colon, so anything the shell
|
|
2496
2612
|
# would have to split on appears inside a value already.
|
|
@@ -2499,6 +2615,8 @@ if found is not None:
|
|
|
2499
2615
|
print("roles=%s" % ", ".join(role for role in roles if role))
|
|
2500
2616
|
print("target=%s" % (target or ""))
|
|
2501
2617
|
print("remedy=%s" % remedy_for(signature))
|
|
2618
|
+
if missing_body is not None:
|
|
2619
|
+
print("body_file=%s" % json.dumps(missing_body))
|
|
2502
2620
|
sys.exit(0)
|
|
2503
2621
|
|
|
2504
2622
|
print("ALLOW")
|
|
@@ -2582,6 +2700,7 @@ verdict="$(
|
|
|
2582
2700
|
LISA_GUARD_CALLER_IS_GITHUB="$caller_is_github" \
|
|
2583
2701
|
LISA_GUARD_TRACKER="$tracker" \
|
|
2584
2702
|
LISA_GUARD_PROJECT_DIR="$project_dir" \
|
|
2703
|
+
LISA_GUARD_TOOL_CWD="$tool_cwd" \
|
|
2585
2704
|
python3 -
|
|
2586
2705
|
)"
|
|
2587
2706
|
python_status=$?
|
|
@@ -2604,7 +2723,8 @@ case "$verdict" in
|
|
|
2604
2723
|
"$(verdict_field signature)" \
|
|
2605
2724
|
"$(verdict_field roles)" \
|
|
2606
2725
|
"$(verdict_field target)" \
|
|
2607
|
-
"$(verdict_field remedy)"
|
|
2726
|
+
"$(verdict_field remedy)" \
|
|
2727
|
+
"$(verdict_field body_file)"
|
|
2608
2728
|
;;
|
|
2609
2729
|
esac
|
|
2610
2730
|
|