Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add helper plugin to keep paths within sandbox #160

Merged
merged 8 commits into from
Jan 4, 2024
Prev Previous commit
Handle external module resolutions
gregmagolan committed Jan 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit cfc9004c97116bd587f44597803cde586c98ea6a
9 changes: 9 additions & 0 deletions esbuild/private/plugins/bazel-sandbox.js
Original file line number Diff line number Diff line change
@@ -53,6 +53,15 @@ async function resolveInExecroot(build, importPath, otherOptions) {
return result
}

if (
!result.path.startsWith('.') &&
!result.path.startsWith('/') &&
!result.path.startsWith('\\')
) {
// Not a relative or absolute path. Likely a module resolution that is marked "external"
return result
}

// If esbuild attempts to leave the execroot, map the path back into the execroot.
if (!result.path.startsWith(execroot)) {
// If it tried to leave bazel-bin, error out completely.