Compare commits

...

1 Commits

Author SHA1 Message Date
fullstack-engineer 521bdeb941 test(handlers): OFFSEC-001 — harden RecallMemory_GlobalScope test (mc#693)
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 32s
cascade-list-drift-gate / check (pull_request) Successful in 22s
Check migration collisions / Migration version collision check (pull_request) Successful in 42s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 14s
CI / Detect changes (pull_request) Successful in 45s
E2E API Smoke Test / detect-changes (pull_request) Successful in 33s
publish-runtime-autobump / bump-and-tag (pull_request) Has been skipped
Handlers Postgres Integration / detect-changes (pull_request) Successful in 30s
Harness Replays / detect-changes (pull_request) Failing after 44s
Harness Replays / Harness Replays (pull_request) Has been skipped
review-check-tests / review-check.sh regression tests (pull_request) Successful in 17s
publish-runtime-autobump / pr-validate (pull_request) Successful in 55s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 1m25s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 34s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m25s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 49s
sop-tier-check / tier-check (pull_request) Successful in 22s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m40s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m42s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 52s
lint-mask-pr-atomicity / lint-mask-pr-atomicity (pull_request) Successful in 1m59s
Runtime Pin Compatibility / PyPI-latest install + import smoke (pull_request) Successful in 2m15s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 30s
audit-force-merge / audit (pull_request) Has been skipped
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 4m4s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 7m22s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 8m50s
CI / Python Lint & Test (pull_request) Successful in 9m10s
CI / Canvas (Next.js) (pull_request) Successful in 18m38s
CI / Platform (Go) (pull_request) Failing after 19m56s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 6s
Sibling of #680 (CommitMemory). The recall path exercises the same dispatchRPC
scrub path as commit, but the previous test only asserted `resp.Error != nil`.

Changes:
- Renamed TestMCPHandler_RecallMemory_GlobalScope_Blocked → ..._ScrubsInternalError
- Added OFFSEC-001 scrub contract assertions:
  1. resp.Error.Code == -32000 (server error, not generic -32600)
  2. resp.Error.Message == "tool call failed" (constant, no "GLOBAL" leak)
  3. Defence-in-depth: strings.Contains guard rejects original error keywords

Issue: #693

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 09:25:29 +00:00
+20 -2
View File
@@ -548,7 +548,12 @@ func TestMCPHandler_CommitMemory_CleanContent_PassesThrough(t *testing.T) {
// tools/call — recall_memory
// ─────────────────────────────────────────────────────────────────────────────
func TestMCPHandler_RecallMemory_GlobalScope_Blocked(t *testing.T) {
// TestMCPHandler_RecallMemory_GlobalScope_ScrubsInternalError verifies C3 is
// enforced and the OFFSEC-001 scrub contract is applied. The tool returns a
// descriptive error mentioning GLOBAL scope; dispatchRPC must replace it with
// a constant "tool call failed" message so internal implementation details
// never reach the caller.
func TestMCPHandler_RecallMemory_GlobalScope_ScrubsInternalError(t *testing.T) {
h, mock := newMCPHandler(t)
// No DB expectations — handler must abort before touching the DB.
@@ -568,7 +573,20 @@ func TestMCPHandler_RecallMemory_GlobalScope_Blocked(t *testing.T) {
var resp mcpResponse
json.Unmarshal(w.Body.Bytes(), &resp)
if resp.Error == nil {
t.Error("expected JSON-RPC error for GLOBAL scope recall, got nil")
t.Fatal("expected JSON-RPC error for GLOBAL scope recall, got nil")
}
// OFFSEC-001 scrub contract: error code is -32000 (server error).
if resp.Error.Code != -32000 {
t.Errorf("expected error code -32000, got %d", resp.Error.Code)
}
// Message must be the constant scrubbed string — no "GLOBAL" or bridge
// implementation details leaked to the caller.
if resp.Error.Message != "tool call failed" {
t.Errorf("error message should be constant 'tool call failed', got: %q", resp.Error.Message)
}
// Defence-in-depth: the original error body must not appear in the response.
if strings.Contains(resp.Error.Message, "GLOBAL") || strings.Contains(resp.Error.Message, "bridge") {
t.Error("scrubbed error message must not contain original error keywords")
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unexpected DB calls on GLOBAL scope block: %v", err)