-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add resume option to sdk #6083
base: dev
Are you sure you want to change the base?
add resume option to sdk #6083
Conversation
WalkthroughThis change introduces a new function, Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant F as WithResumeFile
participant E as NucleiEngine
U->>F: Invoke WithResumeFile("resume.txt")
F->>E: Set Resume field to "resume.txt"
E-->>F: Return nil (successful execution)
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
lib/config.go (2)
514-521
: The implementation looks good but documentation could be improved.The function follows the pattern of other option-setting functions in the codebase. However, the documentation could be enhanced to provide more context about what a resume file is used for, what format it expects, and any limitations or requirements.
Consider expanding the comment to be more descriptive, similar to other option-setting functions:
-// WithResumeFile allows setting a resume file +// WithResumeFile allows setting a resume file path to resume scanning from a previous scan. +// The resume file contains the progress state of a previous scan which enables +// continuing from where the scan was stopped.
516-520
: Consider adding validation for the file parameter.Many other option-setting functions in the file include validation logic, but this function accepts any string without validation.
Add basic validation to ensure the file parameter is not empty:
func WithResumeFile(file string) NucleiSDKOptions { return func(e *NucleiEngine) error { + if file == "" { + return errors.New("resume file path cannot be empty") + } e.opts.Resume = file return nil } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/config.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Tests (macOS-latest)
- GitHub Check: Tests (windows-latest)
- GitHub Check: Tests (ubuntu-latest)
func WithResumeFile(file string) NucleiSDKOptions { | ||
return func(e *NucleiEngine) error { | ||
e.opts.Resume = file | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify if thread-safety check is needed.
Some configuration functions in this file check if the engine is running in thread-safe mode (if e.mode == threadSafe
) and return an error if the option is not supported in that mode. Consider whether this option should have a similar check.
🏁 Script executed:
#!/bin/bash
# Check if other similar file-setting functions check for thread-safe mode
echo "Checking if other file-setting functions check for thread-safe mode..."
rg "e.mode == threadSafe" --context 10 lib/config.go | grep -A 10 -B 10 "func With.*File"
Length of output: 897
Action Required: Add Thread-Safety Check to WithResumeFile
Based on the output from similar functions (e.g., WithSandboxOptions
and WithTemplateUpdateCallback
), it’s evident that a thread-safety check is applied before setting file-related options. To maintain consistency and avoid unsupported behavior when the engine runs in thread-safe mode, consider adding a check for thread-safe mode in WithResumeFile
. For example:
func WithResumeFile(file string) NucleiSDKOptions {
return func(e *NucleiEngine) error {
if e.mode == threadSafe {
return ErrOptionsNotSupported.Msgf("WithResumeFile")
}
e.opts.Resume = file
return nil
}
}
Please evaluate if the resume file functionality should be restricted in thread-safe mode and update accordingly.
Proposed changes
Closes #6078
Checklist
Summary by CodeRabbit