legitbot 0.2.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/legitbot/ahrefs.rb +13 -0
- data/lib/legitbot/facebook.rb +0 -1
- data/lib/legitbot/version.rb +1 -1
- data/lib/legitbot.rb +1 -0
- data/test/ahrefs_test.rb +28 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdde57656a3544982f83a9cf1afca4b63fcaa26e6da402a97de5ee053f2168fd
|
4
|
+
data.tar.gz: 8408a3c73d579ecf92526d7e4889376e5a61996df21df06511fe4076f5bf0913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f21c0c3c93a2ac9eab93b919f8455a05f5accf07c82623be68fc372f6e3bdc38b88993cd3dc7682cc647b8e74b90290eeb474c5a35ab607f7bf2a2537a50c48
|
7
|
+
data.tar.gz: 610e55bbc7d66958c36bc6f77e265d6e14d0427a1d7df3346728cad3450a0cf77181cb76129cd31728db1bb693cba54e74c57aa77ddb6a2d5f26d1a6da3707a9
|
data/README.md
CHANGED
@@ -43,6 +43,7 @@ end
|
|
43
43
|
|
44
44
|
## Supported
|
45
45
|
|
46
|
+
* [Ahrefs](https://ahrefs.com/robot)
|
46
47
|
* [Applebot](https://support.apple.com/en-us/HT204683)
|
47
48
|
* [Baidu spider](http://help.baidu.com/question?prod_en=master&class=498&id=1000973)
|
48
49
|
* [Bingbot](https://blogs.bing.com/webmaster/2012/08/31/how-to-verify-that-bingbot-is-bingbot/)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Legitbot
|
2
|
+
# https://ahrefs.com/robot
|
3
|
+
class Ahrefs < BotMatch
|
4
|
+
Ranges = %w(54.36.148.0/24 54.36.149.0/24 54.36.150.0/24 195.154.122.0/24 195.154.123.0/24 195.154.126.0/24 195.154.127.0/24)
|
5
|
+
|
6
|
+
def valid?
|
7
|
+
ip = IPAddr.new @ip
|
8
|
+
Ranges.any? { |range| IPAddr.new(range).include? ip }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
rule Legitbot::Ahrefs, %w(AhrefsBot)
|
13
|
+
end
|
data/lib/legitbot/facebook.rb
CHANGED
data/lib/legitbot/version.rb
CHANGED
data/lib/legitbot.rb
CHANGED
data/test/ahrefs_test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'legitbot'
|
3
|
+
|
4
|
+
class AhrefsTest < Minitest::Test
|
5
|
+
def test_malicious_ip
|
6
|
+
ip = "149.210.164.47"
|
7
|
+
match = Legitbot::Ahrefs.new ip
|
8
|
+
assert !match.valid?, msg: "#{ip} is not a real Ahrefs IP"
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_valid_ip
|
12
|
+
ip = "54.36.148.0"
|
13
|
+
match = Legitbot::Ahrefs.new ip
|
14
|
+
assert match.valid?, msg: "#{ip} is a valid Ahrefs IP"
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_malicious_ua
|
18
|
+
bot = Legitbot.bot("Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)", "149.210.164.47")
|
19
|
+
assert bot, msg: "Ahrefs detected from User-Agent"
|
20
|
+
assert !bot.valid?, msg: "Not a valid Ahrefs"
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_valid_ua
|
24
|
+
bot = Legitbot.bot("Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)", "54.36.148.0")
|
25
|
+
assert bot, msg: "Ahrefs detected from User-Agent"
|
26
|
+
assert bot.valid?, msg: "Valid Ahrefs"
|
27
|
+
end
|
28
|
+
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: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Azarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irrc
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- legitbot.gemspec
|
83
83
|
- lib/legitbot.rb
|
84
|
+
- lib/legitbot/ahrefs.rb
|
84
85
|
- lib/legitbot/apple.rb
|
85
86
|
- lib/legitbot/baidu.rb
|
86
87
|
- lib/legitbot/bing.rb
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- lib/legitbot/pinterest.rb
|
93
94
|
- lib/legitbot/version.rb
|
94
95
|
- lib/legitbot/yandex.rb
|
96
|
+
- test/ahrefs_test.rb
|
95
97
|
- test/apple_as_google_test.rb
|
96
98
|
- test/apple_test.rb
|
97
99
|
- test/botmatch_test.rb
|
@@ -127,6 +129,7 @@ summary: 'Validate requests from Web crawlers: impersonating or not?'
|
|
127
129
|
test_files:
|
128
130
|
- test/legitbot_test.rb
|
129
131
|
- test/pinterest_test.rb
|
132
|
+
- test/ahrefs_test.rb
|
130
133
|
- test/apple_test.rb
|
131
134
|
- test/apple_as_google_test.rb
|
132
135
|
- test/google_test.rb
|