Skip to content

Print config directories in -hc and verbose modes - #7578

Merged
dwisiswant0 merged 2 commits into
devfrom
4880-config-dirs
Jul 26, 2026
Merged

Print config directories in -hc and verbose modes#7578
dwisiswant0 merged 2 commits into
devfrom
4880-config-dirs

Conversation

@Mzack9999

@Mzack9999 Mzack9999 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

Summary by CodeRabbit

  • New Features
    • Added configuration/cache/PDCP directory details to health-check output.
    • When verbose modes are enabled, startup logs now display configuration, cache, and PDCP directory locations.
    • Version output now includes the relevant nuclei directory paths.
  • Bug Fixes
    • Standardized directory reporting across health checks, verbose startup logs, and version output.
  • Tests
    • Added a unit test to verify the directory info output format/content.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99973fd3-4521-46af-a251-33e755629d1e

📥 Commits

Reviewing files that changed from the base of the PR and between 7f059a3 and 070d622.

📒 Files selected for processing (5)
  • cmd/nuclei/main.go
  • internal/runner/directories.go
  • internal/runner/directories_test.go
  • internal/runner/healthcheck.go
  • internal/runner/runner.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/runner/healthcheck.go
  • cmd/nuclei/main.go
  • internal/runner/directories.go

Walkthrough

Centralizes config, cache, and PDCP directory reporting, then exposes it in version output, health checks, and verbose or very verbose startup logs. Tests verify the shared formatting.

Changes

Directory diagnostics

Layer / File(s) Summary
Shared directory reporting
internal/runner/directories.go
Adds helpers to format directory paths, return them as text, and log them with a nil-logger guard.
Command context integration and validation
internal/runner/healthcheck.go, internal/runner/runner.go, cmd/nuclei/main.go, internal/runner/directories_test.go
Adds directory output to health checks, verbose startup, and version printing, with tests for labels and formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NucleiCLI
  participant runner.New
  participant DoHealthCheck
  participant DirectoryHelpers
  NucleiCLI->>runner.New: start with verbose flags
  runner.New->>DirectoryHelpers: LogDirectoryInfo(logger)
  NucleiCLI->>DoHealthCheck: run health check
  DoHealthCheck->>DirectoryHelpers: AppendDirectoryInfo(writer)
  NucleiCLI->>DirectoryHelpers: printVersion
  DirectoryHelpers-->>NucleiCLI: formatted directory paths
Loading

Suggested reviewers: dwisiswant0

Poem

A rabbit hops through config and cache,
PDCP paths printed in a flash.
Verbose logs and health checks align,
Version output looks neat and fine.
Three little directories shine!

🚥 Pre-merge checks | ✅ 5
✅ 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 is concise and accurately describes the main behavior change in -hc and verbose modes.
Linked Issues check ✅ Passed The changes add shared directory logging to -hc and -v/-vv startup, matching the issue's requested outputs.
Out of Scope Changes check ✅ Passed All changes stay within directory-reporting and related tests; no unrelated functionality was introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 4880-config-dirs

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: 1

🧹 Nitpick comments (1)
internal/runner/directories_test.go (1)

10-15: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the reported directory values, not only their labels.

This test would pass if the helper printed incorrect paths while retaining the expected labels. Compare against GetConfigDir(), GetCacheDir(), and pdcpauth.PDCPDir, or assert the complete formatted string.

🤖 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 `@internal/runner/directories_test.go` around lines 10 - 15, Update
TestDirectoryInfoContainsKnownLabels to validate the directory values as well as
their labels by comparing DirectoryInfo() with GetConfigDir(), GetCacheDir(),
and pdcpauth.PDCPDir, or by asserting the complete expected formatted output
while preserving the existing newline-count check.
🤖 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 `@internal/runner/directories_test.go`:
- Line 19: Update the test around DoHealthCheck to avoid invoking its live
network probe; extract the health-check result formatting path or inject a
mockable dialer, then test that isolated behavior with deterministic inputs.
Ensure the test no longer dials scanme.sh or depends on network availability.

---

Nitpick comments:
In `@internal/runner/directories_test.go`:
- Around line 10-15: Update TestDirectoryInfoContainsKnownLabels to validate the
directory values as well as their labels by comparing DirectoryInfo() with
GetConfigDir(), GetCacheDir(), and pdcpauth.PDCPDir, or by asserting the
complete expected formatted output while preserving the existing newline-count
check.
🪄 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: 483c20b1-0559-44f6-a6bf-814b6e636fed

📥 Commits

Reviewing files that changed from the base of the PR and between bcf2089 and 7f059a3.

📒 Files selected for processing (5)
  • cmd/nuclei/main.go
  • internal/runner/directories.go
  • internal/runner/directories_test.go
  • internal/runner/healthcheck.go
  • internal/runner/runner.go

Comment thread internal/runner/directories_test.go Outdated
}

func TestDoHealthCheckIncludesDirectoryInfo(t *testing.T) {
out := DoHealthCheck(nil)

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Keep this test independent of live network probes.

DoHealthCheck(nil) also dials scanme.sh without timeouts, so this unit test can hang or fail when CI lacks network access. Extract the formatting path or inject a mockable dialer instead of invoking the full health check here.

🤖 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 `@internal/runner/directories_test.go` at line 19, Update the test around
DoHealthCheck to avoid invoking its live network probe; extract the health-check
result formatting path or inject a mockable dialer, then test that isolated
behavior with deterministic inputs. Ensure the test no longer dials scanme.sh or
depends on network availability.

@dwisiswant0
dwisiswant0 merged commit 437897d into dev Jul 26, 2026
29 of 30 checks passed
@dwisiswant0
dwisiswant0 deleted the 4880-config-dirs branch July 26, 2026 10:57
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.

Provide config directory details in other contexts

2 participants