-
Couldn't load subscription status.
- Fork 2.9k
Labels
Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.Inconsistencies or issues which will cause an issue or problem for users or implementors.
Description
Missing go keyword causing synchronous execution in workflow and file protocols.
Description
Two critical goroutines are missing the go keyword, causing them to execute synchronously instead of concurrently, which significantly impacts performance during template execution and file processing.
Affected components:
- Workflow execution
- File protocol processing
$ semgrep scan --config waitgroup-sequential-parallel.yaml ~/Development/PD/nuclei/
┌──── ○○○ ────┐
│ Semgrep CLI │
└─────────────┘
Scanning 843 files (only git-tracked) with 1 Code rule:
CODE RULES
Scanning 481 files.
SUPPLY CHAIN RULES
No rules to run.
PROGRESS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
┌─────────────────┐
│ 2 Code Findings │
└─────────────────┘
/home/dw1/Development/PD/nuclei/pkg/core/workflow_execute.go
❯❯❱ waitgroup-sequential-parallel
Detected inline function after WaitGroup.Add() that runs sequentially. This looks like an
attempt at parallelism, but without the 'go' keyword the function executes synchronously.
Did you mean `go func(...) { ... }()`?
37┆ swg.Add()
38┆
39┆ func(template *workflows.WorkflowTemplate) {
40┆ defer swg.Done()
41┆
42┆ if err := e.runWorkflowStep(template, ctx, results, swg, w); err != nil {
43┆ gologger.Warning().Msgf(workflowStepExecutionError, template.Template,
err)
44┆ }
45┆ }(template)
/home/dw1/Development/PD/nuclei/pkg/protocols/file/request.go
❯❯❱ waitgroup-sequential-parallel
Detected inline function after WaitGroup.Add() that runs sequentially. This looks like an
attempt at parallelism, but without the 'go' keyword the function executes synchronously.
Did you mean `go func(...) { ... }()`?
61┆ wg.Add()
62┆ func(filePath string) {
63┆ defer wg.Done()
64┆ fi, err := os.Open(filePath)
65┆ if err != nil {
66┆ gologger.Error().Msgf("%s\n", err)
67┆ return
68┆ }
69┆ defer func() {
70┆ _ = fi.Close()
[hid 118 additional lines, adjust with --max-lines-per-finding]
┌──────────────┐
│ Scan Summary │
└──────────────┘
✅ Scan completed successfully.
• Findings: 2 (2 blocking)
• Rules run: 1
• Targets scanned: 481
• Parsed lines: ~100.0%
• Scan skipped:
◦ Files larger than files 1.0 MB: 6
◦ Files matching .semgrepignore patterns: 124
• Scan was limited to files tracked by git
• For a detailed list of skipped files and lines, run semgrep with the --verbose flag
Ran 1 rule on 481 files: 2 findings.Impact
- Performance degradation due to synchronous execution where parallel processing was intended.
- Potential bottlenecks during large-scale scans with multiple templates or files.
WaitGroupsare used but goroutines run sequentially.
knakul853
Metadata
Metadata
Assignees
Labels
Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.Inconsistencies or issues which will cause an issue or problem for users or implementors.