Skip to content

Strip trellis vm shell banner in dbBackup and securityScan - #214

Merged
jasperf merged 2 commits into
mainfrom
fix/mcp-strip-vm-banner
Sep 4, 2026
Merged

Strip trellis vm shell banner in dbBackup and securityScan#214
jasperf merged 2 commits into
mainfrom
fix/mcp-strip-vm-banner

Conversation

@jasperf

@jasperf jasperf commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

stripVmBanner() in mcp-server/src/tools/wpCli.ts strips the Running command => … banner that trellis vm shell prints ahead of the wrapped command's real output — added after that banner previously leaked into wp_blogs.domain and 61 content rows on the demo site via db_pull. That fix only covers callers going through runWpCli/runWpCliRaw. Two tools spawn trellis vm shell directly and skipped it:

  • dbBackup.ts — streams wp db export - straight through the VM shell's stdout into the .sql dump before gzip, so a banner line could land inside the actual backup content, not just a parsed value.
  • securityScan.ts — same shape for the PHP scanner's stdout; a banner line would land at the top of the scan report.

Changes

  • wpCli.ts: exported the existing stripVmBanner(), and added a Buffer-safe stripVmBannerFromBuffer() for binary output (a SQL dump isn't guaranteed valid UTF-8, so the string version can't be used without risking corruption) — it only decodes the fixed ASCII prefix, never the full buffer.
  • securityScan.ts: reuses stripVmBanner() in its VM path, same as wpCli.ts's own runVm().
  • dbBackup.ts: wraps its VM-path export in stripVmBannerFromBuffer().
  • docs/mcp-server-recommendations.md: marked the gap done.
  • CHANGELOG.md: added 5.17.2.

Testing

  • npm run build in mcp-server/ — clean typecheck.
  • Manual verification of stripVmBannerFromBuffer() against three cases: banner present, no banner, and binary bytes following the banner (confirmed byte-for-byte preserved).

stripVmBanner() in wpCli.ts already fixes this for runWpCli/runWpCliRaw
callers (dbPull.ts, urlAudit.ts), but dbBackup.ts and securityScan.ts
spawn trellis vm shell directly and skipped it.

dbBackup.ts streams wp db export - straight into the .sql dump before
gzip, so a banner line there lands inside the actual backup content,
not just a parsed value — sharper than the bug stripVmBanner's own
comment describes (wp_blogs.domain and 61 content rows on the demo
site). Since the export is a Buffer, not a string, added a
Buffer-safe stripVmBannerFromBuffer() that only decodes the fixed
ASCII prefix rather than the whole dump, so binary content after the
banner is never at risk.

securityScan.ts's VM path now reuses the existing string stripVmBanner()
the same way wpCli.ts's own runVm() does.
@jasperf
jasperf merged commit 9a83abd into main Sep 4, 2026
1 check passed
@jasperf
jasperf deleted the fix/mcp-strip-vm-banner branch September 4, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant