Skip to content

Conversation

@dwisiswant0
Copy link
Member

@dwisiswant0 dwisiswant0 commented Dec 14, 2025

Proposed changes

fix(hosterrorscache): dup log spam for permanent errs

The "Skipped X from target list as found
unresponsive permanently" message was logged on
every (*Cache).Check() call for hosts with
permanent errors, resulting in thousands of
duplicate log entries in verbose mode.

Wrap the log statement in sync.Once to match the
behavior already used for non-permanent error
logging.

Fixes #6416.

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

    • Simplified error log formatting by removing colorization from execution failure messages for improved readability.
  • New Features

    • Enhanced error detection to better identify and handle permanent host-related network failures.

✏️ Tip: You can customize this high-level summary in your review settings.

The "Skipped X from target list as found
unresponsive permanently" message was logged on
every `(*Cache).Check()` call for hosts with
permanent errors, resulting in thousands of
duplicate log entries in verbose mode.

Wrap the log statement in `sync.Once` to match the
behavior already used for non-permanent error
logging.

Signed-off-by: Dwi Siswanto <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 14, 2025

Walkthrough

The changes fix excessive logging on unresponsive hosts in verbose mode by introducing a new IsPermanentErr method to the host errors cache interface and updating logging behavior to report permanent errors only once at Info level. Additionally, colorization is removed from execution error logs.

Changes

Cohort / File(s) Change Summary
Host Error Cache Interface & Implementation
pkg/protocols/common/hosterrorscache/hosterrorscache.go
Added new public method IsPermanentErr to CacheInterface and implemented it in Cache type to determine if an error is permanent for a host. Updated Check method to log permanent errors at Info level wrapped in cache.Do for single-occurrence logging.
Test Stub Updates
pkg/protocols/http/request_test.go
Added IsPermanentErr method stub to fakeHostErrorsCache test type returning false.
Execution Error Logging
pkg/core/executors.go
Removed colorization from log messages in executeTemplateWithTargets and executeTemplatesOnTarget when reporting execution failures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Attention area: The logging behavior change in hosterrorscache.go's Check method—verify that the cache.Do wrapper correctly prevents duplicate logs and that Info level is appropriate for permanent error reporting
  • Verify the IsPermanentErr logic correctly identifies permanent errors and handles nil errors
  • Confirm test stub implementation matches the interface contract

Poem

🐰 Quiet logs now for hosts that won't reply,
No colorful clutter filling up the sky.
One message once, no echoes through the din,
Permanent errors cached with a careful grin!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix(hosterrorscache): dup log spam for permanent errs' directly and concisely summarizes the main change—fixing duplicate log spam for permanent errors in the hosterrorscache module.
Linked Issues check ✅ Passed The PR successfully addresses issue #6416 by implementing logging deduplication for permanent host errors, ensuring only one error log per unresponsive host instead of repeated entries in verbose mode.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing duplicate logging for permanent errors: new IsPermanentErr method, adjusted logging in Check method, and test stub implementation are all within scope of issue #6416.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dwisiswant0/fix/hosterrorscache/dup-log-spam-for-permanent-errs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf3b5bf and 8a583bf.

📒 Files selected for processing (3)
  • pkg/core/executors.go (2 hunks)
  • pkg/protocols/common/hosterrorscache/hosterrorscache.go (3 hunks)
  • pkg/protocols/http/request_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: Format Go code using go fmt ./...
Run static analysis using go vet ./... on Go code

Files:

  • pkg/protocols/http/request_test.go
  • pkg/core/executors.go
  • pkg/protocols/common/hosterrorscache/hosterrorscache.go
pkg/protocols/**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

pkg/protocols/**/*.go: Each protocol implementation should implement the Request interface with Compile(), ExecuteWithResults(), Match(), and Extract() methods
Protocol implementations should embed Operators for matching/extraction functionality

Files:

  • pkg/protocols/http/request_test.go
  • pkg/protocols/common/hosterrorscache/hosterrorscache.go
pkg/core/**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

Execution engine with work pools and template clustering should be implemented in pkg/core

Files:

  • pkg/core/executors.go
🧬 Code graph analysis (1)
pkg/protocols/common/hosterrorscache/hosterrorscache.go (1)
pkg/protocols/common/contextargs/contextargs.go (1)
  • Context (22-33)
⏰ 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). (1)
  • GitHub Check: Lint
🔇 Additional comments (5)
pkg/protocols/http/request_test.go (1)

277-278: LGTM!

The fake implementation correctly satisfies the new CacheInterface method. Returning false is appropriate for tests that don't need to simulate permanent error behavior.

pkg/core/executors.go (1)

115-115: Verify intentional removal of colorization.

The template ID colorization (e.executerOpts.Colorizer.BrightBlue(template.ID)) was removed from this warning log. This change appears unrelated to the primary fix for duplicate permanent error logging.

Was this intentional? If so, consider documenting the rationale or handling this in a separate commit for cleaner change tracking.

pkg/protocols/common/hosterrorscache/hosterrorscache.go (3)

30-30: Breaking change: new interface method.

Adding IsPermanentErr to CacheInterface is a breaking change for users implementing custom cache interfaces (as noted in the interface comment at Line 21-22). This is acceptable for the fix but worth noting in release notes.

Ensure this breaking change is documented for users who embed Nuclei as a library and implement their own CacheInterface.


140-144: Core fix looks correct.

Using cache.Do() (the embedded sync.Once) ensures the permanent error log message is emitted only once per host, directly addressing the duplicate log spam issue described in #6416. The pattern is consistent with the existing non-permanent error logging at Lines 148-150.


237-257: Implementation is correct.

The method properly checks both the error type via errkit.IsKind and the cached permanent error state. The mutex lock ensures thread-safe access to isPermanentErr.

Note: The err parameter is used both for type checking (Lines 243-245) and cache key derivation (Line 247), which aligns with GetKeyFromContext's behavior of extracting the address from error attributes when available. This is consistent with MarkFailedOrRemove.


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

@Mzack9999 Mzack9999 added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Jan 5, 2026
@dogancanbakir dogancanbakir merged commit 286fc91 into dev Jan 6, 2026
19 checks passed
@dogancanbakir dogancanbakir deleted the dwisiswant0/fix/hosterrorscache/dup-log-spam-for-permanent-errs branch January 6, 2026 08:07
@dwisiswant0 dwisiswant0 added this to the v3.7.0 milestone Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Fix extra logging when running in verbose mode on unresponsive hosts

4 participants