fix: restore parallel processing in file proto#6493
Conversation
WalkthroughWorkflow template execution was changed from concurrent to sequential (removed goroutine per template). File protocol per-path processing was changed from sequential to concurrent (each file now processed in its own goroutine). A new concurrent test and small CLI/debug helper were added. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Executor
participant WG as WaitGroup
participant Template
Note over Executor: New (current) workflow behavior — sequential
Executor->>Template: for each template: create context
Executor->>Template: call runWorkflowStep(...)
Template-->>Executor: returns (error logged if any)
Executor->>Executor: next template (no concurrent goroutine)
sequenceDiagram
autonumber
participant Caller as File Request
participant WG as WaitGroup
participant File
Note over Caller: File processing — now concurrent per file
Caller->>WG: Add(N)
par For each file
Caller--)File: go processFile(filePath)
File-->>WG: Done (defer)
end
Caller->>WG: Wait()
WG-->>Caller: All complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas to inspect closely:
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Mzack9999
left a comment
There was a problem hiding this comment.
implementation: lgtm!
Fix: failing tests
add missing `go` keyword to anonymous funcs that were intended to run as goroutines but were executing synchronously instead. Fixes #6492 Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
* replace hardcoded `DEBUG` env var check with extensible helper func. * add support for GitHub Actions Runner env var. * accept multiple truthy value variants. Signed-off-by: Dwi Siswanto <git@dw1.io>
caused by shared context callbacks. it was exposed after adding concurrent exec to workflow processing and occurred when multiple goroutines attempted to write to the same `ctx.OnResult` callback field simultaneously, causing data races during workflow template exec. Signed-off-by: Dwi Siswanto <git@dw1.io>
This reverts commit 1093bbc.
Signed-off-by: Dwi Siswanto <git@dw1.io>
52d9b58 to
69c831b
Compare
Signed-off-by: Dwi Siswanto <git@dw1.io>
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cmd/integration-test/integration-test.go(5 hunks)pkg/core/workflow_execute.go(1 hunks)pkg/protocols/file/request.go(1 hunks)pkg/protocols/file/request_test.go(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Format Go code using go fmt
Run static analysis with go vet
Files:
pkg/protocols/file/request.gopkg/core/workflow_execute.gopkg/protocols/file/request_test.gocmd/integration-test/integration-test.go
pkg/protocols/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
Each protocol implementation must provide a Request interface with methods Compile(), ExecuteWithResults(), Match(), and Extract()
Files:
pkg/protocols/file/request.gopkg/protocols/file/request_test.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: hdm
Repo: projectdiscovery/nuclei PR: 6322
File: pkg/templates/compile.go:79-81
Timestamp: 2025-07-16T21:27:14.937Z
Learning: To make the template caching mechanism in pkg/templates/compile.go production-ready, DSLs need to be updated to use runtime options instead of cached variables, rather than restoring the Compile() calls on each request.
Learnt from: hdm
Repo: projectdiscovery/nuclei PR: 6322
File: pkg/templates/compile.go:79-81
Timestamp: 2025-07-16T21:27:14.937Z
Learning: In pkg/templates/compile.go, the template caching mechanism intentionally skips calling Compile() on copied requests to achieve performance benefits. This is the intended design, not a bug. The current implementation isn't production-ready but represents the desired direction.
📚 Learning: 2025-09-05T14:23:55.257Z
Learnt from: CR
Repo: projectdiscovery/nuclei PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-05T14:23:55.257Z
Learning: Applies to pkg/protocols/**/*.go : Each protocol implementation must provide a Request interface with methods Compile(), ExecuteWithResults(), Match(), and Extract()
Applied to files:
pkg/protocols/file/request.gopkg/protocols/file/request_test.go
🧬 Code graph analysis (3)
pkg/core/workflow_execute.go (2)
pkg/scan/scan_context.go (1)
NewScanContext(47-49)pkg/protocols/common/contextargs/contextargs.go (1)
Context(22-33)
pkg/protocols/file/request_test.go (7)
pkg/testutils/testutils.go (2)
NewMockExecuterOptions(94-116)TemplateInfo(87-91)pkg/model/types/severity/severity.go (3)
Holder(70-72)Severity(11-11)Low(20-20)pkg/protocols/protocols.go (1)
Request(308-333)pkg/operators/operators.go (1)
Operators(19-45)pkg/operators/matchers/matchers_types.go (3)
MatcherTypeHolder(77-79)MatcherType(12-12)WordsMatcher(17-17)pkg/protocols/common/contextargs/contextargs.go (1)
NewWithInput(48-64)pkg/output/output.go (2)
InternalWrappedEvent(100-113)InternalEvent(93-93)
cmd/integration-test/integration-test.go (1)
pkg/testutils/fuzzplayground/db.go (1)
Cleanup(35-42)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Tests (windows-latest)
- GitHub Check: Tests (ubuntu-latest)
|
@coderabbitai resolve |
✅ Actions performedComments resolved. |
Mzack9999
left a comment
There was a problem hiding this comment.
Note: should we keep sequential processing for file protocol in case stop at first match is requested in order to preserve real first match?
|
^ answered on Slack thread. @dogancanbakir I think we can ship this in #6605. |
Proposed changes
add missing
gokeyword to anonymous funcs thatwere intended to run as goroutines but were
executing synchronously instead.
Fixes #6492
Proof
this PR
dev
Note
Apply bcf7a90 patch first.
Checklist
Summary by CodeRabbit