Skip to content

Commit

Permalink
✨ detect and validate you.com
Browse files Browse the repository at this point in the history
  • Loading branch information
alaz committed Jul 16, 2022
1 parent fed9627 commit 15ecc14
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ end
* [Pinterest](https://help.pinterest.com/en/articles/about-pinterest-crawler-0)
* [Twitterbot](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started), the list of IPs is in the [Troubleshooting page](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/troubleshooting-cards)
* [Yandex robots](https://yandex.com/support/webmaster/robot-workings/check-yandex-robots.xml)
* [You.com](https://about.you.com/youbot/)

## License

Expand Down
1 change: 1 addition & 0 deletions lib/legitbot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
require_relative 'legitbot/pinterest'
require_relative 'legitbot/twitter'
require_relative 'legitbot/yandex'
require_relative 'legitbot/you'
12 changes: 12 additions & 0 deletions lib/legitbot/you.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Legitbot # :nodoc:
# https://about.you.com/youbot/
class You < BotMatch
ip_ranges %w[
20.59.40.22
]
end

rule Legitbot::You, %w[YouBot/]
end
36 changes: 36 additions & 0 deletions test/you_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require 'minitest/autorun'
require 'legitbot'

class YouTest < Minitest::Test
def test_malicious_ip
ip = '20.59.41.22'
match = Legitbot::You.new ip
refute_predicate match, :valid?
end

def test_valid_ip
ip = '20.59.40.22'
match = Legitbot::You.new ip
assert_predicate match, :valid?
end

def test_malicious_ua
bot = Legitbot.bot(
'Mozilla/5.0 (compatible; YouBot/1.0; +https://about.you.com/youbot/)',
'20.59.41.22'
)
assert bot
refute_predicate bot, :valid?
end

def test_valid_ua
bot = Legitbot.bot(
'Mozilla/5.0 (compatible; YouBot/1.0; +https://about.you.com/youbot/)',
'20.59.40.22'
)
assert bot
assert_predicate bot, :valid?
end
end

0 comments on commit 15ecc14

Please sign in to comment.