fix(worker): reject process global in workflow bundle#2128
Conversation
chris-olszewski
left a comment
There was a problem hiding this comment.
Thanks for taking this on. Only a small suggested change to avoid the as any cast.
| normalModuleFactory.hooks.parser.for(moduleType).tap('WorkflowCodeBundler', (parser) => { | ||
| const javascriptParser = parser as any; |
There was a problem hiding this comment.
Will need to add import type { javascript } from 'webpack'
| normalModuleFactory.hooks.parser.for(moduleType).tap('WorkflowCodeBundler', (parser) => { | |
| const javascriptParser = parser as any; | |
| normalModuleFactory.hooks.parser.for(moduleType).tap('WorkflowCodeBundler', (javascriptParser: javascript.JavascriptParser) => { |
|
Addressed the review feedback in 448b528 by replacing the |
chris-olszewski
left a comment
There was a problem hiding this comment.
Please read my suggested change from the previous review. You are still casting unnecessarily.
448b528 to
5bba954
Compare
|
Updated the review fix in 5bba954 to follow the requested shape directly.\n\nWhat changed:\n- Removed the parser cast entirely.\n- The parser callback parameter is now typed directly as |
chris-olszewski
left a comment
There was a problem hiding this comment.
We will need this new hook to respect our allowlist so that our internal testing where we colocate workflow code with tests can pass.
|
Addressed the allowlist feedback from @chris-olszewski. Changes made:
Validation:
I also tried the focused AVA bundler test locally, but this checkout is missing the |
Summary
Reject workflow bundles that reference the Node
processglobal directly.Webpack previously allowed free
processreferences through the workflow bundle, which only failed later inside the workflow sandbox. This adds a workflow bundler parser check for freeprocessexpressions while preserving locally shadowed bindings.Fixes #1112.
Testing
Additional focused bundler checks were run with a minimal
@temporalio/core-bridgecache stub:processis rejected as a disallowed moduleprocessbinding still bundlesNot run:
This currently fails while building
@temporalio/core-bridgebecauseprotocis not installed in this environment.