Strip trellis vm shell banner in dbBackup and securityScan - #214
Merged
Conversation
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.
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
stripVmBanner()inmcp-server/src/tools/wpCli.tsstrips theRunning command => …banner thattrellis vm shellprints ahead of the wrapped command's real output — added after that banner previously leaked intowp_blogs.domainand 61 content rows on the demo site viadb_pull. That fix only covers callers going throughrunWpCli/runWpCliRaw. Two tools spawntrellis vm shelldirectly and skipped it:dbBackup.ts— streamswp db export -straight through the VM shell's stdout into the.sqldump 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 existingstripVmBanner(), and added a Buffer-safestripVmBannerFromBuffer()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: reusesstripVmBanner()in its VM path, same aswpCli.ts's ownrunVm().dbBackup.ts: wraps its VM-path export instripVmBannerFromBuffer().docs/mcp-server-recommendations.md: marked the gap done.CHANGELOG.md: added 5.17.2.Testing
npm run buildinmcp-server/— clean typecheck.stripVmBannerFromBuffer()against three cases: banner present, no banner, and binary bytes following the banner (confirmed byte-for-byte preserved).