Skip to content

refactor: use github.com/go-webengine/esbuildsandbox instead of a local copy - #83

Merged
tannevaled merged 1 commit into
mainfrom
refactor/use-esbuildsandbox-package
Sep 1, 2026
Merged

tannevaled merged 1 commit into
mainfrom
refactor/use-esbuildsandbox-package

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

The ResolveDir sandboxing fix (#65) is a genuinely reusable pattern: any Go program driving evanw/esbuild's pkg/api through a plugin has the same exposure. Extracted it into its own package, github.com/go-webengine/esbuildsandbox (v0.1.0), rather than leaving it siloed here — its own README explains the vulnerability, and it has a self-contained regression test driving a real api.Build (confirmed to fail/time out when reverted to "/").

modules.go now calls esbuildsandbox.ResolveDir() at all three call sites; the local esbuildSandboxResolveDir()/esbuildSandboxOnce/esbuildSandboxDir are deleted.

Removed the now-redundant TestEsbuildSandboxResolveDirIsIsolated (the shared package tests that itself, 100% coverage) but kept TestModuleGlobImportDoesNotWalkRealFilesystem — integration-level on purpose, proving this engine's own plugin wiring actually uses the shared sandbox everywhere, not just that the sandbox is safe in isolation.

Test plan

  • go test -short ./... — full suite green.
  • go vet ./... clean; dom/css/layout/paint coverage floors all still met.
  • No behavioural change: verified live against developer.mozilla.org (~550ms, matching the original fix's numbers).

…al copy

The ResolveDir sandboxing fix (engine#65) is a genuinely reusable pattern:
any Go program driving evanw/esbuild's pkg/api through a plugin has the
same exposure — a glob-shaped dynamic import bypasses OnResolve/OnLoad
entirely and resolves against ResolveDir on the real filesystem, no
matter how thorough the plugin's own sandboxing is. Extracted it into its
own package (github.com/go-webengine/esbuildsandbox, v0.1.0) rather than
leaving it siloed here, with its own README explaining the vulnerability
and a self-contained regression test that drives a real api.Build and
proves it (confirmed to time out walking real "/" when reverted).

modules.go now calls esbuildsandbox.ResolveDir() at all three call sites
instead of the local esbuildSandboxResolveDir()/esbuildSandboxOnce/
esbuildSandboxDir, which are deleted. Removed the now-redundant
TestEsbuildSandboxResolveDirIsIsolated (the shared package tests that
itself, with 100% coverage) but kept TestModuleGlobImportDoesNotWalk-
RealFilesystem — it is integration-level on purpose, proving this engine's
OWN plugin wiring actually uses the shared sandbox at every call site, not
just that the sandbox itself is safe in isolation.

No behavioural change: same directory-creation logic, same memoization,
same fallback. Verified live against developer.mozilla.org (~550ms,
matching the fix's original numbers) and the full test suite.
@tannevaled
tannevaled merged commit b27a41d into main Sep 1, 2026
7 checks passed
@tannevaled
tannevaled deleted the refactor/use-esbuildsandbox-package branch September 1, 2026 10:43
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