test(handlers): add CWE-22 regression suite + KI-005 terminal access fix + tests - #1574
Merged
Merged
Conversation
molecule-ai
Bot
force-pushed
the
fix/container-files-test-regression
branch
from
April 22, 2026 13:36
68b4328 to
129a823
Compare
|
|
||
| // Cascade guard: include child count in the warning message when the workspace | ||
| // has children, so the user understands the blast radius before clicking Delete All. | ||
| const cascadeMessage = pendingDelete?.hasChildren |
| * 2. A2ATopologyOverlay component — side-effect behavior (API + store mocks) | ||
| */ | ||
| import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; | ||
| import { render, cleanup, waitFor, act } from "@testing-library/react"; |
| * entry list, expand, delete flow, optimistic updates, Refresh, semantic search. | ||
| */ | ||
| import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; | ||
| import { render, screen, fireEvent, waitFor, cleanup, act } from "@testing-library/react"; |
| // ── Import component under test AFTER all mocks ────────────────────────────── | ||
| import { SidePanel } from "../SidePanel"; | ||
|
|
||
| const TABS = [ |
| /** | ||
| * Tests for the Z keyboard shortcut (zoom-to-team) and help panel entry. | ||
| */ | ||
| import React from "react"; |
| * Tests for the Z keyboard shortcut (zoom-to-team) and help panel entry. | ||
| */ | ||
| import React from "react"; | ||
| import { render, screen, fireEvent, cleanup } from "@testing-library/react"; |
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 22, 2026
- Add regression section: 85de7d6 regressed 49ab614 CWE-78 fix → "/configs/"+filePath concatenation reintroduced path traversal → Fix: revert to exec-form two-arg Cmd - Update head commit to 9246924 (regression fix) - Add PR #1555 vs #1498 conflict note (ssrf.go modified both ways) - Add PR #1574 conflict note (dirty vs forced staging update) - Update timestamp to 13:40Z Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…warnings
golangci-lint errcheck has been flagging these since before this PR —
not regressions from the restart fix, just long-standing debt that
blocks Platform (Go) CI from ever going green. Prefix ignored returns
with `_ =` to make the signal explicit without changing behavior:
- channels/lark_test.go:97 (w.Write) + :118 (resp.Body.Close)
- channels/channels_test.go:620 + :760 (mockDB.Close in t.Cleanup)
- channels/manager.go:131 + :196 (defer rows.Close via closure wrapper)
- channels/manager.go:206–207 (json.Unmarshal into struct fields)
- artifacts/client_test.go:195, 237, 297 (json.Decode in test handlers)
The manager.go defer patch uses `defer func() { _ = rows.Close() }()`
since errcheck doesn't allow the `_ =` prefix directly on `defer`.
Build + `go test ./...` green locally for internal/channels and
internal/artifacts. The manager.go change touches production code so
I re-ran the channels test suite; passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…fix + tests container_files_test.go (152 lines): - 11 path-traversal test cases for copyFilesToContainer (F1501/CWE-22) - Tests nil Docker client — validation logic runs before any Docker call terminal.go KI-005 security fix (backport from ship/security-fix 6de7530): - Enforce CanCommunicate hierarchy check before granting terminal access - Shell access is more dangerous than A2A message-passing; apply the same hierarchy check used by A2A and discovery endpoints - When X-Workspace-ID header is present and bearer token is valid (ValidateAnyToken), reject unless CanCommunicate(callerID, targetID) - Canvas/molecli callers without X-Workspace-ID header pass through to WorkspaceAuth middleware for existing bearer check - canCommunicateCheck exposed as package var for testability terminal_test.go (5 test cases): - TestTerminalConnect_KI005_RejectsUnauthorizedCrossWorkspace - TestTerminalConnect_KI005_AllowsOwnTerminal - TestTerminalConnect_KI005_SkipsCheckWithoutHeader - TestTerminalConnect_KI005_RejectsInvalidToken - TestTerminalConnect_KI005_AllowsSiblingWorkspace Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai
Bot
force-pushed
the
fix/container-files-test-regression
branch
from
April 22, 2026 15:29
129a823 to
47dade2
Compare
This was referenced Apr 22, 2026
Closed
molecule-ai Bot
pushed a commit
that referenced
this pull request
Apr 22, 2026
…e KI-005 check PR #1574 introduced two compile errors at SHA 66ea0b6: 1. var canCommunicateCheck declared inside function body (line 86) — invalid Go 2. Duplicate HandleConnect method (lines 60 and 89) — Go disallows duplicate methods Fix: - Extract canCommunicateCheck as package-level var (line 34) so tests can stub it - Move KI-005 CanCommunicate check into routing HandleConnect before routing decision; check applies to both remote and local terminal paths - Remove handleLocalConnect stub containing the duplicate HandleConnect - handleLocalConnect now immediately starts with Docker nil check (clean entry) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 22, 2026
This was referenced Apr 23, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a regression test suite for the CWE-22 path traversal fix in
copyFilesToContainerand validates the KI-005 terminal access fix with 5 test cases.Files changed
workspace-server/internal/handlers/container_files_test.go: 11 test cases covering legitimate paths, absolute-path prefix, leading..prefix, mid-path traversal (CWE-22 regression), and traversal escaping destPath.workspace-server/internal/handlers/terminal_test.go: 5 test cases for KI-005 workspace-hierarchy guard in terminal WebSocket handler.workspace-server/internal/handlers/terminal.go: AddscanCommunicateCheckpackage var + hierarchy guard.Tests
TestCopyFilesToContainer_CWE22_RejectsTraversalTestTerminalConnect_KI005_RejectsUnauthorizedCrossWorkspaceTestTerminalConnect_KI005_AllowsOwnTerminalTestTerminalConnect_KI005_SkipsCheckWithoutHeaderTestTerminalConnect_KI005_RejectsInvalidTokenTestTerminalConnect_KI005_AllowsSiblingWorkspaceCI
Platform (Go)
go build ./cmd/serverandgo vet ./...pass onorigin/stagingbase.