Skip to content

Fix host discovery#1553

Merged
Mzack9999 merged 3 commits intoprojectdiscovery:devfrom
mielverkerken:dev
Sep 15, 2025
Merged

Fix host discovery#1553
Mzack9999 merged 3 commits intoprojectdiscovery:devfrom
mielverkerken:dev

Conversation

@mielverkerken
Copy link
Copy Markdown
Contributor

@mielverkerken mielverkerken commented Sep 13, 2025

Fixes #1531

Bug introduced in PR #1431 if no excludedIpsNP is set on runner.

Version 2.3.5

Host discovery is not outputted.

$ sudo naabu -host google.com -sn

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/

                projectdiscovery.io

[INF] Current naabu version 2.3.5 (latest)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
[INF] Running host discovery scan

Host discovery outputs as expected when a host is excluded.

$ sudo naabu -host google.com -sn -exclude-hosts 0.0.0.0

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/

                projectdiscovery.io

[INF] Current naabu version 2.3.5 (latest)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
[INF] Running host discovery scan
[INF] Found alive host google.com (74.125.206.100)
google.com

This PR

Host discovery outputs again as expected

$ sudo ./naabu -host google.com -sn                       

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/

                projectdiscovery.io

[INF] Current naabu version 2.3.5 (latest)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
[INF] Running host discovery scan
[INF] Found alive host google.com (74.125.206.139)
google.com

Summary by CodeRabbit

  • Bug Fixes
    • Host discovery now runs across all IPs within specified CIDRs when no denylist is configured.
    • When a denylist is present, discovery still respects exclusions.
    • Improves coverage and predictability of network enumeration in default setups with no configuration changes required.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 13, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • .github/workflows/lint-test.yml is excluded by !**/*.yml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Updates host-discovery gating during CIDR enumeration: when excludedIpsNP is nil, discovery runs for every expanded IP; when present, discovery runs only for IPs where ValidateAddress(ip) returns true. No other logic or public signatures changed.

Changes

Cohort / File(s) Summary of edits
Host discovery gating logic
pkg/runner/runner.go
Modified per-IP CIDR discovery condition from if r.excludedIpsNP != nil && r.excludedIpsNP.ValidateAddress(ip) to `if r.excludedIpsNP == nil

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Runner
  participant DenyList as ExcludedIpsNP
  participant Discovery as Host Discovery

  User->>Runner: RunEnumeration(CIDR)
  loop for each IP in CIDR
    alt DenyList is nil
      note right of Runner #E6F7FF: New: allow discovery for all IPs
      Runner->>Discovery: discover(IP)
    else DenyList present
      Runner->>DenyList: ValidateAddress(IP)
      alt Valid
        Runner->>Discovery: discover(IP)
      else Invalid
        note right of Runner #FFF4E6: Skip IP
      end
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble code and sniff the net,
If no denylist, every hop I let.
With lists I tiptoe, quiet and sly,
Finding hosts beneath the sky.
Carrots glow when scans reply. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix host discovery" is concise, directly related to the primary change in the patch (restoring host discovery behavior), and is clear enough for a reviewer to understand the main intent at a glance.
Linked Issues Check ✅ Passed The change updates the host-discovery gating from requiring a non-nil excludedIpsNP to allowing discovery when r.excludedIpsNP is nil (or when ValidateAddress returns true), which directly addresses the regression described in issue #1531 by restoring discovery output when no excluded hosts are configured while preserving denylist behavior; the raw summary indicates this is the sole functional change and no exported signatures were modified.
Out of Scope Changes Check ✅ Passed Per the provided summary, the diff is limited to the conditional that gates per-IP host discovery in pkg/runner/runner.go and does not touch other files or public APIs, so there are no detectable out-of-scope or unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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 and usage tips.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (1)
pkg/runner/runner.go (1)

325-327: Solid fix; simplify the conditional for clarity (no behavior change).

The new gating correctly restores host discovery when no denylist is set. You can drop the redundant nil-check in the second disjunct.

-                if r.excludedIpsNP == nil || (r.excludedIpsNP != nil && r.excludedIpsNP.ValidateAddress(ip)) {
+                if r.excludedIpsNP == nil || r.excludedIpsNP.ValidateAddress(ip) {
                     r.handleHostDiscovery(ip)
                 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e656154 and 43b3788.

📒 Files selected for processing (1)
  • pkg/runner/runner.go (1 hunks)

@ehsandeep ehsandeep requested a review from Mzack9999 September 15, 2025 15:20
@Mzack9999 Mzack9999 merged commit 75db5d2 into projectdiscovery:dev Sep 15, 2025
10 checks passed
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.

2.3.5 Regression - Host Discovery Failing

2 participants