Skip to content

Commit

Permalink
Merge 7b90ff0 into 4e94be7
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Apr 29, 2019
2 parents 4e94be7 + 7b90ff0 commit 5924235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/rogue_one/detector.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "yaml"
require "parallel"

module RogueOne
class Detector
Expand All @@ -10,7 +11,7 @@ class Detector

def initialize(target:)
@target = target
@memo = Hash.new(0)
@memo = {}
end

def report
Expand Down Expand Up @@ -38,14 +39,14 @@ def landing_pages
end

def inspect
top_100_domains.each do |domain|
results = Parallel.map(top_100_domains) do |domain|
normal_result = normal_resolver.dig(domain, "A")
target_result = target_resolver.dig(domain, "A")

if normal_result != target_result
@memo[target_result] += 1 if target_result
end
end
target_result if target_result && normal_result != target_result
end.compact

@memo = results.group_by(&:itself).map { |k, v| [k, v.length] }.to_h
end

def top_100_domains
Expand Down
1 change: 1 addition & 0 deletions rogue_one.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake", "~> 12.3"
spec.add_development_dependency "rspec", "~> 3.8"

spec.add_dependency "parallel", "~> 1.17"
spec.add_dependency "thor", "~> 0.19"
end
1 change: 1 addition & 0 deletions spec/rogue_one_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
describe "#report" do
before do
allow(subject).to receive(:top_100_domains).and_return(%w(google.com))
allow(Parallel).to receive(:processor_count).and_return(0)
end

let(:report) { subject.report }
Expand Down

0 comments on commit 5924235

Please sign in to comment.