Skip to content

refactor(types)!: make resume state as cache data#7042

Open
dwisiswant0 wants to merge 1 commit intodevfrom
dwisiswant0/refactor/types/make-resume-state-as-cache-data
Open

refactor(types)!: make resume state as cache data#7042
dwisiswant0 wants to merge 1 commit intodevfrom
dwisiswant0/refactor/types/make-resume-state-as-cache-data

Conversation

@dwisiswant0
Copy link
Member

@dwisiswant0 dwisiswant0 commented Feb 25, 2026

Proposed changes

Resume files are runtime artifacts and SHOULD NOT
be presented as persistent config.

Update reset messaging to separate config vs cache
and explicitly include resume state under cache
cleanup. Also delete the cache dir during -reset
to keep behavior aligned with the new semantics.

Close #6792

Proof

N/A

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced reset functionality to ensure complete cleanup of all related data: configuration files, cache files with resume state, and nuclei-templates directory are all removed together.
    • Updated warning messages to provide clear visibility into all three major areas of data that will be affected and permanently deleted during the reset process.

Resume files are runtime artifacts and SHOULD NOT
be presented as persistent config.

Update reset messaging to separate config vs cache
and explicitly include resume state under cache
cleanup. Also delete the cache dir during `-reset`
to keep behavior aligned with the new semantics.

Close #6792

Signed-off-by: Dwi Siswanto <git@dw1.io>
@auto-assign auto-assign bot requested a review from Mzack9999 February 25, 2026 23:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

Walkthrough

The changes relocate resume configuration storage from the config directory to the cache directory, reflecting its transient nature. The reset flow is updated to delete the cache directory alongside the config directory, with warning messaging adjusted to list all three deleted areas.

Changes

Cohort / File(s) Summary
Reset Flow Update
cmd/nuclei/main.go
Updated reset callback to delete cache directory after config directory; warning text extended to list three deleted areas: config files, cache files (including resume state), and nuclei-templates.
Resume Path Logic
pkg/types/resume.go
Renamed configDir variable to cacheDir in DefaultResumeFilePath function to align with resume configuration now stored in cache directory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Resume files hop away with glee,
From config cluttered, finally free!
To cache they flutter, transient and light,
Runtime data, oh what a delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(types)!: make resume state as cache data' directly and clearly summarizes the main change: moving resume state from config to cache.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #6792 by moving resume state out of config into cache directory and updating reset behavior accordingly.
Out of Scope Changes check ✅ Passed All changes are directly related to moving resume state to cache: modifying reset flow, updating cache deletion logic, and renaming variables to reflect cache semantics.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dwisiswant0/refactor/types/make-resume-state-as-cache-data

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
cmd/nuclei/main.go (1)

782-785: Consider adding path validation before destructive reset deletions.

The -reset handler deletes three directories without validating that the paths are safe. While the user confirmation message displays the paths being deleted—which is a strong existing safeguard—adding pre-deletion checks would provide defense-in-depth against misconfiguration or unexpected path values from environment variables (NUCLEI_CONFIG_DIR, NUCLEI_TEMPLATES_DIR).

Consider validating that paths are non-empty, not system root (/), and not duplicate before calling os.RemoveAll(). Example pattern:

clean := filepath.Clean(path)
if clean == "" || clean == "." || clean == string(filepath.Separator) {
    options.Logger.Fatal().Msgf("refusing to delete unsafe path: %q", path)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/nuclei/main.go` around lines 782 - 785, Before calling os.RemoveAll for
the reset flow, validate each path returned by
config.DefaultConfig.GetCacheDir(), config.DefaultConfig.GetConfigDir(), and
config.DefaultConfig.GetTemplatesDir(): ensure the cleaned path (use
filepath.Clean on the value) is non-empty, not "." and not the OS path separator
(root), and reject duplicates among the three; if a path is unsafe, call
options.Logger.Fatal().Msgf with a clear “refusing to delete unsafe path”
message referencing the offending value instead of deleting it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/nuclei/main.go`:
- Around line 754-756: The reset/cleanup messaging is inconsistent: you added
the "All cache files (including resume state) at %v" line but the later success
message (the string that currently says only config + templates) and the other
occurrence still omit cache; update those success messages to mention cache as
well. Locate the print/log strings that output "All config files at %v", "All
cache files (including resume state) at %v" and "All nuclei-templates at %v" and
change the corresponding success message(s) (the one near the reset completion
and the duplicate around the 760 area) so they list config, cache, and
nuclei-templates consistently.

---

Nitpick comments:
In `@cmd/nuclei/main.go`:
- Around line 782-785: Before calling os.RemoveAll for the reset flow, validate
each path returned by config.DefaultConfig.GetCacheDir(),
config.DefaultConfig.GetConfigDir(), and config.DefaultConfig.GetTemplatesDir():
ensure the cleaned path (use filepath.Clean on the value) is non-empty, not "."
and not the OS path separator (root), and reject duplicates among the three; if
a path is unsafe, call options.Logger.Fatal().Msgf with a clear “refusing to
delete unsafe path” message referencing the offending value instead of deleting
it.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72b6919 and 0b1faf6.

📒 Files selected for processing (2)
  • cmd/nuclei/main.go
  • pkg/types/resume.go

Comment on lines +754 to +756
1. All config files at %v
2. All cache files (including resume state) at %v
3. All nuclei-templates at %v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Keep reset messaging symmetric after adding cache deletion.

Line 755 now states cache cleanup, but the success message at Line 790 still says only config + templates. Please update it to include cache for consistency.

Suggested wording update
- options.Logger.Info().Msgf("Successfully deleted all nuclei configurations files and nuclei-templates")
+ options.Logger.Info().Msgf("Successfully deleted nuclei config files, cache files, and nuclei-templates")

Also applies to: 760-760

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/nuclei/main.go` around lines 754 - 756, The reset/cleanup messaging is
inconsistent: you added the "All cache files (including resume state) at %v"
line but the later success message (the string that currently says only config +
templates) and the other occurrence still omit cache; update those success
messages to mention cache as well. Locate the print/log strings that output "All
config files at %v", "All cache files (including resume state) at %v" and "All
nuclei-templates at %v" and change the corresponding success message(s) (the one
near the reset completion and the duplicate around the 760 area) so they list
config, cache, and nuclei-templates consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Move resume config to temp/cache dir

1 participant