Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make "landing_pages" values sorted #7

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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