Skip to content

IDE Wiring Map: open only a file the wiring graph reports (ASVS 5.3.2, BACKLOG #4277) - #3252

Open
wshallwshall wants to merge 3 commits into
mainfrom
b684-4277-opensource-guard
Open

wshallwshall wants to merge 3 commits into
mainfrom
b684-4277-opensource-guard

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Merge danger

Reversible: yes -- reverting the squash on main restores the previous Wiring Map open handler.

Blast radius: the VS Code extension's Wiring Map webview open handler only (ide/src/wiringMap.ts, ide/src/wiringMapModel.ts) and its unit tests. No engine package, API, store or pipeline change. The messagefoundry.openSource command and its other callers are unchanged.

Evidence

  • Before: at origin/main 353b2183fe2, ide/src/wiringMap.ts passed the page-posted m.file straight to messagefoundry.openSource, which opened it with no check.
  • After: 10 new tests in ide/src/test/suite/wiring-map-model.test.ts. A graph-reported path opens, absolute or workspace-relative. A page-chosen path is refused: traversal, near-miss, case variant, UNC, malformed input. Negative control: with the guard disabled, 4 of the 22 tests in that suite go red. npm run test:unit 1968 passing, 0 failing on the final head.

Batch 684, BACKLOG #4277 (Builder E1)

Source branch b684-4277-opensource-guard, head 37363340baeb19c606ea68a8a3f5c9f4c27de44b. Its own PR because it changes a security control.

What changed. The Wiring Map open request now goes through handleOpenRequest / graphOpenTarget in ide/src/wiringMapModel.ts (no vscode import). The open is allowed only when the page's file exactly equals an element file the current graph reports, matched against the same collectElements source the payload is built from, so no root resolution or case fold can widen it (ASVS 5.3.2). A refused request runs no command and shows a warning that does not echo the path. A failed open (file deleted since the last refresh) now warns instead of being dropped. The message's file and line are typed unknown.

The guard is stricter than the row asked: the Wiring Map can no longer open the open document unless the graph reports it. The page never asks for that, so nothing regresses.

Checks run: ide tsc --noEmit clean; npm run compile OK; npm run test:unit 1968 passing, 0 failing on the final head (on an earlier head, one unrelated collectionCaseFiles junction test failed in the full run and passed alone, a load-timing flake); tests/test_file_path_join_census.py green (18 passed), join counts unchanged. No Python changed, so ruff and mypy do not apply.

Not run: the electron npm test suite.

Deferred, out of scope:

  • Host-side shape checks on setFocus, reveal and a null message belong to BACKLOG Redactor masks the rest of a PHI value a field run cut through (BACKLOG #3318) #2418.
  • Rejections from reveal and refresh are still dropped by void onMessage.
  • An alternative design has the page post (kind, name) instead of a path; that touches wiringMapWebview.ts, outside the brief.
  • A vault record follow-up is owed after merge, briefed separately.

Review: code-review skill at xhigh, Rounds: 2 + 1 unrepaired. The QA line and unrepaired findings are in a comment below.

The Wiring Map's "open" handler passed a webview message's file
straight to messagefoundry.openSource, which opens any path. A page
script names that file, so a compromised page could have the
extension open any file the operator's account can read.

graphOpenTarget (wiringMapModel.ts, vscode-free) now accepts the
request only when the current graph reports that file for an element,
compared with fileKey against the workspace root, and hands openSource
the graph's own spelling of it. Anything else is refused with a
warning and nothing opens. openSource itself is unchanged: its other
callers pass a graph-reported tree-row path or the open document.

Node-side tests: graph paths (absolute and workspace-relative) open;
page-chosen paths, traversal, UNC and malformed requests are refused.

BACKLOG #4277
…failures

Review round 1. graphOpenTarget now requires the page's file to EQUAL a
file the graph reports, rather than matching a resolved, case-folded
key: the page only ever echoes the payload, and an exact match takes no
dependency on the workspace root or on fileKey, whose contract says it
is not a containment check. The open message's fields are typed
unknown, an openSource rejection (a graph file gone since the last
refresh) now warns instead of being dropped, and the tests no longer
claim a UNC rule the guard does not have. A new test pins that every
file the map payload offers is one the guard accepts.

BACKLOG #4277
…able files

Review round 2. The open handler's decision moves into handleOpenRequest
(wiringMapModel.ts, vscode-free, host calls injected), so node-side
tests now pin that a refused file runs no command and a graph file
reaches messagefoundry.openSource under the graph's spelling.
graphOpenTarget reads openable files through collectElements, the same
source the payload is built from, so an empty file is excluded by
construction. Drops the imports round 1 left unused, and the refusal
warning now says when no graph is loaded. A mutation that disables the
guard turns 4 of the 22 suite tests red.

BACKLOG #4277
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA (Builder E1, BACKLOG #4277): code-review skill at xhigh, Rounds: 2 + 1 unrepaired. Tag for round-a2e7b4cc and round-844fe3d6, read with review_tag.py, exit 0: "xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings". The tool did not echo a tag line for round-083e5def, the final unrepaired round.

Unrepaired findings from the final round, shipped as the Builder reported them:
(a) No test drives WiringMapPanel.onMessage itself; only the pure function is pinned.
(b) The handleOpenRequest docstring says "the graph's file, never the page's". The returned string is the page's, equal under ===; returning the matched e.open.file would make it true by construction.
(c) The guard sits in the Wiring Map caller, not at the openSource sink, so a future webview caller could reopen the path.
(d) If graphOpenTarget throws on a malformed graph, the error escapes outside the try.
(e) It accepts any graph file, not only the nodes on screen.
(f) normalize runs on every click.
(g) The stale-render warning wording.
(h) A refusal leaves no durable log line.
(i) The module header still says "read-only projection".
(j) The injected execute is broader than needed.
(k) The for-loop could be .find.

@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Nov 24, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander hand-over (Manager aebf32, batch 684)

Field Value
Pull request MEFORORG/MessageFoundry 3252
Head SHA 3736334
Unread legs Every hosted CI leg (not yet run at hand-over). The Builder did not run the electron npm test suite locally.
Known defects The 11 unrepaired final-round findings, verbatim in the QA comment above, (a) to (k).
Landing-order constraint none

Ledger ask after merge: flip #4277. Proposed banner, from the Builder, to carry as written:
CLOSED by engine PR 3252 (batch 684). The Wiring Map open handler now refuses any file the current wiring graph does not report: an exact match through graphOpenTarget/handleOpenRequest in ide/src/wiringMapModel.ts, with node-side tests showing a page-chosen path is refused and a graph path opens. Closing step 2, the vault record follow-up and the census confirmation, is still owed by a Manager's vault Builder.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant