Skip to content

fix(mcp): keep boundary suggestions source-free - #3955

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-mcp-tool-vulnerability
Jul 7, 2026
Merged

fix(mcp): keep boundary suggestions source-free#3955
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-mcp-tool-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent leakage of private local source by ensuring the MCP gittensory_suggest_boundary_tests tool no longer accepts raw unified-diff patch text at the remote boundary.
  • Replace server-side scanning of raw patches with a source-free metadata contract so agents compute any patch-derived artifacts locally and only submit precomputed, non-sensitive metadata.

Description

  • Change the MCP tool input schema for gittensory_suggest_boundary_tests to remove patch payloads and accept only changedFiles (paths) plus an optional, strict boundaryTouches array containing only path and kind (no source snippets), and cap touches to max(20). (src/mcp/server.ts)
  • Update tool registration and description to document the new source-free contract and to filter supplied boundaryTouches to the declared changedFiles. (src/mcp/server.ts)
  • Remove source snippets from BoundaryTouch and update detectBoundaryTouches to return only path + kind; make buildBoundaryTestGenerationFinding accept either precomputed touches or legacy files input so local callers can still scan and then submit safe metadata. (src/signals/boundary-test-generation.ts)
  • Add/adjust unit tests to cover the regression: MCP now rejects raw patch input, accepts precomputed touches, ignores touches for files not declared in changedFiles, and verifies that returned touches contain no source snippets. (test/unit/mcp-suggest-boundary-tests.test.ts, test/unit/boundary-test-generation.test.ts)

Testing

  • Ran type checking with npm run typecheck and it passed.
  • Ran targeted unit suites with npx vitest run test/unit/boundary-test-generation.test.ts test/unit/mcp-suggest-boundary-tests.test.ts and all tests passed.
  • Ran git diff --check which passed.
  • Attempted full local gate via npm run test:ci; execution reached test:coverage but the run was interrupted due to an unrelated recursive RangeError: Maximum call stack size exceeded observed in an existing test/unit/queue.test.ts test, so the full CI gate was not completed here.
  • npm audit --audit-level=moderate was attempted but the registry audit endpoint returned 403 Forbidden in this environment, so the dependency-review step could not be validated here.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.66%. Comparing base (1ce4364) to head (d284aba).
⚠️ Report is 15 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/signals/boundary-test-generation.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3955      +/-   ##
==========================================
- Coverage   93.66%   93.66%   -0.01%     
==========================================
  Files         372      372              
  Lines       34856    34856              
  Branches    12743    12744       +1     
==========================================
- Hits        32649    32648       -1     
  Misses       1588     1588              
- Partials      619      620       +1     
Files with missing lines Coverage Δ
src/mcp/server.ts 95.83% <100.00%> (+<0.01%) ⬆️
src/signals/boundary-test-generation.ts 97.14% <50.00%> (-2.86%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - fixes required

Review updated: 2026-07-07 09:14:17 UTC

4 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI failing · unstable

🛑 Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR closes a real boundary leak: the MCP `gittensory_suggest_boundary_tests` tool previously accepted raw unified-diff `patch` text over the remote boundary, and now only accepts file paths plus a strict, capped `boundaryTouches` metadata array (path + pattern kind, no snippets). The server-side filter in `suggestBoundaryTests` (src/mcp/server.ts) correctly restricts supplied touches to the declared `changedFiles` set before building the finding/spec, and `BoundaryTouch`/`detectBoundaryTouches`/`buildBoundaryTestGenerationFinding` in src/signals/boundary-test-generation.ts were updated consistently to drop `snippet` while preserving a `files`-based legacy path for other in-repo callers. Tests were added for the new rejection (`patch` now errors), the touch-filtering behavior, and the absence of `snippet` in output, and the changes are internally consistent with no schema/migration surface. The one open gap is coverage: codecov/patch sits at 80% vs the 99% target, so some new lines/branches introduced here (e.g. the `files ?? []` fallback branch of `buildBoundaryTestGenerationFinding`, or interactions between `boundaryTouches` omitted vs empty) likely lack direct tests.

Nits — 5 non-blocking
  • src/mcp/server.ts:808 hardcodes `.max(20)` for `boundaryTouches` even though `MAX_TOUCHES = 20` already exists in src/signals/boundary-test-generation.ts — export and reuse that constant so the schema cap can't silently drift out of sync with the signal's own cap.
  • codecov/patch is failing at 80% vs the 99% target for this diff — worth adding a test for the `input.files ?? []` / no-files-no-touches path in `buildBoundaryTestGenerationFinding` (src/signals/boundary-test-generation.ts) since that arm isn't obviously exercised by the new tests.
  • Confirm `detectBoundaryTouches` and the `files`-based branch of `buildBoundaryTestGenerationFinding` still have a real in-repo caller now that src/mcp/server.ts no longer imports `detectBoundaryTouches` directly — if nothing else calls the legacy `files` path in production, it's now dead code kept alive only by tests.
  • The PR description doesn't cite a maintainer-authorized issue beyond the pre-existing `Boundary-safe test generation #1972` reference in code comments — worth confirming this security fix is explicitly linked to an eligible open issue per repo convention.
  • Export `MAX_TOUCHES` from src/signals/boundary-test-generation.ts and reference it in the `boundaryTouches` zod schema's `.max()` in src/mcp/server.ts instead of the literal `20`.

Why this is blocked

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

CI checks failing

  • codecov/patch — 80.00% of diff hit (target 99.00%)
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 51 registered-repo PR(s), 43 merged, 569 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 569 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 569 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit 96214c5 into main Jul 7, 2026
9 of 10 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-mcp-tool-vulnerability branch July 7, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant