legitbot 1.7.1 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +5 -1
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/codecov.yml +15 -0
- data/legitbot.gemspec +4 -3
- data/lib/legitbot/google.rb +5 -0
- data/lib/legitbot/version.rb +1 -1
- data/test/ahrefs_test.rb +5 -4
- data/test/alexa_test.rb +5 -4
- data/test/amazon_test.rb +7 -4
- data/test/apple_test.rb +4 -4
- data/test/botmatch_test.rb +1 -4
- data/test/facebook_test.rb +4 -2
- data/test/google_test.rb +7 -4
- data/test/legitbot/validators/ip_ranges_test.rb +5 -0
- data/test/legitbot_test.rb +1 -2
- data/test/oracle_test.rb +5 -2
- data/test/petalbot_test.rb +7 -4
- data/test/pinterest_test.rb +7 -4
- data/test/test_helper.rb +15 -0
- data/test/twitter_test.rb +5 -2
- data/test/you_test.rb +5 -2
- metadata +36 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb23292d664c393d5b39a9d7a69b0469dbf326f1c5ef2cda2236cd16baf6eda
|
4
|
+
data.tar.gz: fefe1fd716e81ff8e0f38950be0790006cc84bb9b9c4b1a53997331010efc861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d156a7574284f8b401f6bcf78bb3f005f6f8c4ad11e67c9f30b515ed08d7855481052716cc2dd60f1eb33f19702b5b6bf8a5bd42b56c7907bc24d791cc4fa63
|
7
|
+
data.tar.gz: b33800ac92eaa874a4b74372281b3d512f34b6ab18e7743ef9857237508188ab92fdca1b554a0307397cf63d898f69c23f02462adbe8d52e0a58011cbda9ec4f
|
data/.github/workflows/build.yml
CHANGED
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [ jruby, 2.
|
14
|
+
ruby: [ jruby, 2.7, 3.0, 3.1, 3.2 ]
|
15
15
|
|
16
16
|
steps:
|
17
17
|
- uses: actions/checkout@v3
|
@@ -32,6 +32,10 @@ jobs:
|
|
32
32
|
bundle install --jobs 4 --retry 3
|
33
33
|
- name: Run tests
|
34
34
|
run: bundle exec rake test
|
35
|
+
- name: Upload coverage
|
36
|
+
uses: codecov/codecov-action@v3
|
37
|
+
with:
|
38
|
+
files: coverage/coverage.xml
|
35
39
|
|
36
40
|
lint:
|
37
41
|
needs: test
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Legitbot ![](https://github.com/alaz/legitbot/workflows/build/badge.svg) ![](https://badge.fury.io/rb/legitbot.svg)
|
1
|
+
# Legitbot ![](https://github.com/alaz/legitbot/workflows/build/badge.svg) ![](https://badge.fury.io/rb/legitbot.svg) ![codecov](https://codecov.io/gh/alaz/legitbot/branch/master/graph/badge.svg?token=LKtJ3E9VUl)
|
2
2
|
|
3
3
|
Ruby gem to make sure that an IP really belongs to a bot, typically a search
|
4
4
|
engine.
|
data/codecov.yml
ADDED
data/legitbot.gemspec
CHANGED
@@ -26,10 +26,11 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'dns_mock', '~> 1.5.0', '>= 1.5.0'
|
27
27
|
spec.add_development_dependency 'minitest', '~> 5.1', '>= 5.1.0'
|
28
28
|
spec.add_development_dependency 'minitest-hooks', '~> 1.5', '>= 1.5.0'
|
29
|
-
spec.add_development_dependency 'nokogiri', '~> 1.
|
29
|
+
spec.add_development_dependency 'nokogiri', '~> 1.14', '>= 1.14.3'
|
30
30
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.0'
|
31
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
32
|
-
spec.add_development_dependency 'rubocop-minitest', '~> 0.
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 1.50.0', '>= 1.50.0'
|
32
|
+
spec.add_development_dependency 'rubocop-minitest', '~> 0.31.0', '>= 0.31.0'
|
33
|
+
spec.add_development_dependency 'simplecov-cobertura', '~> 2.0', '>= 2.0'
|
33
34
|
|
34
35
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
35
36
|
spec.rdoc_options = ['--charset=UTF-8']
|
data/lib/legitbot/google.rb
CHANGED
data/lib/legitbot/version.rb
CHANGED
data/test/ahrefs_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class AhrefsTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class AhrefsTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Ahrefs.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '54.36.148.0'
|
20
18
|
match = Legitbot::Ahrefs.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class AhrefsTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class AhrefsTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)',
|
36
36
|
'54.36.148.0'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
data/test/alexa_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class AlexaTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class AlexaTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Alexa.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '52.86.176.3'
|
20
18
|
match = Legitbot::Alexa.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class AlexaTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible; Alexabot/1.0; +http://www.alexa.com/help/certifyscan; certifyscan@alexa.com)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class AlexaTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible; Alexabot/1.0; +http://www.alexa.com/help/certifyscan; certifyscan@alexa.com)',
|
36
36
|
'52.86.176.3'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
data/test/amazon_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class AmazonTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class AmazonTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Amazon.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '54.166.7.90'
|
20
18
|
match = Legitbot::Amazon.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class AmazonTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible; AmazonAdBot/1.0; +https://adbot.amazon.com)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class AmazonTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible; AmazonAdBot/1.0; +https://adbot.amazon.com)',
|
36
36
|
'54.166.7.90'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
@@ -44,6 +45,7 @@ class AmazonTest < Minitest::Test
|
|
44
45
|
'Mozilla/5.0 (compatible; AmazonAdBot/1.0; +https://adbot.amazon.com)',
|
45
46
|
'54.166.7.90'
|
46
47
|
)
|
48
|
+
|
47
49
|
assert_equal :amazon, bot.detected_as
|
48
50
|
end
|
49
51
|
|
@@ -52,6 +54,7 @@ class AmazonTest < Minitest::Test
|
|
52
54
|
'Mozilla/5.0 (compatible; AmazonAdBot/1.0; +https://adbot.amazon.com)',
|
53
55
|
'81.1.172.108'
|
54
56
|
)
|
57
|
+
|
55
58
|
assert_equal :amazon, bot.detected_as
|
56
59
|
end
|
57
60
|
end
|
data/test/apple_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class AppleTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class AppleTest < Minitest::Test
|
|
12
9
|
def test_valid_ip
|
13
10
|
ip = '17.58.98.60'
|
14
11
|
match = Legitbot::Apple.new(ip)
|
12
|
+
|
15
13
|
assert_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_invalid_ip
|
19
17
|
ip = '127.0.0.1'
|
20
18
|
match = Legitbot::Apple.new(ip)
|
19
|
+
|
21
20
|
assert_predicate match, :fake?
|
22
21
|
end
|
23
22
|
|
@@ -27,6 +26,7 @@ class AppleTest < Minitest::Test
|
|
27
26
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5 (Applebot/0.1; +http://www.apple.com/go/applebot)',
|
28
27
|
'17.58.98.60'
|
29
28
|
)
|
29
|
+
|
30
30
|
assert_equal :apple, bot.detected_as
|
31
31
|
assert_predicate bot, :valid?
|
32
32
|
end
|
data/test/botmatch_test.rb
CHANGED
data/test/facebook_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
5
4
|
|
6
5
|
module Legitbot
|
7
6
|
class Facebook
|
@@ -20,16 +19,19 @@ class FacebookTest < Minitest::Test
|
|
20
19
|
def test_valid_ip
|
21
20
|
ip = '69.63.186.89'
|
22
21
|
match = Legitbot::Facebook.new(ip)
|
22
|
+
|
23
23
|
assert_predicate match, :valid?
|
24
24
|
|
25
25
|
ip = '69.171.251.1'
|
26
26
|
match = Legitbot::Facebook.new(ip)
|
27
|
+
|
27
28
|
assert_predicate match, :valid?
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_invalid_ip
|
31
32
|
ip = '127.0.0.1'
|
32
33
|
match = Legitbot::Facebook.new(ip)
|
34
|
+
|
33
35
|
assert_predicate match, :fake?
|
34
36
|
end
|
35
37
|
|
data/test/google_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class GoogleTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class GoogleTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Google.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '66.249.64.141'
|
20
18
|
match = Legitbot::Google.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class GoogleTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class GoogleTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
36
36
|
'66.249.64.141'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
@@ -44,6 +45,7 @@ class GoogleTest < Minitest::Test
|
|
44
45
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
45
46
|
'66.249.64.141'
|
46
47
|
)
|
48
|
+
|
47
49
|
assert_equal :google, bot.detected_as
|
48
50
|
end
|
49
51
|
|
@@ -52,6 +54,7 @@ class GoogleTest < Minitest::Test
|
|
52
54
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
53
55
|
'81.1.172.108'
|
54
56
|
)
|
57
|
+
|
55
58
|
assert_equal :google, bot.detected_as
|
56
59
|
end
|
57
60
|
end
|
@@ -60,17 +60,20 @@ module Legitbot
|
|
60
60
|
class IpRangesTest < Minitest::Test
|
61
61
|
def test_partition_method
|
62
62
|
empty = NoRanges.partition_ips([])
|
63
|
+
|
63
64
|
assert_empty empty
|
64
65
|
end
|
65
66
|
|
66
67
|
def test_ipv6_partition
|
67
68
|
ipv6 = NoRanges.partition_ips(['2a03:2880:f234::/48'])
|
69
|
+
|
68
70
|
assert_nil ipv6[:ipv4].top_node
|
69
71
|
refute_nil ipv6[:ipv6].top_node
|
70
72
|
end
|
71
73
|
|
72
74
|
def test_ipv4_partition
|
73
75
|
ipv4 = NoRanges.partition_ips(['66.220.144.0/21'])
|
76
|
+
|
74
77
|
refute_nil ipv4[:ipv4].top_node
|
75
78
|
assert_nil ipv4[:ipv6].top_node
|
76
79
|
end
|
@@ -87,6 +90,7 @@ module Legitbot
|
|
87
90
|
assert EmptyRanges.valid_ip?('2a03:2880:f234:0:0:0:0:1')
|
88
91
|
|
89
92
|
matcher = EmptyRanges.new '127.0.0.0'
|
93
|
+
|
90
94
|
assert_predicate matcher, :valid_ip?
|
91
95
|
end
|
92
96
|
|
@@ -113,6 +117,7 @@ module Legitbot
|
|
113
117
|
assert_equal 1, LoadRanges.counter
|
114
118
|
|
115
119
|
LoadRanges.reload_ips
|
120
|
+
|
116
121
|
refute_predicate LoadRanges.new('127.127.127.127'), :valid_ip?
|
117
122
|
refute_predicate LoadRanges.new('10.10.10.10'), :valid_ip?
|
118
123
|
assert_predicate LoadRanges.new('192.168.127.254'), :valid_ip?
|
data/test/legitbot_test.rb
CHANGED
data/test/oracle_test.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
5
4
|
|
6
5
|
class OracleTest < Minitest::Test
|
7
6
|
def test_malicious_ip
|
8
7
|
ip = '149.210.164.47'
|
9
8
|
match = Legitbot::Oracle.new ip
|
9
|
+
|
10
10
|
refute_predicate match, :valid?
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_valid_ip
|
14
14
|
ip = '148.64.56.64'
|
15
15
|
match = Legitbot::Oracle.new ip
|
16
|
+
|
16
17
|
assert_predicate match, :valid?
|
17
18
|
end
|
18
19
|
|
@@ -21,6 +22,7 @@ class OracleTest < Minitest::Test
|
|
21
22
|
'Mozilla/5.0 (compatible; GrapeshotCrawler/2.0; +http://www.grapeshot.co.uk/crawler.php)',
|
22
23
|
'149.210.164.47'
|
23
24
|
)
|
25
|
+
|
24
26
|
assert bot
|
25
27
|
refute_predicate bot, :valid?
|
26
28
|
end
|
@@ -30,6 +32,7 @@ class OracleTest < Minitest::Test
|
|
30
32
|
'Mozilla/5.0 (compatible; GrapeshotCrawler/2.0; +http://www.grapeshot.co.uk/crawler.php)',
|
31
33
|
'148.64.56.64'
|
32
34
|
)
|
35
|
+
|
33
36
|
assert bot
|
34
37
|
assert_predicate bot, :valid?
|
35
38
|
end
|
data/test/petalbot_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class PetalbotTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class PetalbotTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Petalbot.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '114.119.134.10'
|
20
18
|
match = Legitbot::Petalbot.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class PetalbotTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible;PetalBot; +https://aspiegel.com/petalbot)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class PetalbotTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible;PetalBot; +https://aspiegel.com/petalbot)',
|
36
36
|
'114.119.134.10'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
@@ -44,6 +45,7 @@ class PetalbotTest < Minitest::Test
|
|
44
45
|
'Mozilla/5.0 (compatible;PetalBot; +https://aspiegel.com/petalbot)',
|
45
46
|
'66.249.64.141'
|
46
47
|
)
|
48
|
+
|
47
49
|
assert_equal :petalbot, bot.detected_as
|
48
50
|
end
|
49
51
|
|
@@ -52,6 +54,7 @@ class PetalbotTest < Minitest::Test
|
|
52
54
|
'Mozilla/5.0 (compatible; PetalBot/2.1; +http://www.google.com/bot.html)',
|
53
55
|
'81.1.172.108'
|
54
56
|
)
|
57
|
+
|
55
58
|
assert_equal :petalbot, bot.detected_as
|
56
59
|
end
|
57
60
|
end
|
data/test/pinterest_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'minitest/hooks/test'
|
5
|
-
require 'lib/dns_server_mock'
|
6
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
7
4
|
|
8
5
|
class PinterestTest < Minitest::Test
|
9
6
|
include Minitest::Hooks
|
@@ -12,12 +9,14 @@ class PinterestTest < Minitest::Test
|
|
12
9
|
def test_malicious_ip
|
13
10
|
ip = '149.210.164.47'
|
14
11
|
match = Legitbot::Pinterest.new ip
|
12
|
+
|
15
13
|
refute_predicate match, :valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
def test_valid_ip
|
19
17
|
ip = '54.236.1.11'
|
20
18
|
match = Legitbot::Pinterest.new ip
|
19
|
+
|
21
20
|
assert_predicate match, :valid?
|
22
21
|
end
|
23
22
|
|
@@ -26,6 +25,7 @@ class PinterestTest < Minitest::Test
|
|
26
25
|
'Mozilla/5.0 (compatible; Pinterestbot/1.0; +https://www.pinterest.com/bot.html)',
|
27
26
|
'149.210.164.47'
|
28
27
|
)
|
28
|
+
|
29
29
|
assert bot
|
30
30
|
refute_predicate bot, :valid?
|
31
31
|
end
|
@@ -35,6 +35,7 @@ class PinterestTest < Minitest::Test
|
|
35
35
|
'Mozilla/5.0 (compatible; Pinterestbot/1.0; +https://www.pinterest.com/bot.html)',
|
36
36
|
'54.236.1.11'
|
37
37
|
)
|
38
|
+
|
38
39
|
assert bot
|
39
40
|
assert_predicate bot, :valid?
|
40
41
|
end
|
@@ -45,6 +46,7 @@ class PinterestTest < Minitest::Test
|
|
45
46
|
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G965F Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.64 Mobile Safari/537.36 [Pinterest/Android]',
|
46
47
|
'85.117.106.133'
|
47
48
|
)
|
49
|
+
|
48
50
|
assert_nil bot
|
49
51
|
end
|
50
52
|
# rubocop:enable Layout/LineLength
|
@@ -54,6 +56,7 @@ class PinterestTest < Minitest::Test
|
|
54
56
|
'Mozilla/5.0 (compatible; Pinterestbot/1.0; +https://www.pinterest.com/bot.html)',
|
55
57
|
'54.236.1.11'
|
56
58
|
)
|
59
|
+
|
57
60
|
assert_equal :pinterest, bot.detected_as
|
58
61
|
end
|
59
62
|
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'simplecov-cobertura'
|
5
|
+
SimpleCov.start do
|
6
|
+
formatter SimpleCov::Formatter::CoberturaFormatter
|
7
|
+
add_filter %r{^/lib/rubocop/}
|
8
|
+
add_filter %r{^/test/}
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'legitbot'
|
12
|
+
|
13
|
+
require 'minitest/autorun'
|
14
|
+
require 'minitest/hooks/test'
|
15
|
+
require 'lib/dns_server_mock'
|
data/test/twitter_test.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
5
4
|
|
6
5
|
class TwitterTest < Minitest::Test
|
7
6
|
def test_malicious_ip
|
8
7
|
ip = '149.210.164.47'
|
9
8
|
match = Legitbot::Twitter.new ip
|
9
|
+
|
10
10
|
refute_predicate match, :valid?
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_valid_ip
|
14
14
|
ip = '199.16.156.125'
|
15
15
|
match = Legitbot::Twitter.new ip
|
16
|
+
|
16
17
|
assert_predicate match, :valid?
|
17
18
|
end
|
18
19
|
|
@@ -21,6 +22,7 @@ class TwitterTest < Minitest::Test
|
|
21
22
|
'Twitterbot/1.0',
|
22
23
|
'149.210.164.47'
|
23
24
|
)
|
25
|
+
|
24
26
|
assert bot
|
25
27
|
refute_predicate bot, :valid?
|
26
28
|
end
|
@@ -30,6 +32,7 @@ class TwitterTest < Minitest::Test
|
|
30
32
|
'Twitterbot/1.0',
|
31
33
|
'199.16.156.125'
|
32
34
|
)
|
35
|
+
|
33
36
|
assert bot
|
34
37
|
assert_predicate bot, :valid?
|
35
38
|
end
|
data/test/you_test.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'legitbot'
|
3
|
+
require_relative 'test_helper'
|
5
4
|
|
6
5
|
class YouTest < Minitest::Test
|
7
6
|
def test_malicious_ip
|
8
7
|
ip = '20.59.41.22'
|
9
8
|
match = Legitbot::You.new ip
|
9
|
+
|
10
10
|
refute_predicate match, :valid?
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_valid_ip
|
14
14
|
ip = '20.59.40.22'
|
15
15
|
match = Legitbot::You.new ip
|
16
|
+
|
16
17
|
assert_predicate match, :valid?
|
17
18
|
end
|
18
19
|
|
@@ -21,6 +22,7 @@ class YouTest < Minitest::Test
|
|
21
22
|
'Mozilla/5.0 (compatible; YouBot/1.0; +https://about.you.com/youbot/)',
|
22
23
|
'20.59.41.22'
|
23
24
|
)
|
25
|
+
|
24
26
|
assert bot
|
25
27
|
refute_predicate bot, :valid?
|
26
28
|
end
|
@@ -30,6 +32,7 @@ class YouTest < Minitest::Test
|
|
30
32
|
'Mozilla/5.0 (compatible; YouBot/1.0; +https://about.you.com/youbot/)',
|
31
33
|
'20.59.40.22'
|
32
34
|
)
|
35
|
+
|
33
36
|
assert bot
|
34
37
|
assert_predicate bot, :valid?
|
35
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legitbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Azarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_interval_tree
|
@@ -136,20 +136,20 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
139
|
+
version: '1.14'
|
140
140
|
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: 1.
|
142
|
+
version: 1.14.3
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
145
|
version_requirements: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
147
|
- - "~>"
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.
|
149
|
+
version: '1.14'
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.14.3
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,40 +176,60 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: 1.
|
179
|
+
version: 1.50.0
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.
|
182
|
+
version: 1.50.0
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: 1.
|
189
|
+
version: 1.50.0
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: 1.
|
192
|
+
version: 1.50.0
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
name: rubocop-minitest
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - "~>"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: 0.
|
199
|
+
version: 0.31.0
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 0.
|
202
|
+
version: 0.31.0
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
207
|
- - "~>"
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 0.
|
209
|
+
version: 0.31.0
|
210
210
|
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
version: 0.
|
212
|
+
version: 0.31.0
|
213
|
+
- !ruby/object:Gem::Dependency
|
214
|
+
name: simplecov-cobertura
|
215
|
+
requirement: !ruby/object:Gem::Requirement
|
216
|
+
requirements:
|
217
|
+
- - "~>"
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
version: '2.0'
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '2.0'
|
223
|
+
type: :development
|
224
|
+
prerelease: false
|
225
|
+
version_requirements: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '2.0'
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '2.0'
|
213
233
|
description: Does Web request come from a real search engine or from an impersonating
|
214
234
|
agent?
|
215
235
|
email: self@alaz.me
|
@@ -227,6 +247,7 @@ files:
|
|
227
247
|
- LICENSE.txt
|
228
248
|
- README.md
|
229
249
|
- Rakefile
|
250
|
+
- codecov.yml
|
230
251
|
- legitbot.gemspec
|
231
252
|
- lib/legitbot.rb
|
232
253
|
- lib/legitbot/ahrefs.rb
|
@@ -270,6 +291,7 @@ files:
|
|
270
291
|
- test/oracle_test.rb
|
271
292
|
- test/petalbot_test.rb
|
272
293
|
- test/pinterest_test.rb
|
294
|
+
- test/test_helper.rb
|
273
295
|
- test/twitter_test.rb
|
274
296
|
- test/you_test.rb
|
275
297
|
homepage: https://github.com/alaz/legitbot
|