agent_orange 0.1.0 → 0.1.1
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.
- data/.gitignore +3 -0
- data/agent_orange.gemspec +22 -0
- data/lib/agent_orange/version.rb +1 -1
- data/lib/tasks/allagents.xml +22170 -0
- data/lib/tasks/bot_agent_test.rake +86 -0
- metadata +48 -25
@@ -0,0 +1,86 @@
|
|
1
|
+
require "agent_orange"
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
task :test_bots do
|
5
|
+
success = 0
|
6
|
+
fail = 0
|
7
|
+
|
8
|
+
# tests for successful bot detection
|
9
|
+
bot_user_agent_strings = [
|
10
|
+
"ia_archiver (+http://www.alexa.com/site/help/webmasters; crawler@alexa.com)",
|
11
|
+
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
12
|
+
]
|
13
|
+
browser_user_agent_strings = [
|
14
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; sv-se) AppleWebKit/525.26.2 (KHTML, like Gecko) Version/3.2 Safari/525.26.12",
|
15
|
+
"Mozilla/5.0 (iPhone; U; Linux i686; pt-br) AppleWebKit/532+ (KHTML, like Gecko) Version/3.0 Mobile/1A538b Safari/419.3 Midori/0.2.0",
|
16
|
+
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; zh-tw) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5",
|
17
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
|
18
|
+
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
|
19
|
+
"Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
|
20
|
+
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
|
21
|
+
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)",
|
22
|
+
"Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0",
|
23
|
+
"Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0",
|
24
|
+
"Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00",
|
25
|
+
"Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11"
|
26
|
+
]
|
27
|
+
puts
|
28
|
+
puts "parsing the user-agents.org list..."
|
29
|
+
doc = REXML::Document.new(File.open("lib/tasks/allagents.xml"))
|
30
|
+
doc.elements.each("user-agents/user-agent") do |ua|
|
31
|
+
bot = false
|
32
|
+
browser = false
|
33
|
+
ua.elements.each("Type") do |item|
|
34
|
+
if item.text == "R" || item.text == "S"
|
35
|
+
bot = true
|
36
|
+
elsif item.text == "B"
|
37
|
+
browser = true
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
if bot
|
42
|
+
ua.elements.each("String") do |item|
|
43
|
+
bot_user_agent_strings << item.text
|
44
|
+
end
|
45
|
+
end
|
46
|
+
if browser
|
47
|
+
ua.elements.each("String") do |item|
|
48
|
+
browser_user_agent_strings << item.text
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
puts "testing..."
|
53
|
+
bot_user_agent_strings.each do |ua_str|
|
54
|
+
ua = AgentOrange::UserAgent.new(ua_str)
|
55
|
+
if ua.is_bot?
|
56
|
+
#puts "SUCCESS:: " + ua_str
|
57
|
+
success += 1
|
58
|
+
else
|
59
|
+
#puts "FAIL:: " + ua_str
|
60
|
+
fail += 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
puts "BOT DETECTION"
|
65
|
+
puts success.to_s + " succeed. BENCHMARK: 376"
|
66
|
+
puts fail.to_s + " fail. BENCHMARK: 1083"
|
67
|
+
|
68
|
+
success = 0
|
69
|
+
fail = 0
|
70
|
+
|
71
|
+
browser_user_agent_strings.each do |ua_str|
|
72
|
+
ua = AgentOrange::UserAgent.new(ua_str)
|
73
|
+
if !ua.is_bot?
|
74
|
+
#puts "SUCCESS:: " + ua_str
|
75
|
+
success += 1
|
76
|
+
else
|
77
|
+
#puts "FAIL:: " + ua_str
|
78
|
+
fail += 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "FALSE POSITIVES CHECK"
|
83
|
+
puts success.to_s + " succeed. BENCHMARK: 326"
|
84
|
+
puts fail.to_s + " fail. BENCHMARK: 4"
|
85
|
+
|
86
|
+
end
|
metadata
CHANGED
@@ -1,24 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: agent_orange
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Kevin Elliott
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2011-10-24 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Parse and process User Agents like a secret one
|
15
|
-
email:
|
22
|
+
email:
|
16
23
|
- kevin@welikeinc.com
|
17
|
-
executables:
|
24
|
+
executables:
|
18
25
|
- agent_orange_example
|
19
26
|
extensions: []
|
27
|
+
|
20
28
|
extra_rdoc_files: []
|
21
|
-
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.rdoc
|
34
|
+
- Rakefile
|
35
|
+
- agent_orange.gemspec
|
36
|
+
- bin/agent_orange_example
|
37
|
+
- lib/agent_orange.rb
|
22
38
|
- lib/agent_orange/base.rb
|
23
39
|
- lib/agent_orange/browser.rb
|
24
40
|
- lib/agent_orange/device.rb
|
@@ -27,33 +43,40 @@ files:
|
|
27
43
|
- lib/agent_orange/platform.rb
|
28
44
|
- lib/agent_orange/user_agent.rb
|
29
45
|
- lib/agent_orange/version.rb
|
30
|
-
- lib/
|
31
|
-
-
|
32
|
-
- Gemfile
|
33
|
-
- Rakefile
|
34
|
-
- README.rdoc
|
46
|
+
- lib/tasks/allagents.xml
|
47
|
+
- lib/tasks/bot_agent_test.rake
|
35
48
|
homepage: http://github.com/kevinelliott/agent_orange
|
36
49
|
licenses: []
|
50
|
+
|
37
51
|
post_install_message:
|
38
52
|
rdoc_options: []
|
39
|
-
|
53
|
+
|
54
|
+
require_paths:
|
40
55
|
- lib
|
41
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
57
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
66
|
none: false
|
49
|
-
requirements:
|
50
|
-
- -
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
53
74
|
requirements: []
|
75
|
+
|
54
76
|
rubyforge_project: agent_orange
|
55
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.5
|
56
78
|
signing_key:
|
57
79
|
specification_version: 3
|
58
80
|
summary: Parse and process User Agents like a secret one
|
59
81
|
test_files: []
|
82
|
+
|