test(nuclei): adds multiproto benchmark test#6270
Conversation
Signed-off-by: Dwi Siswanto <git@dw1.io>
WalkthroughThe benchmark test for the nuclei command was refactored to introduce a Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ 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 (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
cmd/nuclei/main_benchmark_test.go (2)
16-19: Avoid global‐local variable shadowing for clarity & correctness
getDefaultOptionsre-creates its ownprojectPathvariable, silently shadowing the package-levelprojectPath.
Although both point to temp dirs, the shadowing easily confuses readers and makes it unclear which directory is being cleaned up inTestMain. Renaming the globals (e.g.baseProjectPath) or removing the global entirely would prevent future mistakes.
122-139: Addb.Cleanupfor temp dir & improve path robustnessAfter adopting the proposed
getDefaultOptionscleanup callback, remember to register it in each sub-benchmark:opts, cleanup := getDefaultOptions() b.Cleanup(cleanup)Additionally,
options.Templates = []string{"./cmd/nuclei/testdata/benchmark/multiproto/"}is a relative path; the working directory duringgo test ./...is not guaranteed. Usefilepath.Joinwitht.TempDir()ortestingpackage’sb.TempDir()to copy the testdata tree, orruntime.Callerto build an absolute path.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
cmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto-mixed.yamlis excluded by!**/*.yamlcmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto-raw.yamlis excluded by!**/*.yamlcmd/nuclei/testdata/benchmark/multiproto/basic-template-multiproto.yamlis excluded by!**/*.yaml
📒 Files selected for processing (1)
cmd/nuclei/main_benchmark_test.go(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/nuclei/main_benchmark_test.go (1)
internal/runner/options.go (1)
ParseOptions(56-138)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Lint
Signed-off-by: Dwi Siswanto <git@dw1.io>
Proposed changes
Follow up on #6253 #6258
Hopefully this gets caught by perf-regression test workflow.
Checklist
Summary by CodeRabbit