rogue_one 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b1d9ea6171500c42fd1930ba0807e74d8df4908fdec5eb47f1b88b0262caf6
4
- data.tar.gz: 3836ad7bc6a13b68e1fa07d5d584ccbe0da64c8a4c1ee31e16d8f6e5037ada7f
3
+ metadata.gz: b93f5fd8739dbb15739809bba1f391a913d5e7e3a8822a07487f9942ee307ac6
4
+ data.tar.gz: c413a952f102a75f3bbf7db003373eebe1ecd8b0f92c52db345dbda3d562bff1
5
5
  SHA512:
6
- metadata.gz: 8659b118ceaf22a6ec4756d4f883f8bda633ddf1230aab126c2666ad967df887dd7b1fed576b2f3608ed0adefea695067030ed079b3a915af8c06b1398bd2bd0
7
- data.tar.gz: 3c6debab123e645b9765627dda48bc5c2674ee9101f53da0c8bb967a72d54cea411213cc6b6d2354263f1034b73d75282058872779f75a1ac07ec3e5bb77a63d
6
+ metadata.gz: 477c391a0c54c2889ff000048c24952355e2e9c26116a68c7748e6e64d16ca0657264c81a6ce6c56d2251c5d830c8075efd81ccfb3a6151d03914e083927c9a3
7
+ data.tar.gz: 3c4ebc1b64c51d0299c969363fd5d51223f4ef21912c4957ac8d8db1666295f3f070919674687935d48f2e45334f7d4e66fabb96ef4a39e36ef0a7b56c9f903e
@@ -0,0 +1,23 @@
1
+ name: Ruby CI
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby: [2.7, "3.0"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
21
+ - name: Build and test with Rake
22
+ run: |
23
+ bundle exec rake
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in rogue_one.gemspec
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Rogue one
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rogue_one.svg)](https://badge.fury.io/rb/rogue_one)
4
- [![Build Status](https://travis-ci.com/ninoseki/rogue_one.svg?branch=master)](https://travis-ci.com/ninoseki/rogue_one)
4
+ [![Ruby CI](https://github.com/ninoseki/rogue_one/actions/workflows/test.yaml/badge.svg)](https://github.com/ninoseki/rogue_one/actions/workflows/test.yaml)
5
5
  [![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/rogue_one/badge)](https://www.codefactor.io/repository/github/ninoseki/rogue_one)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/ninoseki/rogue_one/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/rogue_one?branch=master)
7
7
 
@@ -75,7 +75,7 @@ $ rogue_one report 171.244.3.111 --custom-list tmp/roaming.yml
75
75
  "58.82.243.9"
76
76
  ]
77
77
  }
78
- # Note: a custom list should be an array of domains in YAML format.
78
+ # Note: a custom list should be an array of domains in a YAML file.
79
79
  ```
80
80
 
81
81
  | Key | Desc. |
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "rogue_one"
data/exe/rogue_one CHANGED
@@ -5,4 +5,6 @@ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
5
 
6
6
  require "rogue_one"
7
7
 
8
- RogueOne::CLI.start
8
+ ARGV.unshift(RogueOne::CLI.default_task) unless RogueOne::CLI.all_tasks.key?(ARGV[0])
9
+
10
+ RogueOne::CLI.start(ARGV)
data/lib/rogue_one/cli.rb CHANGED
@@ -38,6 +38,7 @@ module RogueOne
38
38
  puts JSON.pretty_generate(detector.report)
39
39
  end
40
40
  end
41
+ default_command :report
41
42
 
42
43
  no_commands do
43
44
  def with_error_handling
@@ -11,21 +11,18 @@ require "etc"
11
11
 
12
12
  module RogueOne
13
13
  class Detector
14
- attr_reader :custom_list
15
- attr_reader :default_list
16
- attr_reader :max_concurrency
17
- attr_reader :record_type
18
- attr_reader :target
19
- attr_reader :verbose
14
+ attr_reader :custom_list, :default_list, :max_concurrency, :record_type, :target, :verbose
20
15
 
21
16
  GOOGLE_PUBLIC_DNS = "8.8.8.8"
22
17
 
23
- def initialize(target:,
24
- custom_list: nil,
25
- default_list: "alexa",
26
- record_type: "A",
27
- threshold: nil,
28
- verbose: false)
18
+ def initialize(
19
+ target:,
20
+ custom_list: nil,
21
+ default_list: "alexa",
22
+ record_type: "A",
23
+ threshold: nil,
24
+ verbose: false
25
+ )
29
26
  @target = target
30
27
 
31
28
  @custom_list = custom_list
@@ -74,9 +71,9 @@ module RogueOne
74
71
  end
75
72
 
76
73
  def landing_pages
77
- @memo.map do |ip, count|
74
+ @memo.filter_map do |ip, count|
78
75
  count > threshold ? ip : nil
79
- end.compact.sort
76
+ end.sort
80
77
  end
81
78
 
82
79
  def results
@@ -105,13 +102,13 @@ module RogueOne
105
102
  normal_resolutions = bulk_resolve(normal_resolver, domains)
106
103
  resolutions = bulk_resolve(target_resolver, domains)
107
104
 
108
- results = resolutions.map do |domain, addresses|
109
- normal_addresses = normal_resolutions.dig(domain) || []
105
+ results = resolutions.filter_map do |domain, addresses|
106
+ normal_addresses = normal_resolutions[domain] || []
110
107
  address = (addresses || []).first
111
108
  [domain, address] if address && !normal_addresses.include?(address)
112
- end.compact.to_h
109
+ end.to_h
113
110
 
114
- @memo = results.values.group_by(&:itself).map { |k, v| [k, v.length] }.to_h
111
+ @memo = results.values.group_by(&:itself).transform_values(&:length)
115
112
  @verbose_memo = results if verbose
116
113
  end
117
114
 
@@ -140,8 +137,8 @@ module RogueOne
140
137
  list = DomainList.new(path)
141
138
  return list.domains if list.valid?
142
139
 
143
- raise ArgumentError, "Inputted an invalid list. #{path} is not eixst." unless list.exists?
144
- raise ArgumentError, "Inputted an invalid list. Please input a list as an YAML file." unless list.valid_format?
140
+ raise ArgumentError, "Inputted an invalid list. #{path} does not eixst." unless list.exists?
141
+ raise ArgumentError, "Inputted an invalid list. Please input a list via a YAML file." unless list.valid_format?
145
142
  end
146
143
 
147
144
  def bulk_resolve(resolver, domains)
@@ -175,7 +172,7 @@ module RogueOne
175
172
  end
176
173
 
177
174
  def dns_resource_by_record_type
178
- @dns_resource_by_record_type ||= dns_resources.dig(record_type)
175
+ @dns_resource_by_record_type ||= dns_resources[record_type]
179
176
  end
180
177
 
181
178
  def dns_resources
@@ -4,8 +4,7 @@ require "resolv"
4
4
 
5
5
  module RogueOne
6
6
  class Ping
7
- attr_reader :resolver
8
- attr_reader :nameserver
7
+ attr_reader :resolver, :nameserver
9
8
 
10
9
  def initialize(nameserver)
11
10
  @nameserver = nameserver
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RogueOne
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
data/rogue_one.gemspec CHANGED
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_development_dependency "bundler", "~> 2.1"
28
- spec.add_development_dependency "coveralls", "~> 0.8"
27
+ spec.add_development_dependency "bundler", "~> 2.2"
28
+ spec.add_development_dependency "coveralls_reborn", "~> 0.23"
29
29
  spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.9"
30
+ spec.add_development_dependency "rspec", "~> 3.10"
31
31
 
32
- spec.add_dependency "async-dns", "~> 1.2"
33
- spec.add_dependency "thor", "~> 1.0"
32
+ spec.add_dependency "async-dns", "~> 1.3"
33
+ spec.add_dependency "thor", "~> 1.1"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rogue_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '2.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.1'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: coveralls
28
+ name: coveralls_reborn
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '0.23'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.8'
40
+ version: '0.23'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.9'
61
+ version: '3.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.9'
68
+ version: '3.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: async-dns
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.2'
75
+ version: '1.3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.2'
82
+ version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: '1.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: '1.1'
97
97
  description: A rogue DNS detector
98
98
  email:
99
99
  - manabu.niseki@gmail.com
@@ -102,9 +102,9 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".github/workflows/test.yaml"
105
106
  - ".gitignore"
106
107
  - ".rspec"
107
- - ".travis.yml"
108
108
  - Gemfile
109
109
  - LICENSE
110
110
  - README.md
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.1.2
145
+ rubygems_version: 3.2.22
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: A rogue DNS detector
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6
7
- - 2.7
8
- before_install: gem install bundler -v 2.1