fix: dedup json output by host+url when ip and port are empty - #727
fix: dedup json output by host+url when ip and port are empty#727ShubhamRasal wants to merge 2 commits into
Conversation
WriteJsonData was deduping on "ip:port", which collapses to ":0" for sources that don't return ip info (e.g. nerdydata). every result after the first was dropped as a duplicate, so -j printed only one row. fall back to host+url when ip and port are both empty. keep ip:port dedup for shodan/censys/fofa so two sources hitting the same service still collapse into one row.
Neo - PR Security ReviewNo security issues found Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughWriteJsonData in ChangesDeduplication Key Fallback Logic
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
runner/output_writer.go (1)
69-71: Use an unambiguous composite key forHost+Url.
data.Host + "|" + data.Urlcan theoretically collide if either field contains|. Consider escaping/quoting both parts.Proposed hardening
- key = data.Host + "|" + data.Url + key = fmt.Sprintf("%q|%q", data.Host, data.Url)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@runner/output_writer.go` around lines 69 - 71, The composite key built as key = data.Host + "|" + data.Url is ambiguous if Host or Url contain "|"—replace this with an unambiguous encoding: encode or escape both data.Host and data.Url and then join them, for example by JSON-serializing a two-element array or base64-encoding each part before concatenation; update the place that assigns key (the code using variable key and fields data.Host and data.Url) to use the chosen safe encoding/escaping approach so the composite key cannot collide.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@runner/output_writer.go`:
- Around line 69-71: The composite key built as key = data.Host + "|" + data.Url
is ambiguous if Host or Url contain "|"—replace this with an unambiguous
encoding: encode or escape both data.Host and data.Url and then join them, for
example by JSON-serializing a two-element array or base64-encoding each part
before concatenation; update the place that assigns key (the code using variable
key and fields data.Host and data.Url) to use the chosen safe encoding/escaping
approach so the composite key cannot collide.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8d2fffd8-fda9-434f-9abc-d1a3d967d5cf
📒 Files selected for processing (1)
runner/output_writer.go
Summary
-j(JSON output) only printed the first result for sources that don't return IP info (e.g.nerdydata).Root cause
OutputWriter.WriteJsonDatawas deduping results usingfmt.Sprintf("%s:%d", IP, Port). For sources where IP is empty and Port is 0, every result hashed to the same key:0, so all results after the first were dropped as duplicates.Repro (before fix)
Fix
Pick the dedup key based on what's populated:
IP:Port(preserves existing behaviour for shodan/censys/fofa, where two sources finding the same service should collapse into one row).Host|Url(covers nerdydata and any future source that returns hosts/URLs only).After fix
Test plan
./uncover -nerdydata jquery -silent -limit 10 -jprints all 10 results./uncover -nerdydata jquery -silent -limit 10(non-JSON) still prints all 10 (unchanged code path)Summary by CodeRabbit