Skip to content

Quiet unresolved-variable skips and summarize at scan end - #7572

Open
Mzack9999 wants to merge 1 commit into
devfrom
3386-unresolved-log
Open

Quiet unresolved-variable skips and summarize at scan end#7572
Mzack9999 wants to merge 1 commit into
devfrom
3386-unresolved-log

Conversation

@Mzack9999

@Mzack9999 Mzack9999 commented Jul 23, 2026

Copy link
Copy Markdown
Member

Mutes per-request unresolved-variable warnings by default, counts skips, and prints one end-of-scan summary. Use -log-unresolved to restore per-request details.

Closes #3386

Summary by CodeRabbit

  • New Features

    • Added -log-unresolved (-lu) to optionally display warnings for requests skipped بسبب unresolved template variables.
    • Progress reporting now includes a count of requests skipped for unresolved variables.
    • DNS, HTTP, and network scans consistently skip unresolved-variable requests and summarize them after execution.
  • Bug Fixes

    • Reduced repetitive warning messages while preserving visibility into unresolved requests.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Unresolved Variable Handling

Layer / File(s) Summary
Progress and logging configuration
pkg/types/types.go, pkg/progress/*, cmd/nuclei/main.go, internal/tests/testutils/testutils.go
Adds the LogUnresolved option and progress counter APIs, initializes and tests the counter, and updates the mock progress client.
Centralized unresolved-variable helper
pkg/protocols/common/unresolvedvars/*
Adds unresolved-variable detection, skip counting, optional warning logging, and unit tests.
Protocol integration and scan reporting
pkg/protocols/{dns,http,network}/request.go, internal/runner/runner.go
Routes unresolved-variable cases through the helper and reports the aggregate skipped-request count after execution.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RequestProtocol
  participant unresolvedvars
  participant Progress
  participant Runner
  RequestProtocol->>unresolvedvars: Detect unresolved variable error
  unresolvedvars->>Progress: Increment skipped count
  RequestProtocol-->>Runner: Skip request
  Runner->>Progress: Read skipped count
  Runner-->>Runner: Log aggregate summary
Loading

Suggested reviewers: dwisiswant0

Poem

A rabbit hops through templates bright,
Counts skipped vars beneath moonlight.
Warnings hide unless flags say “show,”
Progress ticks as requests go.
At scan’s end, the tally sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.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 clearly summarizes the main change: reducing unresolved-variable noise and adding end-of-scan summary logging.
Linked Issues check ✅ Passed The PR implements the requested unresolved-variable logging suppression, skip counting, end-of-scan summary, and verbose toggle from #3386.
Out of Scope Changes check ✅ Passed The changes stay focused on unresolved-variable handling and logging, with no evident unrelated additions.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 3386-unresolved-log

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/progress/progress.go`:
- Around line 35-39: The exported Progress interface must remain
source-compatible for existing custom implementations. Remove
IncrementSkippedUnresolved and SkippedUnresolved from Progress, and introduce a
separate optional capability interface for unresolved-skip tracking; update
callers to use a type assertion before invoking those methods.

In `@pkg/protocols/common/unresolvedvars/unresolvedvars.go`:
- Around line 11-19: Replace the message-substring check in unresolvedvars.Is
with identity-based classification using a sentinel or typed
unresolved-variables error and errors.Is/errors.As. Update the producers and
wrapped-error paths to preserve that identity, while keeping nil and unrelated
errors returning false. Add a regression test proving an unrelated error
containing “unresolved variables” is not classified as a skip.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aa1910cf-60bd-48ea-a3d0-d43943a2ce00

📥 Commits

Reviewing files that changed from the base of the PR and between 6d81cc3 and 13a505b.

📒 Files selected for processing (11)
  • cmd/nuclei/main.go
  • internal/runner/runner.go
  • internal/tests/testutils/testutils.go
  • pkg/progress/progress.go
  • pkg/progress/progress_unresolved_test.go
  • pkg/protocols/common/unresolvedvars/unresolvedvars.go
  • pkg/protocols/common/unresolvedvars/unresolvedvars_test.go
  • pkg/protocols/dns/request.go
  • pkg/protocols/http/request.go
  • pkg/protocols/network/request.go
  • pkg/types/types.go

Comment thread pkg/progress/progress.go
Comment on lines +35 to +39
// IncrementSkippedUnresolved increments the count of requests skipped because
// template variables could not be resolved.
IncrementSkippedUnresolved(count int64)
// SkippedUnresolved returns how many requests were skipped for unresolved variables.
SkippedUnresolved() uint64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate files =="
git ls-files | rg '(^|/)progress\.go$|pkg/progress|progress' | head -100

echo "== inspect progress.go =="
if [ -f pkg/progress/progress.go ]; then
  wc -l pkg/progress/progress.go
  cat -n pkg/progress/progress.go
fi

echo "== search Progress usages =="
rg -n "type Progress|interface \{\n|Progress\)|Progress\." . | head -200

echo "== go fmt/vet dry checks if tools present =="
if command -v go >/dev/null 2>&1; then
  go fmt ./pkg/progress/... || true
  go vet ./pkg/progress/... || true
else
  echo "go not available"
fi

Repository: projectdiscovery/nuclei

Length of output: 12013


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== go command availability =="
if command -v go >/dev/null 2>&1; then
  go version
  go fmt ./pkg/progress/...
  output="$(go vet ./pkg/progress/... 2>&1)" || true
  echo "$output"
else
  echo "go not available"
fi

echo "== Progress/progress related references =="
rg -n --multiline 'type Progress interface|func New.*Progress|Progress\)|\.New.*Progress|IncrementSkippedUnresolved|SkippedUnresolved|var _ Progress' . | head -300

Repository: projectdiscovery/nuclei

Length of output: 3298


Keep the public Progress contract source-compatible.

Progress is exported and progress.Progress is exposed through library paths, so adding IncrementSkippedUnresolved and SkippedUnresolved will make existing SDK/custom implementations fail to compile. Use an optional capability interface/type assertion, or document this as a breaking API change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/progress/progress.go` around lines 35 - 39, The exported Progress
interface must remain source-compatible for existing custom implementations.
Remove IncrementSkippedUnresolved and SkippedUnresolved from Progress, and
introduce a separate optional capability interface for unresolved-skip tracking;
update callers to use a type assertion before invoking those methods.

Comment on lines +11 to +19
const errSubstring = "unresolved variables"

// Is reports whether err is (or wraps) an unresolved-variables skip.
func Is(err error) bool {
if err == nil {
return false
}
return strings.Contains(strings.ToLower(err.Error()), errSubstring)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not classify errors by a free-form message substring.

Is turns any error whose text contains "unresolved variables" into a successful skip. Because callers suppress that error and increment only the skip metric, unrelated wrapped errors can be hidden and misreported. Use a sentinel or typed error with errors.Is/errors.As, and add a false-positive regression case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/protocols/common/unresolvedvars/unresolvedvars.go` around lines 11 - 19,
Replace the message-substring check in unresolvedvars.Is with identity-based
classification using a sentinel or typed unresolved-variables error and
errors.Is/errors.As. Update the producers and wrapped-error paths to preserve
that identity, while keeping nil and unrelated errors returning false. Add a
regression test proving an unrelated error containing “unresolved variables” is
not classified as a skip.

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.

Improve Error logging of unresolved variables

1 participant