diff --git a/lib/rogue_one/detector.rb b/lib/rogue_one/detector.rb index 9d635dc..c349c15 100644 --- a/lib/rogue_one/detector.rb +++ b/lib/rogue_one/detector.rb @@ -15,11 +15,9 @@ def initialize(target:) end def report - @report ||= [].tap do |out| - inspect + inspect - out << { verdict: verdict, landing_pages: landing_pages } - end.first + { verdict: verdict, landing_pages: landing_pages } end private @@ -35,10 +33,12 @@ def rogue_one? def landing_pages @memo.map do |ip, count| count > 10 ? ip : nil - end.compact + end.compact.sort end def inspect + return unless @memo.empty? + results = Parallel.map(top_100_domains) do |domain| normal_result = normal_resolver.dig(domain, "A") target_result = target_resolver.dig(domain, "A") diff --git a/spec/detector_spec.rb b/spec/detector_spec.rb index dc811bc..efba7af 100644 --- a/spec/detector_spec.rb +++ b/spec/detector_spec.rb @@ -18,5 +18,18 @@ it do expect(report.dig(:landing_pages)).to eq([]) end + + context "with landing pages" do + let(:memo) { { "9.9.9.9" => 11, "8.8.8.8" => 11, "1.1.1.1" => 11 } } + + before do + subject.instance_variable_set("@memo", memo) + end + + it do + report = subject.report + expect(report.dig(:landing_pages)).to eq(memo.keys.sort) + end + end end end