* test: isolate embedding configuration between unit fixtures Reset model-probe gateway state and pin chunk-sanitization fixtures to the shared legacy embedding dimensions. Preserve the original persistence and hash assertions. * feat: add existing-agent memory and unified hosted access (v0.49.0.0) Add isolated in-agent setup and repair, private PGLite backup and relocated restore, shared hosted grants and live delegation enforcement, secure credential handoff and recovery, and capability discovery and verification. Make local and hosted onboarding prominent in dedicated Grok Bot and Muse guides. Preserve explicit native-harness acceptance gates, update generated references and release metadata, and keep withdrawn facts out of active memory after synchronization. Co-Authored-By: OpenAI Codex <noreply@openai.com> * docs: sync harness documentation for v0.49.0.0 * fix: update security dependencies and confine restored configuration Refresh patched dependency versions, traverse only owned configuration properties during restore, and trust the CI checkout before calculating the Semgrep baseline. Add a regression that preserves inherited path objects. --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
133 lines
7.5 KiB
Bash
Executable File
133 lines
7.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# v0.39 — CI guard against bypassing the localOnly filter on the HTTP MCP
|
|
# surface. Lives alongside check-jsonb-pattern.sh / check-progress-to-stdout.sh
|
|
# in the bun run verify chain.
|
|
#
|
|
# Background: serve-http.ts builds the HTTP MCP tools/list response from
|
|
# `operations.filter(op => !op.localOnly)`. That filter is the only thing
|
|
# keeping localOnly ops (sync_brain, file_upload, file_list, file_url —
|
|
# any admin op the user EXPLICITLY marked as CLI-only) off the wire.
|
|
#
|
|
# If a future HTTP-exposing module imports `operations` from
|
|
# core/operations.ts WITHOUT applying the filter, the localOnly contract
|
|
# silently breaks: a write-scoped OAuth client could submit `sync_brain`
|
|
# or `file_upload` over HTTP. Codex outside-voice review of the e2e-test-
|
|
# wave (CMT-3) flagged this exact bypass class.
|
|
#
|
|
# The guard works by:
|
|
# 1. Listing every file that imports `operations` from core/operations.ts.
|
|
# 2. Comparing against an explicit ALLOWLIST of known-safe importers
|
|
# (each with a rationale below).
|
|
# 3. Failing if a new file is missing from the allowlist — forces the
|
|
# author to either (a) join the allowlist with an explicit rationale,
|
|
# or (b) apply the canonical filter at import.
|
|
#
|
|
# This is a structural defense. The runtime defense lives in
|
|
# test/operations-trust-boundary.test.ts (the canonical filter contract +
|
|
# handler-invocation cases for the historically-broken classes).
|
|
#
|
|
# To allow a new importer: add the relative path to ALLOWED below with a
|
|
# one-line comment explaining why localOnly isn't a concern there.
|
|
#
|
|
# Exit: 0 when no unknown importers, 1 when at least one is missing from
|
|
# the allowlist.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
cd "$ROOT"
|
|
|
|
# Files allowed to import `operations` directly. Each entry must be
|
|
# accompanied by a one-line rationale (the comment on the same line).
|
|
ALLOWED=(
|
|
"src/core/grants/profiles.ts" # snapshots eligible remote ops with !op.localOnly; grant validation never exposes local-only operations
|
|
"src/core/harness/capabilities.ts" # introspection applies !op.localOnly plus effective surface, scope, fence, snapshot and publish-gate filters
|
|
"src/cli.ts" # local CLI; user owns the machine, no trust boundary
|
|
"src/mcp/dispatch.ts" # shared dispatch; sets ctx.remote from caller, handlers self-gate
|
|
"src/mcp/server.ts" # stdio MCP; local-trusted (binary on user's box)
|
|
"src/mcp/http-transport.ts" # superseded by serve-http.ts; kept for back-compat tests
|
|
"src/mcp/tool-defs.ts" # pure helper; takes ops as parameter, never exposes them
|
|
"src/core/minions/tools/brain-allowlist.ts" # subagent registry; has its own opt-in allowlist (separate from localOnly)
|
|
"src/commands/capture.ts" # local CLI tool; not network-exposed
|
|
"src/commands/enrich.ts" # local CLI tool; calls put_page handler with remote=false, not network-exposed
|
|
"src/commands/book-mirror.ts" # local CLI tool; not network-exposed
|
|
"src/commands/tools-json.ts" # gbrain --tools-json introspection; full op list IS the purpose
|
|
"src/mcp/publish-gates.ts" # reads op.publishGateKey/name only to compute gate-DISABLED sets; never lists/exposes ops
|
|
"src/mcp/tool-catalog.ts" # docs/TOOL_CATALOG.md renderer; filters !op.localOnly at the boundary; never a transport surface
|
|
"src/commands/serve-http.ts" # MUST APPLY .filter(op => !op.localOnly) — verified by grep below
|
|
"src/core/ops/request-tools.ts" # visibleOpsForCaller loads the assembled list lazily (verbs.ts house pattern) and applies (isLocal || !op.localOnly) + surface + gate filtering
|
|
# The four below predate the widened specifier regex (they import via
|
|
# '../operations.ts', invisible to the old 'core/operations.ts' pattern) —
|
|
# all internal consumers, none a transport surface:
|
|
"src/core/advisor/collect-mcp-client-fit.ts" # advisor collector; uses op.localOnly names to SCORE client fit, never serves the list
|
|
"src/core/bootstrap/verify.ts" # bootstrap wiring verifier; finds ops by name to probe local wiring, remote=false context
|
|
"src/core/skillopt/rollout.ts" # skillopt internals; iterates op metadata for rollout planning, not exposed
|
|
"src/core/skillopt/write-capture.ts" # skillopt internals; iterates op params for capture schema, not exposed
|
|
)
|
|
|
|
# Pattern: any import that brings the `operations` VALUE in from core/operations.ts.
|
|
# Three shapes the value can enter through; each must be caught:
|
|
# - destructured: import { operations } from '...core/operations.ts'
|
|
# - aliased: import { operations as ops } from '...core/operations.ts'
|
|
# - namespace: import * as opsModule from '...core/operations.ts'
|
|
# The original narrow regex only matched the destructured form — codex caught
|
|
# the bypass class during /ship adversarial review (aliased + namespace forms
|
|
# slipped through). The broadened regex below specifically requires `operations`
|
|
# inside the destructured clause OR a namespace import (`* as X`); type-only
|
|
# imports of sibling exports like `sourceScopeOpts` / `OperationContext` are
|
|
# left alone (those don't expose the op list to a transport surface).
|
|
# Specifier: `core/operations.ts` from outside src/core, `../operations.ts`
|
|
# from inside (the ops/ module dir sits one level down post-peel), and the
|
|
# dynamic `import('...operations.ts')` house pattern — all three reach the
|
|
# assembled op list.
|
|
PATTERN='(import[[:space:]]+(\*[[:space:]]+as[[:space:]]+[a-zA-Z_$][a-zA-Z0-9_$]*|\{[^}]*\boperations\b[^}]*\})[[:space:]]+from[[:space:]]*['\''"][^'\''"]*(core/operations|\.\./operations)\.ts['\''"]|\{[^}]*\boperations\b[^}]*\}[[:space:]]*=[[:space:]]*await[[:space:]]+import\(['\''"][^'\''"]*operations\.ts['\''"]\))'
|
|
|
|
# Collect files that import `operations`. Use a while-loop over grep output
|
|
# instead of `mapfile` to stay compatible with macOS's default bash 3.2.
|
|
FOUND_FILES=""
|
|
while IFS= read -r f; do
|
|
[ -n "$f" ] && FOUND_FILES="$FOUND_FILES$f"$'\n'
|
|
done < <(grep -rlE --include='*.ts' "$PATTERN" src 2>/dev/null | sort -u || true)
|
|
|
|
FAIL=0
|
|
|
|
# Check 1: every found file is in ALLOWED.
|
|
while IFS= read -r file; do
|
|
[ -z "$file" ] && continue
|
|
rel="${file#"$ROOT/"}"
|
|
ok=0
|
|
for allowed in "${ALLOWED[@]}"; do
|
|
if [ "$rel" = "$allowed" ]; then
|
|
ok=1
|
|
break
|
|
fi
|
|
done
|
|
if [ "$ok" -eq 0 ]; then
|
|
echo "FAIL: $rel imports operations but is not in scripts/check-operations-filter-bypass.sh ALLOWED list."
|
|
echo " Either apply .filter(op => !op.localOnly) at the import boundary,"
|
|
echo " or add this file to ALLOWED with a one-line rationale."
|
|
FAIL=1
|
|
fi
|
|
done <<< "$FOUND_FILES"
|
|
|
|
# Check 2: serve-http.ts MUST contain the canonical filter expression near
|
|
# its operations import. Without the filter, the entire HTTP MCP surface
|
|
# leaks localOnly ops.
|
|
SERVE_HTTP="src/commands/serve-http.ts"
|
|
if [ -f "$SERVE_HTTP" ]; then
|
|
if ! grep -qE 'operations\.filter\(\s*op\s*=>\s*!op\.localOnly\s*\)' "$SERVE_HTTP"; then
|
|
echo "FAIL: $SERVE_HTTP no longer contains the canonical"
|
|
echo " operations.filter(op => !op.localOnly) expression. The HTTP MCP"
|
|
echo " surface depends on this filter to enforce localOnly. Restore"
|
|
echo " the filter or refactor the trust boundary explicitly."
|
|
FAIL=1
|
|
fi
|
|
fi
|
|
|
|
if [ "$FAIL" -eq 1 ]; then
|
|
echo ""
|
|
echo "Hint: see test/operations-trust-boundary.test.ts for the runtime contract."
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|