Skip to content

Conversation

circleous
Copy link

@circleous circleous commented Oct 4, 2025

Summary

If -srd or -sr flags is used, an index.txt file would be generated to store reponse file path, request URL, and it's response code. This happens 2 times for a single request, in which the first write doesn't even have the response path populated yet.

Before
$ go run ./cmd/httpx -u 'scanme.nmap.org' -sr -probe
    __    __  __       _  __
   / /_  / /_/ /_____ | |/ /
  / __ \/ __/ __/ __ \|   /
 / / / / /_/ /_/ /_/ /   |
/_/ /_/\__/\__/ .___/_/|_|
             /_/

                projectdiscovery.io

[INF] Current httpx version v1.7.1 (latest)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
http://scanme.nmap.org [SUCCESS]
$ cat output/response/index.txt
 http://scanme.nmap.org (200 OK)
output/response/scanme.nmap.org/052e162f32e4fcad8f5bb74af18524c3d2b2a420.txt http://scanme.nmap.org (200 OK)

Proposed Changes

$ go run ./cmd/httpx -u 'scanme.nmap.org' -sr -probe

    __    __  __       _  __
   / /_  / /_/ /_____ | |/ /
  / __ \/ __/ __/ __ \|   /
 / / / / /_/ /_/ /_/ /   |
/_/ /_/\__/\__/ .___/_/|_|
             /_/

                projectdiscovery.io

[INF] Current httpx version v1.7.1 (latest)
[WRN] UI Dashboard is disabled, Use -dashboard option to enable
http://scanme.nmap.org [SUCCESS]

$ cat output/response/index.txt
output/response/scanme.nmap.org/052e162f32e4fcad8f5bb74af18524c3d2b2a420.txt http://scanme.nmap.org (200 OK)

Summary by CodeRabbit

  • Refactor

    • Stopped writing per-response entries to index files, including screenshot indexing.
    • Output artifacts now exclude per-response index lines; responses and screenshots are still saved.
  • Chores

    • Reduced disk I/O during runs for faster, lighter execution.
    • No changes to filtering, storage behavior, or printed output paths beyond index removal.

Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

Removed index-writing blocks from runner/runner.go that previously appended per-response entries to main and screenshot index files. Core response processing, filtering, and storage logic remains unchanged. Control flow now skips persisting index entries, altering side effects and disk I/O during RunEnumeration.

Changes

Cohort / File(s) Summary
Runner index write removal
runner/runner.go
Deleted three blocks that wrote per-response entries to index files (main and screenshot). Kept response processing, filters, storage, and output path generation intact. Control flow no longer persists index lines when responses/screenshots are saved.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Runner
  participant Storage as Storage (responses/screenshots)
  participant Index as Index Files

  Caller->>Runner: RunEnumeration()
  loop For each response
    Runner->>Runner: Apply filters
    alt Should store response
      Runner->>Storage: Save response/screenshot
      note right of Runner: Index writes removed<br/>(no append to main/screenshot indexes)
      Runner--x Index: (No operation)
    else Skip storing
      Runner-->>Runner: Continue
    end
  end
  Runner-->>Caller: Return results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws at lines once penned,
No more we list each tiny end—
The disk now hums a softer tune,
While bytes of screenshots save the moon.
Hop, hop—responses safely stay,
But indexes have hopped away. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “fix: write to index only one time” concisely captures the primary change of preventing duplicate index writes after the response path is populated and aligns directly with the PR’s objective. It clearly indicates that a bug is being fixed and summarizes the main behavioral change without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@circleous circleous force-pushed the remove-double-entry-index branch from eaf6e9c to ee3b2ab Compare October 4, 2025 04:20
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.

1 participant