fix(flow): global state collision and leakage#6281
Conversation
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
WalkthroughThe changes remove JavaScript runtime pooling in the flow executor, ensuring each scan gets a fresh runtime instance. The flow protocol's execution callback now updates the JS "template" variable after each protocol run, reflecting the current template context. Benchmark tests are updated and expanded to measure these behaviors. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Nuclei
participant FlowExecutor
participant JSRuntime
User->>Nuclei: Start scan with flow protocol
Nuclei->>FlowExecutor: Compile flow
FlowExecutor->>JSRuntime: GetJSRuntime()
JSRuntime-->>FlowExecutor: New runtime instance
FlowExecutor->>JSRuntime: Register protocol callback
Nuclei->>FlowExecutor: Execute protocol step
FlowExecutor->>JSRuntime: Execute requestExecutor
JSRuntime-->>FlowExecutor: Protocol result
FlowExecutor->>JSRuntime: Update "template" variable with context
FlowExecutor-->>Nuclei: Return execution result
Assessment against linked issues
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
🧰 Additional context used🧬 Code Graph Analysis (2)pkg/tmplexec/flow/vm_benchmark_test.go (1)
pkg/tmplexec/flow/vm.go (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (6)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Proposed changes
Fixes #6263
Benchmark
Local Scoping v. Namespacing
Note
Local scoping == clean state (this patch).
Namespacing == runtime shared/reuse (old / prior to this PR/patch).
Local scoping:
Namespacing:
old (runtime shared/reuse):
patch (clean state):
benchstat:
Strange that the benchstat results show no statistically significant difference between the two approaches on a real-world task.
Steps to Test
Checklist
Summary by CodeRabbit
New Features
Refactor
Bug Fixes