Skip to content

Commit

Permalink
chore: make "landing_pages" values sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed May 1, 2019
1 parent 43ef63e commit 18a16bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/rogue_one/detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
13 changes: 13 additions & 0 deletions spec/detector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 18a16bd

Please sign in to comment.