@sema-agent/server 7.133.0 → 7.135.0
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/MIGRATION.md +221 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/USAGE.md +222 -36
- package/deploy/sema-up/README.md +16 -0
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
- package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +14 -0
- package/deploy/sema-up/chart/templates/server.yaml +14 -0
- package/deploy/sema-up/chart/values-full-single.yaml +5 -1
- package/deploy/sema-up/chart/values.yaml +34 -0
- package/dist/adoption/plan.d.ts +1 -1
- package/dist/approval-ask-audit-store.d.ts +25 -25
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +66 -154
- package/dist/approval-card.js +33 -52
- package/dist/approval-content-kind.d.ts +26 -6
- package/dist/approval-content-kind.js +23 -3
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-gate-currency.d.ts +91 -0
- package/dist/approval-gate-currency.js +120 -0
- package/dist/approval-hmac.d.ts +7 -7
- package/dist/approval-policy-settlement.d.ts +2 -2
- package/dist/approval-reconciler.d.ts +3 -3
- package/dist/approval.d.ts +14 -8
- package/dist/approval.js +35 -16
- package/dist/auth-bridge.d.ts +1 -1
- package/dist/auto-mode-face.d.ts +4 -4
- package/dist/background-session-reap.d.ts +2 -2
- package/dist/bake-runner/main.d.ts +2 -2
- package/dist/bake-runner/runner.d.ts +4 -4
- package/dist/bench/s1/live-deps.d.ts +1 -1
- package/dist/bench/s1/run-firm.d.ts +1 -1
- package/dist/boot/coordinators.d.ts +7 -2
- package/dist/boot/coordinators.js +8 -5
- package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
- package/dist/boot/deferred-sandbox-path-env.js +0 -5
- package/dist/boot/engine-lease.d.ts +5 -5
- package/dist/boot/execution-env.d.ts +16 -15
- package/dist/boot/execution-env.js +19 -21
- package/dist/boot/fatal-exit.d.ts +2 -2
- package/dist/boot/late-binds.d.ts +1 -1
- package/dist/boot/leader.d.ts +2 -0
- package/dist/boot/leader.js +2 -1
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +15 -15
- package/dist/boot/parked-revive-gate.d.ts +3 -3
- package/dist/boot/parked-revive-gate.js +3 -2
- package/dist/boot/read-deny-anchor-audit.js +2 -2
- package/dist/boot/reapers.d.ts +4 -4
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +28 -24
- package/dist/boot/runner-deps.d.ts +29 -16
- package/dist/boot/runner-deps.js +12 -2
- package/dist/boot/session-faces.d.ts +3 -3
- package/dist/boot/session-faces.js +11 -30
- package/dist/boot/shutdown.d.ts +5 -5
- package/dist/boot/side-query-lane.d.ts +2 -2
- package/dist/boot/stage-05-execution-env.js +4 -4
- package/dist/boot/stage-06-runners.d.ts +4 -3
- package/dist/boot/stage-06-runners.js +15 -4
- package/dist/boot/stage-07-capability-layer.d.ts +2 -1
- package/dist/boot/stage-08-reapers.d.ts +2 -1
- package/dist/boot/stage-09-leader.d.ts +2 -1
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +2 -1
- package/dist/boot/stage-10-http-server.js +2 -1
- package/dist/boot/stores.d.ts +8 -0
- package/dist/boot/stores.js +10 -13
- package/dist/boot/web-admin.d.ts +21 -15
- package/dist/boot/web-admin.js +16 -12
- package/dist/boot/workflow-orchestration.js +2 -9
- package/dist/brain.d.ts +11 -11
- package/dist/budget.d.ts +4 -4
- package/dist/budget.js +5 -1
- package/dist/caller-text-echo.d.ts +2 -0
- package/dist/caller-text-echo.js +2 -1
- package/dist/canonical-json.d.ts +2 -41
- package/dist/canonical-json.js +2 -13
- package/dist/capabilities/approvals-push.d.ts +4 -4
- package/dist/capabilities/builtin-tools.d.ts +5 -5
- package/dist/capabilities/center-plugins.d.ts +5 -5
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +1 -1
- package/dist/capabilities/center-wiring.d.ts +1 -1
- package/dist/capabilities/composite-members.d.ts +2 -2
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/execution-lane.d.ts +5 -5
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +5 -5
- package/dist/capabilities/mcp-probe.d.ts +10 -7
- package/dist/capabilities/mcp-probe.js +2 -2
- package/dist/capabilities/sandbox-file-send.d.ts +1 -18
- package/dist/capabilities/sandbox-file-send.js +0 -7
- package/dist/capabilities/scenarios.d.ts +28 -10
- package/dist/capabilities/scenarios.js +15 -5
- package/dist/capabilities/send-user-file-tool.d.ts +1 -1
- package/dist/capabilities/skills.d.ts +31 -12
- package/dist/capabilities/skills.js +23 -17
- package/dist/capabilities/tool-defer.d.ts +1 -1
- package/dist/capability-facts.d.ts +27 -24
- package/dist/capability-facts.js +18 -20
- package/dist/center-config-tier.d.ts +1 -1
- package/dist/center-credential.d.ts +4 -4
- package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
- package/dist/checkpoint-ctx-seal-m28.js +19 -0
- package/dist/checkpoint-identity.d.ts +5 -0
- package/dist/checkpoint-identity.js +14 -0
- package/dist/config-catalog.d.ts +12 -12
- package/dist/config-invariants.d.ts +4 -4
- package/dist/config-invariants.js +3 -2
- package/dist/config-lkg.d.ts +1 -1
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +2 -1
- package/dist/config-types.d.ts +83 -83
- package/dist/config.d.ts +26 -24
- package/dist/config.js +12 -10
- package/dist/cross-session-settings.d.ts +1 -1
- package/dist/delegated-session-owner.d.ts +16 -13
- package/dist/delegated-session-owner.js +9 -10
- package/dist/deployment-governance.d.ts +16 -16
- package/dist/deployment-shape.d.ts +127 -0
- package/dist/deployment-shape.js +72 -0
- package/dist/device-store.d.ts +1 -1
- package/dist/device-ws-hub.d.ts +1 -1
- package/dist/egress-redirect.d.ts +1 -1
- package/dist/entry-mode-clamp-notice.d.ts +2 -2
- package/dist/env-facts.d.ts +10 -9
- package/dist/env-facts.js +1 -1
- package/dist/env-name-allowlist-knobs.d.ts +5 -5
- package/dist/exec-bounds.d.ts +2 -2
- package/dist/execution-lane-caps.d.ts +31 -43
- package/dist/execution-lane-caps.js +0 -13
- package/dist/field-conflict.d.ts +2 -1
- package/dist/field-conflict.js +1 -0
- package/dist/file-history-capture.d.ts +9 -9
- package/dist/file-history-disclosure.d.ts +50 -9
- package/dist/file-history-disclosure.js +8 -13
- package/dist/fleet/drain-entry.d.ts +2 -2
- package/dist/fleet/fleet-bus.d.ts +26 -14
- package/dist/fleet/fleet-bus.js +6 -5
- package/dist/fleet/fleet-reconciler.d.ts +9 -9
- package/dist/fleet/subagent-tail-bus.d.ts +4 -4
- package/dist/fleet-client.d.ts +13 -13
- package/dist/fleet-lease.d.ts +16 -16
- package/dist/governance-http-status.d.ts +2 -2
- package/dist/hooks/hook-llm.d.ts +7 -7
- package/dist/hooks/hook-runner.d.ts +57 -30
- package/dist/hooks/hook-runner.js +38 -20
- package/dist/host-decision.d.ts +5 -5
- package/dist/host-lsp-manager.d.ts +5 -5
- package/dist/hosted-posture.d.ts +23 -13
- package/dist/hosted-posture.js +4 -9
- package/dist/http/admission.d.ts +2 -2
- package/dist/http/admission.js +28 -5
- package/dist/http/approval-sweeps.d.ts +1 -1
- package/dist/http/approval-sweeps.js +5 -2
- package/dist/http/checkpoint-ctx.d.ts +183 -2
- package/dist/http/checkpoint-ctx.js +197 -2
- package/dist/http/dispatch.d.ts +3 -3
- package/dist/http/dispatch.js +3 -3
- package/dist/http/durable-run-leg.js +7 -5
- package/dist/http/idempotency.d.ts +4 -4
- package/dist/http/idempotency.js +2 -2
- package/dist/http/mcp-dial-deadline.d.ts +7 -5
- package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
- package/dist/http/owner-access.d.ts +4 -6
- package/dist/http/owner-access.js +1 -1
- package/dist/http/principal-gate.d.ts +39 -13
- package/dist/http/principal-gate.js +30 -6
- package/dist/http/readiness.d.ts +1 -1
- package/dist/http/refusal-body.d.ts +12 -0
- package/dist/http/refusal-body.js +11 -0
- package/dist/http/request-guards.d.ts +4 -13
- package/dist/http/request-guards.js +4 -17
- package/dist/http/resume-ctx-read.d.ts +53 -6
- package/dist/http/resume-ctx-read.js +26 -3
- package/dist/http/resume-legs.d.ts +5 -4
- package/dist/http/resume-legs.js +47 -29
- package/dist/http/route-ctx.d.ts +29 -38
- package/dist/http/route-table.d.ts +9 -9
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.d.ts +5 -5
- package/dist/http/routes/approvals-assistant.js +91 -17
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/background.js +2 -2
- package/dist/http/routes/capabilities.d.ts +1 -1
- package/dist/http/routes/capabilities.js +16 -8
- package/dist/http/routes/config-catalog.d.ts +1 -1
- package/dist/http/routes/devices.d.ts +1 -1
- package/dist/http/routes/diagnostics.d.ts +6 -6
- package/dist/http/routes/diagnostics.js +1 -1
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/fleet.js +5 -4
- package/dist/http/routes/mcp-reconnect.d.ts +4 -4
- package/dist/http/routes/mcp-reconnect.js +3 -3
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/notify-wake.d.ts +1 -1
- package/dist/http/routes/notify-wake.js +2 -2
- package/dist/http/routes/rules.d.ts +1 -1
- package/dist/http/routes/rules.js +4 -4
- package/dist/http/routes/runs.js +44 -11
- package/dist/http/routes/session-sync.d.ts +3 -2
- package/dist/http/routes/session-sync.js +109 -62
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions-list.js +4 -5
- package/dist/http/routes/sessions.js +34 -48
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/tasks.js +21 -16
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/trace-usage.js +7 -9
- package/dist/http/routes/workflows.d.ts +3 -0
- package/dist/http/routes/workflows.js +31 -28
- package/dist/http/send.d.ts +5 -5
- package/dist/http/server.d.ts +39 -33
- package/dist/http/server.js +5 -2
- package/dist/http/session-inherit-env.d.ts +3 -3
- package/dist/http/sse-lifecycle.d.ts +1 -1
- package/dist/http/sse-log.d.ts +2 -2
- package/dist/http/submit-ctx.d.ts +4 -3
- package/dist/http/submit-ctx.js +19 -3
- package/dist/http/sync-submit-body.d.ts +1 -1
- package/dist/http/verify-rounds.d.ts +1 -1
- package/dist/http/wire-types.d.ts +35 -24
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/instruction-source-notice.d.ts +2 -2
- package/dist/key-resolver.d.ts +3 -3
- package/dist/lane-home-probe.d.ts +1 -1
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/leader/diffup.d.ts +2 -2
- package/dist/leader/endpoint.d.ts +1 -1
- package/dist/leader/fanout.d.ts +1 -1
- package/dist/leader/leader.d.ts +4 -4
- package/dist/leader/merge.d.ts +3 -3
- package/dist/leader/repair-wire.d.ts +1 -1
- package/dist/leader/wire.d.ts +9 -5
- package/dist/leader/wire.js +8 -7
- package/dist/list-entry-display.d.ts +1 -1
- package/dist/lsp-evict.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +1 -1
- package/dist/memory-layer-legacy-lock.d.ts +1 -1
- package/dist/memory-operator-faces.d.ts +1 -1
- package/dist/memory-origin-fence.js +2 -2
- package/dist/memory-posture.js +4 -2
- package/dist/memory-project-layer.d.ts +1 -1
- package/dist/memory-scope.d.ts +19 -19
- package/dist/memory-store-refusal.d.ts +4 -4
- package/dist/model-compat.d.ts +1 -1
- package/dist/model-entry-headers.d.ts +2 -2
- package/dist/model-entry-refusal.d.ts +17 -17
- package/dist/model-provider.d.ts +10 -10
- package/dist/model-reach-scope.d.ts +1 -1
- package/dist/model-route-endpoint.d.ts +6 -6
- package/dist/model-route-url.d.ts +5 -5
- package/dist/model-select.d.ts +15 -6
- package/dist/model-select.js +5 -0
- package/dist/model-unreachable-notice.d.ts +3 -3
- package/dist/namespaced-rule-name.d.ts +15 -5
- package/dist/namespaced-rule-name.js +3 -2
- package/dist/observability/corrupt-read-seat.d.ts +9 -9
- package/dist/observability/cost-taxonomy.d.ts +1 -1
- package/dist/observability/err-text.d.ts +1 -1
- package/dist/observability/fail-open.d.ts +12 -8
- package/dist/observability/fail-open.js +12 -8
- package/dist/observability/metrics.d.ts +3 -3
- package/dist/observability/prompt-manifest.d.ts +19 -8
- package/dist/observability/prompt-manifest.js +9 -8
- package/dist/observability/run-terminal.d.ts +36 -36
- package/dist/observability/secret-env-scrub.d.ts +3 -3
- package/dist/observability/tool-trace.d.ts +1 -1
- package/dist/observability/tool-trace.js +8 -9
- package/dist/operator-ask.d.ts +4 -4
- package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
- package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
- package/dist/orchestration/workflow-completion-inbox.js +29 -7
- package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
- package/dist/orchestration/workflow-notify-journal.js +17 -0
- package/dist/orchestration/workflow-park-decision.d.ts +1 -1
- package/dist/orchestration/workflow-park-decision.js +1 -0
- package/dist/outbound-dispatcher.d.ts +4 -4
- package/dist/parent-watch.d.ts +4 -4
- package/dist/parked-decide.d.ts +20 -20
- package/dist/parked-decide.js +8 -5
- package/dist/parked-revive-surface.d.ts +7 -7
- package/dist/parked-revive-surface.js +2 -3
- package/dist/peer-directory.d.ts +3 -3
- package/dist/peer-directory.js +1 -1
- package/dist/permission-rule-list.d.ts +10 -1
- package/dist/permission-rule-list.js +7 -5
- package/dist/permission-rule-vocab.d.ts +3 -25
- package/dist/permission-rule-vocab.js +0 -13
- package/dist/plugins/adoption-log-sql.d.ts +1 -1
- package/dist/plugins/approval-ask-store-file.d.ts +8 -1
- package/dist/plugins/approval-ask-store-file.js +6 -3
- package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
- package/dist/plugins/approval-ask-store-memory.js +11 -7
- package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
- package/dist/plugins/approval-ask-store-sql.js +18 -5
- package/dist/plugins/approval-exemption-store.d.ts +3 -3
- package/dist/plugins/approval-nonce-store.d.ts +3 -3
- package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
- package/dist/plugins/approval-payload-fingerprint.js +1 -1
- package/dist/plugins/background-agent-store-sql.d.ts +1 -1
- package/dist/plugins/background-shell-support.d.ts +2 -2
- package/dist/plugins/blob-backend.d.ts +1 -1
- package/dist/plugins/caching-session-store.d.ts +24 -33
- package/dist/plugins/caching-session-store.js +8 -19
- package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
- package/dist/plugins/checkpoint-index-columns.js +62 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +66 -67
- package/dist/plugins/checkpoint-store-sql.js +100 -103
- package/dist/plugins/device-store-sql.d.ts +7 -6
- package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
- package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
- package/dist/plugins/file-history-store-sql.d.ts +9 -7
- package/dist/plugins/file-history-store-sql.js +27 -15
- package/dist/plugins/file-run-store.d.ts +8 -8
- package/dist/plugins/fork-routing-session-store.d.ts +2 -2
- package/dist/plugins/fork-routing-session-store.js +1 -1
- package/dist/plugins/host-platform.d.ts +10 -10
- package/dist/plugins/image-bake-store-sql.d.ts +1 -1
- package/dist/plugins/image-index-sql.d.ts +1 -1
- package/dist/plugins/leader-run-store-sql.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.d.ts +23 -12
- package/dist/plugins/local-checkpoint-store.js +29 -4
- package/dist/plugins/local-session-store.d.ts +44 -45
- package/dist/plugins/local-session-store.js +42 -52
- package/dist/plugins/local-session-window.d.ts +12 -6
- package/dist/plugins/local-session-window.js +1 -17
- package/dist/plugins/mailbox-store-sql.d.ts +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +1 -1
- package/dist/plugins/memory-run-store.d.ts +4 -4
- package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +76 -39
- package/dist/plugins/one-time-migrations.js +127 -34
- package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
- package/dist/plugins/park-commit-watch.d.ts +3 -3
- package/dist/plugins/permission-rule-store-file.d.ts +5 -5
- package/dist/plugins/permission-rule-store-file.js +16 -19
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
- package/dist/plugins/permission-rule-store-sql.js +74 -31
- package/dist/plugins/pg-cost-quota.d.ts +1 -1
- package/dist/plugins/pg-pool.d.ts +2 -2
- package/dist/plugins/pg-pool.js +5 -2
- package/dist/plugins/pg-rate-limiter.d.ts +1 -1
- package/dist/plugins/pg-session-storage.d.ts +9 -21
- package/dist/plugins/pg-session-storage.js +51 -42
- package/dist/plugins/remote-env-adb.d.ts +10 -10
- package/dist/plugins/remote-env-device.d.ts +22 -14
- package/dist/plugins/remote-env-device.js +28 -16
- package/dist/plugins/remote-env-e2b.d.ts +3 -3
- package/dist/plugins/remote-env-host.d.ts +16 -16
- package/dist/plugins/remote-env-k8s.d.ts +8 -8
- package/dist/plugins/remote-env-local-docker.d.ts +2 -2
- package/dist/plugins/remote-env-ssh.d.ts +4 -4
- package/dist/plugins/remote-scratchpad.d.ts +2 -3
- package/dist/plugins/remote-scratchpad.js +0 -4
- package/dist/plugins/remote-shell.d.ts +6 -6
- package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
- package/dist/plugins/retention-store-sql.d.ts +4 -4
- package/dist/plugins/roster-store-sql.d.ts +1 -1
- package/dist/plugins/run-store-sql.d.ts +8 -8
- package/dist/plugins/schema-consistency.d.ts +2 -2
- package/dist/plugins/schema-ensure-legs.d.ts +3 -3
- package/dist/plugins/schema-indexes.d.ts +1 -1
- package/dist/plugins/schema-live-columns.d.ts +1 -1
- package/dist/plugins/session-event-payload.d.ts +4 -4
- package/dist/plugins/session-fork.d.ts +34 -0
- package/dist/plugins/session-fork.js +29 -0
- package/dist/plugins/session-ownership.d.ts +11 -0
- package/dist/plugins/session-ownership.js +11 -0
- package/dist/plugins/session-placement.d.ts +12 -14
- package/dist/plugins/session-placement.js +2 -15
- package/dist/plugins/session-policy-store-sql.d.ts +12 -12
- package/dist/plugins/session-store.d.ts +2 -2
- package/dist/plugins/session-store.js +2 -2
- package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
- package/dist/plugins/sql-driver.d.ts +8 -8
- package/dist/plugins/sql-errors.d.ts +1 -1
- package/dist/plugins/sql-json-column.d.ts +21 -21
- package/dist/plugins/sql-row-helpers.d.ts +2 -2
- package/dist/plugins/store-backend.d.ts +17 -16
- package/dist/plugins/store-backend.js +3 -3
- package/dist/plugins/store-contracts.d.ts +21 -21
- package/dist/plugins/task-attachment-store.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.d.ts +1 -1
- package/dist/plugins/tidb-pool.d.ts +2 -2
- package/dist/plugins/tidb-pool.js +9 -2
- package/dist/plugins/tidb-session-store.d.ts +17 -27
- package/dist/plugins/tidb-session-store.js +52 -42
- package/dist/plugins/tool-result-store-sql.d.ts +1 -1
- package/dist/plugins/usage-window-store-sql.d.ts +3 -3
- package/dist/plugins/user-input-ledger-file.d.ts +1 -1
- package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
- package/dist/plugins/web-search.d.ts +19 -5
- package/dist/plugins/web-search.js +19 -4
- package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
- package/dist/plugins/workflow-journal-payload.js +32 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
- package/dist/plugins/workflow-journal-store-sql.js +34 -15
- package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
- package/dist/posture-source.d.ts +11 -11
- package/dist/principal-jwt.d.ts +6 -6
- package/dist/project-identity.d.ts +3 -3
- package/dist/project-memory.d.ts +4 -4
- package/dist/read-face-posture.d.ts +7 -7
- package/dist/request-key-closure.d.ts +1 -1
- package/dist/request-key-closure.js +1 -1
- package/dist/request-tool-axes.d.ts +12 -0
- package/dist/request-tool-axes.js +20 -0
- package/dist/request-value-closure.d.ts +15 -8
- package/dist/request-value-closure.js +2 -0
- package/dist/router/route-orchestration.d.ts +11 -16
- package/dist/router/route-orchestration.js +2 -12
- package/dist/rule-entry-list.d.ts +8 -7
- package/dist/rule-entry-list.js +2 -9
- package/dist/rules-consent.d.ts +6 -6
- package/dist/rules-consent.js +2 -0
- package/dist/run-cancel-context.d.ts +5 -5
- package/dist/run-local.d.ts +10 -10
- package/dist/run-local.js +1 -0
- package/dist/runs.d.ts +15 -12
- package/dist/runs.js +19 -4
- package/dist/runtime-caps-resolver.d.ts +6 -6
- package/dist/runtime-governance.d.ts +9 -9
- package/dist/sandbox-pkg-source.d.ts +9 -31
- package/dist/sandbox-pkg-source.js +14 -8
- package/dist/sealed-key.d.ts +34 -2
- package/dist/sealed-key.js +55 -1
- package/dist/security.d.ts +31 -32
- package/dist/security.js +12 -9
- package/dist/server-secret-env.d.ts +10 -10
- package/dist/session-children-retire.d.ts +1 -1
- package/dist/session-error-wire.d.ts +19 -12
- package/dist/session-error-wire.js +4 -1
- package/dist/session-incarnation.d.ts +52 -35
- package/dist/session-incarnation.js +23 -8
- package/dist/session-policy-wire.d.ts +27 -5
- package/dist/session-policy-wire.js +15 -1
- package/dist/session-records-skipped-notice.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +38 -11
- package/dist/session-sync-kernel.js +10 -0
- package/dist/session-sync.d.ts +49 -6
- package/dist/session-sync.js +52 -10
- package/dist/session-titler.d.ts +7 -6
- package/dist/session-titler.js +8 -13
- package/dist/session-watch.d.ts +3 -3
- package/dist/session-watch.js +4 -4
- package/dist/sighup-idle.d.ts +2 -2
- package/dist/spec-fields.d.ts +4 -4
- package/dist/sql-engine-posture.d.ts +3 -3
- package/dist/store-posture.d.ts +2 -2
- package/dist/stored-request-tool-axes-m19.d.ts +1 -1
- package/dist/task-a2a.d.ts +3 -1
- package/dist/task-a2a.js +38 -5
- package/dist/task-cwd.d.ts +7 -88
- package/dist/task-cwd.js +2 -15
- package/dist/task-mcp.d.ts +14 -10
- package/dist/task-mcp.js +39 -12
- package/dist/task-settings.d.ts +34 -18
- package/dist/task-settings.js +34 -4
- package/dist/task-workflow.d.ts +0 -24
- package/dist/task-workflow.js +2 -1
- package/dist/terminal.d.ts +5 -5
- package/dist/tighten-only-seats.d.ts +7 -6
- package/dist/tighten-only-seats.js +1 -1
- package/dist/tool-approval.d.ts +273 -228
- package/dist/tool-approval.js +125 -47
- package/dist/tool-rule-names.d.ts +7 -1
- package/dist/trace/core-keyset-guard.d.ts +15 -9
- package/dist/trace/engine-notice-wire.d.ts +5 -5
- package/dist/trace/engine-notice-wire.js +1 -0
- package/dist/trace/exit-seat.d.ts +40 -1
- package/dist/trace/exit-seat.js +46 -14
- package/dist/trace/ledger-events.d.ts +6 -4
- package/dist/trace/ledger-sink.d.ts +1 -1
- package/dist/trace/model-segment.d.ts +3 -3
- package/dist/trace/project.d.ts +65 -46
- package/dist/trace/project.js +49 -5
- package/dist/trace/redact.d.ts +44 -27
- package/dist/trace/redact.js +343 -73
- package/dist/trace/self-minted-wire.d.ts +39 -14
- package/dist/trace/self-minted-wire.js +9 -0
- package/dist/trace/sema-provenance.d.ts +1 -1
- package/dist/trace/task-notification-facets.d.ts +4 -4
- package/dist/trace/wire-projection-faces.d.ts +9 -3
- package/dist/trace/wire-projection-faces.js +7 -1
- package/dist/unattended-permission-mode.d.ts +5 -5
- package/dist/url-credential.d.ts +52 -0
- package/dist/url-credential.js +49 -0
- package/dist/url-refusal.d.ts +6 -2
- package/dist/url-refusal.js +8 -1
- package/dist/usage-analytics.d.ts +2 -2
- package/dist/user-input-ledger.d.ts +23 -23
- package/dist/web-admin-client/apply-effective.d.ts +5 -5
- package/dist/web-admin-client/apply-effective.js +2 -1
- package/dist/web-admin-client/apply-ledger.d.ts +2 -2
- package/dist/web-admin-client/center-request.d.ts +2 -2
- package/dist/web-admin-client/facade.d.ts +5 -5
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
- package/dist/web-admin-client/http-client.d.ts +4 -4
- package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
- package/dist/web-admin-client/pull-state.d.ts +1 -1
- package/dist/web-admin-client/read-face.d.ts +2 -2
- package/dist/web-admin-client/read-warnings.d.ts +5 -5
- package/dist/web-admin-client/restart-signal.d.ts +6 -6
- package/dist/web-admin-client/skills-mcp.d.ts +29 -4
- package/dist/web-admin-client/skills-mcp.js +31 -4
- package/dist/web-admin-client/types.d.ts +17 -10
- package/dist/workspace-space.d.ts +5 -3
- package/dist/write-protection.d.ts +2 -2
- package/package.json +4 -3
- package/scripts/drain-check-local.mjs +35 -2
- package/scripts/drain-check.mysql.sql +22 -2
- package/scripts/drain-check.pg.sql +22 -2
- package/skills/loop.md +1 -1
- package/dist/mcp-tool-faces.d.ts +0 -69
- package/dist/mcp-tool-faces.js +0 -104
- package/dist/orchestration/workflow-journal-entry.js +0 -27
package/dist/trace/redact.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { displayUrlOf, stripFormatCharacters } from "@sema-agent/core";
|
|
2
|
-
import { isHierarchicalUrl } from "@sema-agent/settings-schema";
|
|
2
|
+
import { CONTROL_AND_BIDI_CHARS, isHierarchicalUrl } from "@sema-agent/settings-schema";
|
|
3
3
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
4
4
|
const normalizeForRedaction = stripFormatCharacters;
|
|
5
5
|
export function mapNormalizedToOriginal(text, normalized) {
|
|
@@ -28,6 +28,185 @@ export function mapNormalizedToOriginal(text, normalized) {
|
|
|
28
28
|
map[normalized.length] = text.length;
|
|
29
29
|
return map;
|
|
30
30
|
}
|
|
31
|
+
const SPELLED_FORMAT = 1, SPELLED_CONTROL = 2, RAW_CONTROL = 4, RAW_WHITESPACE = 8;
|
|
32
|
+
const INVISIBLE_UNIT_CLASS = (() => {
|
|
33
|
+
const inSet = new RegExp(`[${CONTROL_AND_BIDI_CHARS}]`);
|
|
34
|
+
const table = new Uint8Array(0x10000);
|
|
35
|
+
for (let unit = 0; unit < table.length; unit++) {
|
|
36
|
+
const ch = String.fromCharCode(unit);
|
|
37
|
+
if (inSet.test(ch))
|
|
38
|
+
table[unit] = /\s/.test(ch) ? 2 : 1;
|
|
39
|
+
}
|
|
40
|
+
return table;
|
|
41
|
+
})();
|
|
42
|
+
const RAW_STRIP_SET_RE = (() => {
|
|
43
|
+
let body = "";
|
|
44
|
+
for (let unit = 0; unit < 0x10000; unit++) {
|
|
45
|
+
if (INVISIBLE_UNIT_CLASS[unit] === 0)
|
|
46
|
+
continue;
|
|
47
|
+
let last = unit;
|
|
48
|
+
while (last + 1 < 0x10000 && INVISIBLE_UNIT_CLASS[last + 1] !== 0)
|
|
49
|
+
last += 1;
|
|
50
|
+
const hex = (u) => `\\u${u.toString(16).padStart(4, "0")}`;
|
|
51
|
+
body += last === unit ? hex(unit) : `${hex(unit)}-${hex(last)}`;
|
|
52
|
+
unit = last;
|
|
53
|
+
}
|
|
54
|
+
return new RegExp(`[${body}]`, "g");
|
|
55
|
+
})();
|
|
56
|
+
function collectRawControlCuts(s, allowed) {
|
|
57
|
+
const cuts = [];
|
|
58
|
+
let present = 0;
|
|
59
|
+
if ((allowed & (RAW_CONTROL | RAW_WHITESPACE)) === 0)
|
|
60
|
+
return { cuts, present };
|
|
61
|
+
RAW_STRIP_SET_RE.lastIndex = 0;
|
|
62
|
+
for (let m = RAW_STRIP_SET_RE.exec(s); m !== null; m = RAW_STRIP_SET_RE.exec(s)) {
|
|
63
|
+
const cls = INVISIBLE_UNIT_CLASS[s.charCodeAt(m.index)] === 2 ? RAW_WHITESPACE : RAW_CONTROL;
|
|
64
|
+
if ((cls & allowed) === 0)
|
|
65
|
+
continue;
|
|
66
|
+
cuts.push(m.index, m.index + 1, cls);
|
|
67
|
+
present |= cls;
|
|
68
|
+
}
|
|
69
|
+
return { cuts, present };
|
|
70
|
+
}
|
|
71
|
+
function collectSpelledCuts(s) {
|
|
72
|
+
const cuts = [];
|
|
73
|
+
let present = 0;
|
|
74
|
+
let i = s.indexOf("\\");
|
|
75
|
+
if (i < 0)
|
|
76
|
+
return { cuts, present };
|
|
77
|
+
const n = s.length;
|
|
78
|
+
const read = { end: 0 };
|
|
79
|
+
while (i >= 0) {
|
|
80
|
+
let body = i + 1;
|
|
81
|
+
while (body < n && s.charCodeAt(body) === CH_BACKSLASH)
|
|
82
|
+
body += 1;
|
|
83
|
+
const cp = readSpelledCodePoint(s, body, read);
|
|
84
|
+
const cls = cp < 0 ? 0 : isFormatCodePoint(cp) ? SPELLED_FORMAT : cp < 0x10000 && INVISIBLE_UNIT_CLASS[cp] === 1 ? SPELLED_CONTROL : 0;
|
|
85
|
+
if (cls !== 0) {
|
|
86
|
+
cuts.push(i, read.end, cls);
|
|
87
|
+
present |= cls;
|
|
88
|
+
body = read.end;
|
|
89
|
+
}
|
|
90
|
+
i = s.indexOf("\\", body);
|
|
91
|
+
}
|
|
92
|
+
return { cuts, present };
|
|
93
|
+
}
|
|
94
|
+
function deleteInvisibleCharacters(s, all, mask) {
|
|
95
|
+
const atList = [];
|
|
96
|
+
const cumList = [];
|
|
97
|
+
const parts = [];
|
|
98
|
+
let from = 0;
|
|
99
|
+
let removed = 0;
|
|
100
|
+
const { cuts } = all;
|
|
101
|
+
for (let k = 0; k < cuts.length; k += 3) {
|
|
102
|
+
if ((cuts[k + 2] & mask) === 0)
|
|
103
|
+
continue;
|
|
104
|
+
const a = cuts[k];
|
|
105
|
+
const b = cuts[k + 1];
|
|
106
|
+
parts.push(s.slice(from, a));
|
|
107
|
+
atList.push(a - removed);
|
|
108
|
+
removed += b - a;
|
|
109
|
+
cumList.push(removed);
|
|
110
|
+
from = b;
|
|
111
|
+
}
|
|
112
|
+
if (atList.length === 0)
|
|
113
|
+
return { text: s, at: undefined, cum: undefined };
|
|
114
|
+
parts.push(s.slice(from));
|
|
115
|
+
return { text: parts.join(""), at: Int32Array.from(atList), cum: Int32Array.from(cumList) };
|
|
116
|
+
}
|
|
117
|
+
function viewIndexInInput(fold, v) {
|
|
118
|
+
const at = fold.at;
|
|
119
|
+
let lo = 0;
|
|
120
|
+
let hi = at.length;
|
|
121
|
+
while (lo < hi) {
|
|
122
|
+
const mid = (lo + hi) >>> 1;
|
|
123
|
+
if (at[mid] <= v)
|
|
124
|
+
lo = mid + 1;
|
|
125
|
+
else
|
|
126
|
+
hi = mid;
|
|
127
|
+
}
|
|
128
|
+
return lo === 0 ? v : v + fold.cum[lo - 1];
|
|
129
|
+
}
|
|
130
|
+
function readHexRun(s, at, count) {
|
|
131
|
+
let v = 0;
|
|
132
|
+
for (let k = at; k < at + count; k++) {
|
|
133
|
+
const d = hexDigitValue(s.charCodeAt(k));
|
|
134
|
+
if (d < 0)
|
|
135
|
+
return -1;
|
|
136
|
+
v = v * 16 + d;
|
|
137
|
+
}
|
|
138
|
+
return v;
|
|
139
|
+
}
|
|
140
|
+
function readEscapeElement(s, at, out) {
|
|
141
|
+
const kind = s.charCodeAt(at);
|
|
142
|
+
if (kind === CH_x) {
|
|
143
|
+
out.end = at + 3;
|
|
144
|
+
return readHexRun(s, at + 1, 2);
|
|
145
|
+
}
|
|
146
|
+
if (kind !== CH_u)
|
|
147
|
+
return -1;
|
|
148
|
+
if (s.charCodeAt(at + 1) === CH_LBRACE) {
|
|
149
|
+
let v = 0;
|
|
150
|
+
let k = at + 2;
|
|
151
|
+
for (; k < s.length; k++) {
|
|
152
|
+
const d = hexDigitValue(s.charCodeAt(k));
|
|
153
|
+
if (d < 0)
|
|
154
|
+
break;
|
|
155
|
+
v = v * 16 + d;
|
|
156
|
+
if (v > 0x10ffff)
|
|
157
|
+
return -1;
|
|
158
|
+
}
|
|
159
|
+
if (k === at + 2 || s.charCodeAt(k) !== CH_RBRACE)
|
|
160
|
+
return -1;
|
|
161
|
+
out.end = k + 1;
|
|
162
|
+
return v;
|
|
163
|
+
}
|
|
164
|
+
out.end = at + 5;
|
|
165
|
+
return readHexRun(s, at + 1, 4);
|
|
166
|
+
}
|
|
167
|
+
function readSpelledCodePoint(s, at, out) {
|
|
168
|
+
const v = readEscapeElement(s, at, out);
|
|
169
|
+
if (v < 0xd800 || v > 0xdfff)
|
|
170
|
+
return v;
|
|
171
|
+
if (v > 0xdbff)
|
|
172
|
+
return -1;
|
|
173
|
+
let k = out.end;
|
|
174
|
+
if (s.charCodeAt(k) !== CH_BACKSLASH)
|
|
175
|
+
return -1;
|
|
176
|
+
while (s.charCodeAt(k) === CH_BACKSLASH)
|
|
177
|
+
k += 1;
|
|
178
|
+
const lo = readEscapeElement(s, k, out);
|
|
179
|
+
return lo >= 0xdc00 && lo <= 0xdfff ? 0x10000 + ((v - 0xd800) << 10) + (lo - 0xdc00) : -1;
|
|
180
|
+
}
|
|
181
|
+
const FORMAT_CODEPOINT_TABLE = (() => {
|
|
182
|
+
const table = new Uint8Array(0x10000);
|
|
183
|
+
const units = [];
|
|
184
|
+
const codes = [];
|
|
185
|
+
for (let c = 0; c < 0x10000; c++) {
|
|
186
|
+
if (c >= 0xd800 && c <= 0xdfff)
|
|
187
|
+
continue;
|
|
188
|
+
units.push(String.fromCharCode(c));
|
|
189
|
+
codes.push(c);
|
|
190
|
+
}
|
|
191
|
+
const kept = normalizeForRedaction(units.join(""));
|
|
192
|
+
let j = 0;
|
|
193
|
+
for (let i = 0; i < codes.length; i++) {
|
|
194
|
+
if (j < kept.length && kept.charCodeAt(j) === codes[i])
|
|
195
|
+
j += 1;
|
|
196
|
+
else
|
|
197
|
+
table[codes[i]] = 1;
|
|
198
|
+
}
|
|
199
|
+
if (j !== kept.length)
|
|
200
|
+
throw new Error("redact: format-character stripping is not a code-unit deletion over the BMP — refusing to derive the escape-spelled format-character table");
|
|
201
|
+
return table;
|
|
202
|
+
})();
|
|
203
|
+
function isFormatCodePoint(cp) {
|
|
204
|
+
if (cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff))
|
|
205
|
+
return false;
|
|
206
|
+
if (cp >= 0x10000)
|
|
207
|
+
return normalizeForRedaction(String.fromCodePoint(cp)) === "";
|
|
208
|
+
return FORMAT_CODEPOINT_TABLE[cp] === 1;
|
|
209
|
+
}
|
|
31
210
|
export const REDACTION_TOKEN_RE_SRC = String.raw `«redacted(?::[a-z-]{1,16}){0,2}»`;
|
|
32
211
|
const ARM_VALUE_CLASSES = [];
|
|
33
212
|
const atLeast = (cls, min) => {
|
|
@@ -42,7 +221,7 @@ const WORD_INTERIOR_CLASS = "[A-Za-z0-9]";
|
|
|
42
221
|
const CH_TAB = 9, CH_LF = 10, CH_CR = 13, CH_ESC = 27, CH_SPACE = 32, CH_PLUS = 43, CH_MINUS = 45, CH_SLASH = 47;
|
|
43
222
|
const CH_0 = 48, CH_9 = 57, CH_COLON = 58, CH_EQ = 61, CH_AT = 64, CH_A = 65, CH_Z = 90;
|
|
44
223
|
const CH_LBRACKET = 91, CH_BACKSLASH = 92, CH_UNDERSCORE = 95;
|
|
45
|
-
const CH_a = 97, CH_b = 98, CH_f = 102, CH_n = 110, CH_r = 114, CH_t = 116, CH_u = 117, CH_z = 122, CH_TILDE = 126;
|
|
224
|
+
const CH_a = 97, CH_b = 98, CH_f = 102, CH_n = 110, CH_r = 114, CH_t = 116, CH_u = 117, CH_x = 120, CH_z = 122, CH_TILDE = 126;
|
|
46
225
|
const CH_QUOTE = 34;
|
|
47
226
|
const CH_CSI8 = 155;
|
|
48
227
|
const CH_LAQUO = 171;
|
|
@@ -282,8 +461,9 @@ let urlSegmentRuns = 0;
|
|
|
282
461
|
let urlSegmentReplays = 0;
|
|
283
462
|
let ssh2ScanBytes = 0;
|
|
284
463
|
let mappedUnits = 0;
|
|
464
|
+
let readings = 0;
|
|
285
465
|
export function armPoolBudgetForTest() {
|
|
286
|
-
return { spanCount: poolSpanCount, coveredPositions, headScreenHits, fullYCalls, armCount: poolArmCount, boundaryArmCount: poolBoundaryArmCount, forensicLevels, forensicRuns, forensicSkips, urlSegmentRuns, urlSegmentReplays, ssh2ScanBytes, mappedUnits };
|
|
466
|
+
return { spanCount: poolSpanCount, coveredPositions, headScreenHits, fullYCalls, armCount: poolArmCount, boundaryArmCount: poolBoundaryArmCount, forensicLevels, forensicRuns, forensicSkips, urlSegmentRuns, urlSegmentReplays, ssh2ScanBytes, mappedUnits, readings };
|
|
287
467
|
}
|
|
288
468
|
export function resetArmPoolBudgetForTest() {
|
|
289
469
|
poolSpanCount = 0;
|
|
@@ -297,6 +477,7 @@ export function resetArmPoolBudgetForTest() {
|
|
|
297
477
|
urlSegmentReplays = 0;
|
|
298
478
|
ssh2ScanBytes = 0;
|
|
299
479
|
mappedUnits = 0;
|
|
480
|
+
readings = 0;
|
|
300
481
|
}
|
|
301
482
|
const unitBit = (t, c) => (t[c >>> 5] >>> (c & 31)) & 1;
|
|
302
483
|
let codeUnitDomain;
|
|
@@ -632,9 +813,15 @@ function collectStickySpans(a, text, at, out) {
|
|
|
632
813
|
}
|
|
633
814
|
}
|
|
634
815
|
const WORD_SEGMENT_CLASS = "[A-Za-z0-9._~+/-]";
|
|
816
|
+
const SCHEME_DELIMITER_CHARS = "\\\"'`“”|";
|
|
817
|
+
if (/[\]^-]/.test(SCHEME_DELIMITER_CHARS))
|
|
818
|
+
throw new Error("redact: scheme delimiter table holds a character-class metacharacter — the class source is built without escaping it");
|
|
819
|
+
const SCHEME_DELIMITER_CODES = new Set([...SCHEME_DELIMITER_CHARS].map((c) => c.charCodeAt(0)));
|
|
820
|
+
const isSchemeDelimiterCode = (c) => SCHEME_DELIMITER_CODES.has(c);
|
|
821
|
+
const SCHEME_SEPARATOR_CLASS = `[\\s${SCHEME_DELIMITER_CHARS.replace(/\\/g, "\\\\")}]`;
|
|
635
822
|
const LEXICAL_KEYWORD_ARMS = new Set();
|
|
636
|
-
const keywordArm = (keywordSrc, valueClass, min, tailSrc = "") => {
|
|
637
|
-
const re = new RegExp(`(?:${keywordSrc}
|
|
823
|
+
const keywordArm = (keywordSrc, valueClass, min, tailSrc = "", separatorClass = "\\s") => {
|
|
824
|
+
const re = new RegExp(`(?:${keywordSrc}${separatorClass}+${atLeast(valueClass, min)}${tailSrc}` +
|
|
638
825
|
`|(?<!${WORD_SEGMENT_CLASS})${keywordSrc}(?:${twoStrongAhead(valueClass)}|${noConnectorAhead(valueClass)})${atLeast(valueClass, min)}${tailSrc})`, "g");
|
|
639
826
|
LEXICAL_KEYWORD_ARMS.add(re);
|
|
640
827
|
return re;
|
|
@@ -657,6 +844,12 @@ const CREDENTIAL_NAME_ALT = (() => {
|
|
|
657
844
|
}
|
|
658
845
|
return [...CREDENTIAL_NAME_WORDS].sort((a, b) => b.length - a.length || (a < b ? -1 : 1)).join("|");
|
|
659
846
|
})();
|
|
847
|
+
const CREDENTIAL_NAME_MAX = Math.max(...CREDENTIAL_NAME_WORDS.map((w) => w.length));
|
|
848
|
+
const asciiLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
849
|
+
function credentialNameAnchor(name) {
|
|
850
|
+
return CREDENTIAL_ANCHOR_OF.get(asciiLower(name));
|
|
851
|
+
}
|
|
852
|
+
const CREDENTIAL_ANCHOR_OF = new Map(Object.entries(CREDENTIAL_NAME_ANCHORS));
|
|
660
853
|
const STRUCTURAL_SECRET_PATTERNS = [
|
|
661
854
|
[/-----BEGIN(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,8192}?-----END(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----/g, "«redacted:private-key»"],
|
|
662
855
|
[/---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----[\s\S]{0,8192}?---- END SSH2 ENCRYPTED PRIVATE KEY ----/g, "«redacted:private-key»"],
|
|
@@ -668,8 +861,8 @@ const PEM_FRAGMENT_TOKEN = "«redacted:private-key:partial»";
|
|
|
668
861
|
const HEADLESS_PPK_TOKEN = "«redacted:private-key:partial»";
|
|
669
862
|
const ANCHORED_VALUE_TOKEN = "«redacted»";
|
|
670
863
|
const KEYWORD_SECRET_PATTERNS = [
|
|
671
|
-
[keywordArm("[Bb]earer", "[A-Za-z0-9._~+/-]", 20, "=*"), "Bearer «redacted»"],
|
|
672
|
-
[keywordArm("Basic", "[A-Za-z0-9+/]", 16, "={0,2}"), "Basic «redacted»"],
|
|
864
|
+
[keywordArm("[Bb]earer", "[A-Za-z0-9._~+/-]", 20, "=*", SCHEME_SEPARATOR_CLASS), "Bearer «redacted»"],
|
|
865
|
+
[keywordArm("Basic", "[A-Za-z0-9+/]", 16, "={0,2}", SCHEME_SEPARATOR_CLASS), "Basic «redacted»"],
|
|
673
866
|
[keywordArm("[Tt]oken", "[A-Za-z0-9._~+/-]", 20), "token «redacted»"],
|
|
674
867
|
];
|
|
675
868
|
const SK_FULL_ARM_MIN = 20;
|
|
@@ -1249,9 +1442,11 @@ const isRegexSpace = (c) => c === 32 || (c >= 9 && c <= 13) || c === 0xa0 || c =
|
|
|
1249
1442
|
const isLineTerminator = (c) => c === 10 || c === 13 || c === 0x2028 || c === 0x2029;
|
|
1250
1443
|
const isControlCode = (c) => c < 0x20 || c === 0x7f;
|
|
1251
1444
|
const TOKEN_UNIT_Y = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
|
|
1445
|
+
export const CREDENTIAL_PARAM_NAMES = Object.freeze([...CREDENTIAL_NAME_WORDS]);
|
|
1446
|
+
export function isCredentialParamName(decodedName) {
|
|
1447
|
+
return credentialNameAnchor(decodedName) !== undefined;
|
|
1448
|
+
}
|
|
1449
|
+
const CREDENTIAL_NAME_SCAN_MAX = CREDENTIAL_NAME_MAX * 3 + 1;
|
|
1255
1450
|
function decodeAsciiName(name) {
|
|
1256
1451
|
let out = "";
|
|
1257
1452
|
for (let i = 0; i < name.length; i++) {
|
|
@@ -1272,9 +1467,6 @@ function decodeAsciiName(name) {
|
|
|
1272
1467
|
return out;
|
|
1273
1468
|
}
|
|
1274
1469
|
function credentialParamValueStart(text, p) {
|
|
1275
|
-
CREDENTIAL_PARAM_Y.lastIndex = p;
|
|
1276
|
-
if (CREDENTIAL_PARAM_Y.test(text))
|
|
1277
|
-
return CREDENTIAL_PARAM_Y.lastIndex;
|
|
1278
1470
|
const limit = Math.min(text.length, p + CREDENTIAL_NAME_SCAN_MAX);
|
|
1279
1471
|
let hasPct = false;
|
|
1280
1472
|
for (let i = p; i < limit; i++) {
|
|
@@ -1283,12 +1475,14 @@ function credentialParamValueStart(text, p) {
|
|
|
1283
1475
|
hasPct = true;
|
|
1284
1476
|
continue;
|
|
1285
1477
|
}
|
|
1286
|
-
if (c
|
|
1287
|
-
|
|
1288
|
-
|
|
1478
|
+
if (c === CH_EQ) {
|
|
1479
|
+
if (i === p)
|
|
1480
|
+
return -1;
|
|
1481
|
+
const name = hasPct ? decodeAsciiName(text.slice(p, i)) : text.slice(p, i);
|
|
1482
|
+
return name !== undefined && credentialNameAnchor(name) !== undefined ? i + 1 : -1;
|
|
1483
|
+
}
|
|
1484
|
+
if (!(isAsciiAlnumCode(c) || c === CH_UNDERSCORE || c === CH_MINUS))
|
|
1289
1485
|
return -1;
|
|
1290
|
-
const decoded = decodeAsciiName(text.slice(p, i));
|
|
1291
|
-
return decoded !== undefined && CREDENTIAL_NAME_SET.has(decoded.toLowerCase()) ? i + 1 : -1;
|
|
1292
1486
|
}
|
|
1293
1487
|
return -1;
|
|
1294
1488
|
}
|
|
@@ -1697,24 +1891,19 @@ function collectUrlCredentialSpans(scan, text, json, span) {
|
|
|
1697
1891
|
scan.footHi = armHi;
|
|
1698
1892
|
}
|
|
1699
1893
|
const JSON_FIELD_ANCHOR = '"';
|
|
1700
|
-
const CREDENTIAL_NAME_MAX = Math.max(...CREDENTIAL_NAME_WORDS.map((w) => w.length));
|
|
1701
1894
|
function jsonSecretFieldValueQuoteAt(text, p) {
|
|
1702
1895
|
const n = text.length;
|
|
1703
|
-
let name = "";
|
|
1704
1896
|
let i = p + 1;
|
|
1705
1897
|
for (; i < n; i++) {
|
|
1706
|
-
|
|
1898
|
+
const c = text.charCodeAt(i);
|
|
1707
1899
|
if (c === CH_QUOTE)
|
|
1708
1900
|
break;
|
|
1709
1901
|
if (i - p > CREDENTIAL_NAME_MAX)
|
|
1710
1902
|
return -1;
|
|
1711
|
-
if (c
|
|
1712
|
-
c += 32;
|
|
1713
|
-
if (!((c >= CH_a && c <= CH_z) || (c >= CH_0 && c <= CH_9) || c === CH_UNDERSCORE || c === CH_MINUS))
|
|
1903
|
+
if (!(isAsciiAlnumCode(c) || c === CH_UNDERSCORE || c === CH_MINUS))
|
|
1714
1904
|
return -1;
|
|
1715
|
-
name += String.fromCharCode(c);
|
|
1716
1905
|
}
|
|
1717
|
-
if (i >= n ||
|
|
1906
|
+
if (i >= n || i === p + 1 || credentialNameAnchor(text.slice(p + 1, i)) === undefined)
|
|
1718
1907
|
return -1;
|
|
1719
1908
|
i += 1;
|
|
1720
1909
|
while (i < n && isRegexSpace(text.charCodeAt(i)))
|
|
@@ -1759,7 +1948,6 @@ const STRONG_AUTH_SCHEMES = new Set(["basic", "bearer"]);
|
|
|
1759
1948
|
const STRONG_AUTH_SCHEME_MAX = Math.max(...[...STRONG_AUTH_SCHEMES].map((w) => w.length));
|
|
1760
1949
|
const ABSENT_OR_BOOLEAN_WORDS = new Set(["null", "nil", "none", "undefined", "true", "false", "yes", "no"]);
|
|
1761
1950
|
const ABSENT_OR_BOOLEAN_MAX = Math.max(...[...ABSENT_OR_BOOLEAN_WORDS].map((w) => w.length));
|
|
1762
|
-
const CREDENTIAL_ANCHOR_OF = new Map(Object.entries(CREDENTIAL_NAME_ANCHORS));
|
|
1763
1951
|
const CH_GRAVE = 96, CH_APOS = 39, CH_DOT = 46, CH_COMMA = 44, CH_SEMI = 59, CH_DOLLAR = 36;
|
|
1764
1952
|
const CH_LPAREN = 40, CH_RPAREN = 41, CH_RBRACKET = 93, CH_LBRACE = 123, CH_RBRACE = 125, CH_LT = 60, CH_GT = 62;
|
|
1765
1953
|
const CH_QMARK = 63, CH_AMP = 38, CH_HASH = 35;
|
|
@@ -1772,7 +1960,7 @@ const isValueCloser = (ch) => ch === CH_DOT || ch === CH_COMMA || ch === CH_SEMI
|
|
|
1772
1960
|
const isInlineSpaceUnit = (ch) => ch === CH_SPACE || ch === CH_TAB;
|
|
1773
1961
|
const isToken68Code = (c) => isAsciiAlnumCode(c) || c === CH_DOT || c === CH_MINUS || c === CH_UNDERSCORE || c === CH_TILDE || c === CH_PLUS || c === CH_SLASH;
|
|
1774
1962
|
const endsValueUnit = (ch) => ch === JSON_STRING_END || isRegexSpace(ch) || isQuoteUnit(ch) || isValueCloser(ch);
|
|
1775
|
-
const endsHeaderValueUnit = (ch) => ch === JSON_STRING_END || isLineTerminator(ch) ||
|
|
1963
|
+
const endsHeaderValueUnit = (ch) => ch === JSON_STRING_END || isLineTerminator(ch) || isSchemeDelimiterCode(ch) || ch === CH_COMMA || ch === CH_SEMI || ch === CH_RPAREN || ch === CH_RBRACKET || ch === CH_RBRACE || ch === CH_GT;
|
|
1776
1964
|
const bracketOf = (c) => c === CH_LPAREN ? 1 : c === CH_RPAREN ? -1 : c === CH_LBRACKET ? 2 : c === CH_RBRACKET ? -2 : c === CH_LBRACE ? 3 : c === CH_RBRACE ? -3 : c === CH_LT ? 4 : c === CH_GT ? -4 : 0;
|
|
1777
1965
|
let anchoredScanUnits = 0;
|
|
1778
1966
|
export function anchoredScanUnitsForTest() {
|
|
@@ -1884,7 +2072,7 @@ function anchorHeadAt(text, op, json) {
|
|
|
1884
2072
|
return undefined;
|
|
1885
2073
|
before = j - openLen;
|
|
1886
2074
|
}
|
|
1887
|
-
const strength =
|
|
2075
|
+
const strength = credentialNameAnchor(text.slice(nameStart, nameEnd));
|
|
1888
2076
|
if (strength === undefined)
|
|
1889
2077
|
return undefined;
|
|
1890
2078
|
if (!afterEscape && runStart === j + 1 && quote === 0 && j >= 0 && text.charCodeAt(j) === CH_SLASH)
|
|
@@ -2016,15 +2204,16 @@ function schemeValueAt(text, s, json) {
|
|
|
2016
2204
|
anchoredScanUnits += i - w;
|
|
2017
2205
|
if (i - w > STRONG_AUTH_SCHEME_MAX || !STRONG_AUTH_SCHEMES.has(text.slice(w, i).toLowerCase()))
|
|
2018
2206
|
return undefined;
|
|
2019
|
-
let
|
|
2207
|
+
let separated = false;
|
|
2020
2208
|
while (i < n) {
|
|
2021
2209
|
const unit = readAnchorUnit(text, i, json);
|
|
2022
|
-
|
|
2210
|
+
const ch = unitChOf(unit);
|
|
2211
|
+
if (!isInlineSpaceUnit(ch) && !isSchemeDelimiterCode(ch))
|
|
2023
2212
|
break;
|
|
2024
2213
|
i += unitLenOf(unit);
|
|
2025
|
-
|
|
2214
|
+
separated = true;
|
|
2026
2215
|
}
|
|
2027
|
-
if (!
|
|
2216
|
+
if (!separated)
|
|
2028
2217
|
return undefined;
|
|
2029
2218
|
const vs = i;
|
|
2030
2219
|
if (i >= n || !isAsciiAlnumCode(text.charCodeAt(i)))
|
|
@@ -2118,7 +2307,7 @@ export function structuralScannerForTest(arm) {
|
|
|
2118
2307
|
let ppkScanBytes = 0;
|
|
2119
2308
|
export function ppkScanBytesForTest() { return ppkScanBytes; }
|
|
2120
2309
|
export function resetPpkScanBytesForTest() { ppkScanBytes = 0; }
|
|
2121
|
-
function collectPpkContainerSpans(scan, text,
|
|
2310
|
+
function collectPpkContainerSpans(scan, text, eat, span) {
|
|
2122
2311
|
const HEAD = "PuTTY-User-Key-File-";
|
|
2123
2312
|
const MAC = "Private-MAC: ";
|
|
2124
2313
|
const HASH = "Private-Hash: ";
|
|
@@ -2204,8 +2393,10 @@ function collectPpkContainerSpans(scan, text, record, span) {
|
|
|
2204
2393
|
end = ateToEnd ? text.length : hexEnd;
|
|
2205
2394
|
break;
|
|
2206
2395
|
}
|
|
2207
|
-
if (ateToEnd &&
|
|
2208
|
-
|
|
2396
|
+
if (ateToEnd && eat !== undefined && eat.from < 0) {
|
|
2397
|
+
eat.from = at;
|
|
2398
|
+
eat.len = text.length;
|
|
2399
|
+
}
|
|
2209
2400
|
span(at, end);
|
|
2210
2401
|
at = end >= text.length ? Number.POSITIVE_INFINITY : nextVersionedHead(end);
|
|
2211
2402
|
}
|
|
@@ -2238,8 +2429,8 @@ const armPool = (() => {
|
|
|
2238
2429
|
phase: 1,
|
|
2239
2430
|
lexical: LEXICAL_KEYWORD_ARMS.has(re),
|
|
2240
2431
|
collect: boundary === undefined
|
|
2241
|
-
? (text, _json,
|
|
2242
|
-
: (text, _json,
|
|
2432
|
+
? (text, _json, _eat, out) => collectRegexSpans(arm, text, out)
|
|
2433
|
+
: (text, _json, _eat, out) => collectValueArmSpans(boundary, text, out),
|
|
2243
2434
|
retry: boundary === undefined ? undefined : (text, at, out) => collectStickySpans(boundary, text, at, out),
|
|
2244
2435
|
headSrc: boundary === undefined ? undefined : headSrc,
|
|
2245
2436
|
headFirst: boundary === undefined ? undefined : headFirst,
|
|
@@ -2253,7 +2444,7 @@ const armPool = (() => {
|
|
|
2253
2444
|
order,
|
|
2254
2445
|
phase: 1,
|
|
2255
2446
|
lexical,
|
|
2256
|
-
collect: (text, json,
|
|
2447
|
+
collect: (text, json, eat, out) => arm(text, json, eat, (start, end) => out.push({ start, end, repl, rank, order })),
|
|
2257
2448
|
retry: undefined,
|
|
2258
2449
|
headSrc: undefined,
|
|
2259
2450
|
headFirst: undefined,
|
|
@@ -2268,7 +2459,7 @@ const armPool = (() => {
|
|
|
2268
2459
|
order,
|
|
2269
2460
|
phase: 2,
|
|
2270
2461
|
lexical: false,
|
|
2271
|
-
collect: (scan, text, json,
|
|
2462
|
+
collect: (scan, text, json, eat, out) => arm(scan, text, json, eat, (start, end) => out.push({ start, end, repl, rank, order })),
|
|
2272
2463
|
retry: undefined,
|
|
2273
2464
|
headSrc: undefined,
|
|
2274
2465
|
headFirst: undefined,
|
|
@@ -2276,22 +2467,22 @@ const armPool = (() => {
|
|
|
2276
2467
|
};
|
|
2277
2468
|
const structuralScannerMember = (row, order) => {
|
|
2278
2469
|
if (row === PEM_FENCE_PATTERN)
|
|
2279
|
-
return scannerMember(row[1], order, (text, _json,
|
|
2470
|
+
return scannerMember(row[1], order, (text, _json, _eat, span) => collectPemFenceSpans(text, span));
|
|
2280
2471
|
if (row === SSH2_FENCE_PATTERN)
|
|
2281
|
-
return forensicMember(row[1], order, (scan, text, _json,
|
|
2472
|
+
return forensicMember(row[1], order, (scan, text, _json, _eat, span) => collectSsh2FenceSpans(scan, text, span));
|
|
2282
2473
|
if (row === URL_CREDENTIAL_PATTERN)
|
|
2283
|
-
return forensicMember(row[1], order, (scan, text, json,
|
|
2474
|
+
return forensicMember(row[1], order, (scan, text, json, _eat, span) => collectUrlCredentialSpans(scan, text, json, span));
|
|
2284
2475
|
if (row === JSON_SECRET_FIELD_PATTERN)
|
|
2285
|
-
return scannerMember(row[1], order, (text, _json,
|
|
2476
|
+
return scannerMember(row[1], order, (text, _json, _eat, span) => collectJsonSecretFieldSpans(text, span));
|
|
2286
2477
|
throw new Error(`redact: structural row /${row[0].source}/ has no hand-written scanner — structural grammars are declared as regexes but never executed as one (S-102 / S-265)`);
|
|
2287
2478
|
};
|
|
2288
2479
|
const members = [];
|
|
2289
2480
|
for (const row of STRUCTURAL_SECRET_PATTERNS)
|
|
2290
2481
|
members.push(structuralScannerMember(row, members.length));
|
|
2291
|
-
members.push(forensicMember(PPK_CONTAINER_TOKEN, members.length, (scan, text, _json,
|
|
2292
|
-
members.push(forensicMember(PEM_FRAGMENT_TOKEN, members.length, (scan, text, json,
|
|
2293
|
-
members.push(forensicMember(HEADLESS_PPK_TOKEN, members.length, (scan, text, _json,
|
|
2294
|
-
members.push(scannerMember(ANCHORED_VALUE_TOKEN, members.length, (text, json,
|
|
2482
|
+
members.push(forensicMember(PPK_CONTAINER_TOKEN, members.length, (scan, text, _json, eat, span) => collectPpkContainerSpans(scan, text, eat, span)));
|
|
2483
|
+
members.push(forensicMember(PEM_FRAGMENT_TOKEN, members.length, (scan, text, json, _eat, span) => collectPemFragmentSpans(scan, text, json, span)));
|
|
2484
|
+
members.push(forensicMember(HEADLESS_PPK_TOKEN, members.length, (scan, text, _json, _eat, span) => collectHeadlessPpkSpans(scan, text, span)));
|
|
2485
|
+
members.push(scannerMember(ANCHORED_VALUE_TOKEN, members.length, (text, json, _eat, span) => collectAnchoredValueSpans(text, json, span), ARM_RANK.keyword, true));
|
|
2295
2486
|
for (const row of KEYWORD_SECRET_PATTERNS)
|
|
2296
2487
|
members.push(regexMember(row, ARM_RANK.keyword, members.length));
|
|
2297
2488
|
for (const row of SHAPE_SECRET_PATTERNS)
|
|
@@ -2322,7 +2513,8 @@ const armPool = (() => {
|
|
|
2322
2513
|
const headFirstUnit = unionMembers(retryMembers.map((m) => m.headFirst)) ?? new Uint32Array(0x10000 >>> 5).fill(0xffffffff);
|
|
2323
2514
|
poolArmCount = members.length;
|
|
2324
2515
|
poolBoundaryArmCount = retryMembers.length;
|
|
2325
|
-
return (text, wantCount, json,
|
|
2516
|
+
return (text, wantCount, json, eat, scope) => {
|
|
2517
|
+
readings += 1;
|
|
2326
2518
|
const lane = LANES[scope];
|
|
2327
2519
|
const spans = [];
|
|
2328
2520
|
let tried;
|
|
@@ -2358,7 +2550,7 @@ const armPool = (() => {
|
|
|
2358
2550
|
}
|
|
2359
2551
|
};
|
|
2360
2552
|
for (const m of lane.phase1)
|
|
2361
|
-
m.collect(text, json,
|
|
2553
|
+
m.collect(text, json, eat, spans);
|
|
2362
2554
|
closeCoveragePositions(0);
|
|
2363
2555
|
if (lane.phase2.length > 0) {
|
|
2364
2556
|
const scan = buildForensicScan(credentialSpans(text), lane.phase2.length);
|
|
@@ -2375,7 +2567,7 @@ const armPool = (() => {
|
|
|
2375
2567
|
}
|
|
2376
2568
|
scan.footLo = FOOT_NONE;
|
|
2377
2569
|
scan.footHi = -1;
|
|
2378
|
-
lane.phase2[j].collect(scan, text, json,
|
|
2570
|
+
lane.phase2[j].collect(scan, text, json, level === 0 ? eat : undefined, spans);
|
|
2379
2571
|
foot[2 * j] = scan.footLo;
|
|
2380
2572
|
foot[2 * j + 1] = scan.footHi;
|
|
2381
2573
|
forensicRuns += 1;
|
|
@@ -2396,6 +2588,7 @@ const armPool = (() => {
|
|
|
2396
2588
|
const tokenOf = (sp) => members[sp.order].token;
|
|
2397
2589
|
const strong = spans.filter((sp) => armOfToken(tokenOf(sp)) === "full").sort((a, b) => a.start - b.start);
|
|
2398
2590
|
const byArmedToken = new Map();
|
|
2591
|
+
const stamped = [];
|
|
2399
2592
|
let si = 0;
|
|
2400
2593
|
let strongMaxEnd = -1;
|
|
2401
2594
|
for (const sp of kept) {
|
|
@@ -2411,16 +2604,17 @@ const armPool = (() => {
|
|
|
2411
2604
|
byArmedToken.set(key, { token, arm, count: 1 });
|
|
2412
2605
|
else
|
|
2413
2606
|
cur.count += 1;
|
|
2607
|
+
stamped.push({ ...sp, hit: { token, arm } });
|
|
2414
2608
|
}
|
|
2415
|
-
return { hits: [...byArmedToken.values()].map(({ token, arm, count }) => ({ label: labelOfToken(token), count, arm })), kept };
|
|
2609
|
+
return { hits: [...byArmedToken.values()].map(({ token, arm, count }) => ({ label: labelOfToken(token), count, arm })), kept: stamped };
|
|
2416
2610
|
};
|
|
2417
2611
|
})();
|
|
2418
2612
|
let onRedaction;
|
|
2419
2613
|
export function setRedactionObserver(fn) {
|
|
2420
2614
|
onRedaction = fn;
|
|
2421
2615
|
}
|
|
2422
|
-
function applyRules(text, wantCount, json,
|
|
2423
|
-
return armPool(text, wantCount, json,
|
|
2616
|
+
function applyRules(text, wantCount, json, eat, scope) {
|
|
2617
|
+
return armPool(text, wantCount, json, eat, scope);
|
|
2424
2618
|
}
|
|
2425
2619
|
function reportHits(hits) {
|
|
2426
2620
|
if (onRedaction === undefined)
|
|
@@ -2433,35 +2627,111 @@ function reportHits(hits) {
|
|
|
2433
2627
|
}
|
|
2434
2628
|
}
|
|
2435
2629
|
}
|
|
2436
|
-
function
|
|
2630
|
+
function invisibleClassesOf(layout) {
|
|
2631
|
+
switch (layout) {
|
|
2632
|
+
case "multi-line":
|
|
2633
|
+
return SPELLED_FORMAT | SPELLED_CONTROL | RAW_CONTROL;
|
|
2634
|
+
case "single-line":
|
|
2635
|
+
return SPELLED_FORMAT | SPELLED_CONTROL | RAW_CONTROL | RAW_WHITESPACE;
|
|
2636
|
+
default: {
|
|
2637
|
+
const unhandled = layout;
|
|
2638
|
+
throw new Error(`redact: unhandled layout ${String(unhandled)}`);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
function runRedaction(text, observe, json, wantHits, scope, layout) {
|
|
2437
2643
|
const wantCount = wantHits || (onRedaction !== undefined && observe);
|
|
2438
|
-
const
|
|
2439
|
-
|
|
2440
|
-
|
|
2644
|
+
const eat = observe ? { from: -1, len: 0 } : undefined;
|
|
2645
|
+
let spans = [];
|
|
2646
|
+
let hits = NO_HITS;
|
|
2647
|
+
let readsSoFar = 0;
|
|
2648
|
+
let unioned = false;
|
|
2649
|
+
const read = (layers, view) => {
|
|
2650
|
+
const r = applyRules(view, wantCount, json, eat, scope);
|
|
2651
|
+
forgetEscapedSeparatorTails();
|
|
2652
|
+
readsSoFar += 1;
|
|
2653
|
+
if (readsSoFar === 1) {
|
|
2654
|
+
spans = spansInOriginal(layers, r.kept);
|
|
2655
|
+
hits = r.hits;
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
const extra = spansInOriginal(layers, r.kept);
|
|
2659
|
+
if (extra.length === 0)
|
|
2660
|
+
return;
|
|
2661
|
+
spans = resolveSpanOverlaps([...spans, ...extra]);
|
|
2662
|
+
unioned = true;
|
|
2663
|
+
};
|
|
2664
|
+
const raw = collectRawControlCuts(text, invisibleClassesOf(layout));
|
|
2665
|
+
for (let rmask = 0;; rmask = (rmask - raw.present) & raw.present) {
|
|
2666
|
+
const rfold = deleteInvisibleCharacters(text, raw, rmask);
|
|
2667
|
+
const normalized = normalizeForRedaction(rfold.text);
|
|
2668
|
+
const spelled = collectSpelledCuts(normalized);
|
|
2669
|
+
for (let smask = 0;; smask = (smask - spelled.present) & spelled.present) {
|
|
2670
|
+
const sfold = deleteInvisibleCharacters(normalized, spelled, smask);
|
|
2671
|
+
read([{ fold: sfold }, { input: rfold.text, view: normalized }, { fold: rfold }], sfold.text);
|
|
2672
|
+
if (smask === spelled.present)
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
if (rmask === raw.present)
|
|
2676
|
+
break;
|
|
2677
|
+
}
|
|
2678
|
+
if (unioned && wantCount)
|
|
2679
|
+
hits = hitsOfSpans(spans);
|
|
2680
|
+
if (eat !== undefined && eat.from >= 0)
|
|
2681
|
+
recordFailOpen("server.redact.ppk-eat-to-end", `from=${eat.from} len=${eat.len}`);
|
|
2441
2682
|
if (observe)
|
|
2442
|
-
reportHits(
|
|
2443
|
-
|
|
2444
|
-
|
|
2683
|
+
reportHits(hits);
|
|
2684
|
+
return { text: applySpans(text, spans).out, hits, spans };
|
|
2685
|
+
}
|
|
2686
|
+
function hitsOfSpans(spans) {
|
|
2687
|
+
const by = new Map();
|
|
2688
|
+
for (const sp of spans) {
|
|
2689
|
+
if (sp.hit === undefined)
|
|
2690
|
+
continue;
|
|
2691
|
+
const key = `${sp.hit.token}\u0000${sp.hit.arm}`;
|
|
2692
|
+
const cur = by.get(key);
|
|
2693
|
+
if (cur === undefined)
|
|
2694
|
+
by.set(key, { token: sp.hit.token, arm: sp.hit.arm, count: 1 });
|
|
2695
|
+
else
|
|
2696
|
+
cur.count += 1;
|
|
2697
|
+
}
|
|
2698
|
+
return [...by.values()].map(({ token, arm, count }) => ({ label: labelOfToken(token), count, arm }));
|
|
2445
2699
|
}
|
|
2446
|
-
function spansInOriginal(
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2700
|
+
function spansInOriginal(layers, kept) {
|
|
2701
|
+
let out = kept;
|
|
2702
|
+
for (const layer of layers) {
|
|
2703
|
+
if (out.length === 0)
|
|
2704
|
+
return out;
|
|
2705
|
+
let at;
|
|
2706
|
+
if ("fold" in layer) {
|
|
2707
|
+
const fold = layer.fold;
|
|
2708
|
+
if (fold.at === undefined)
|
|
2709
|
+
continue;
|
|
2710
|
+
at = (v) => viewIndexInInput(fold, v);
|
|
2711
|
+
}
|
|
2712
|
+
else {
|
|
2713
|
+
if (layer.view === layer.input)
|
|
2714
|
+
continue;
|
|
2715
|
+
const map = mapNormalizedToOriginal(layer.input, layer.view);
|
|
2716
|
+
at = (v) => map[v];
|
|
2717
|
+
}
|
|
2718
|
+
out = out.map((s) => ({ ...s, start: at(s.start), end: at(s.end - 1) + 1 }));
|
|
2719
|
+
}
|
|
2720
|
+
return out;
|
|
2451
2721
|
}
|
|
2452
2722
|
export function redactSecrets(text, opts) {
|
|
2453
|
-
return runRedaction(text, opts?.observe ?? true, opts?.json === true, false, "free-text").text;
|
|
2723
|
+
return runRedaction(text, opts?.observe ?? true, opts?.json === true, false, "free-text", "multi-line").text;
|
|
2454
2724
|
}
|
|
2455
2725
|
export function redactSecretsWithArms(text, opts) {
|
|
2456
|
-
const r = runRedaction(text, opts?.observe ?? true, opts?.json === true, true, "free-text");
|
|
2726
|
+
const r = runRedaction(text, opts?.observe ?? true, opts?.json === true, true, "free-text", "multi-line");
|
|
2457
2727
|
return { text: r.text, arms: new Set(r.hits.map((h) => h.arm)) };
|
|
2458
2728
|
}
|
|
2459
2729
|
export function redactionSpansForTest(text, opts) {
|
|
2460
|
-
const r = runRedaction(text, false, opts?.json === true, false, "free-text");
|
|
2730
|
+
const r = runRedaction(text, false, opts?.json === true, false, "free-text", "multi-line");
|
|
2461
2731
|
return { text: r.text, spans: r.spans.map((sp) => ({ start: sp.start, end: sp.end })) };
|
|
2462
2732
|
}
|
|
2463
|
-
export function proposeRedactionSpans(text, scope) {
|
|
2464
|
-
return runRedaction(text, true, false, false, scope).spans.map((sp) => ({ start: sp.start, end: sp.end, repl: sp.repl }));
|
|
2733
|
+
export function proposeRedactionSpans(text, scope, layout) {
|
|
2734
|
+
return runRedaction(text, true, false, false, scope, layout).spans.map((sp) => ({ start: sp.start, end: sp.end, repl: sp.repl }));
|
|
2465
2735
|
}
|
|
2466
2736
|
const REDACT_MAX_DEPTH = 64;
|
|
2467
2737
|
export function redactDeep(value) {
|
|
@@ -2563,7 +2833,7 @@ function unitCarriesCredential(unit) {
|
|
|
2563
2833
|
for (const v of armValueClassViews())
|
|
2564
2834
|
views.add(boundedUnitView(spelling, v.inClass, v.filler));
|
|
2565
2835
|
views.delete("");
|
|
2566
|
-
const hit = [...views].some((view) => runRedaction(view, true, false, false, "bounded-unit").text !== view);
|
|
2836
|
+
const hit = [...views].some((view) => runRedaction(view, true, false, false, "bounded-unit", "multi-line").text !== view);
|
|
2567
2837
|
return { hit, unreadable: decoded.residue };
|
|
2568
2838
|
}
|
|
2569
2839
|
function displaySafePathname(pathname) {
|
|
@@ -2593,7 +2863,7 @@ function shapeLawCredentialInQueryOrFragment(canonical) {
|
|
|
2593
2863
|
const boundary = canonical.indexOf("?");
|
|
2594
2864
|
if (boundary < 0)
|
|
2595
2865
|
return false;
|
|
2596
|
-
if (runRedaction(canonical, false, false, false, "free-text").spans.some((sp) => sp.end > boundary))
|
|
2866
|
+
if (runRedaction(canonical, false, false, false, "free-text", "multi-line").spans.some((sp) => sp.end > boundary))
|
|
2597
2867
|
return true;
|
|
2598
2868
|
for (const unit of canonical.slice(boundary + 1).split("&").flatMap((sg) => {
|
|
2599
2869
|
const eq = sg.indexOf("=");
|