wsoc 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.tar.gz.sig +2 -4
- data/History.rdoc +12 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +2 -0
- data/lib/wsoc/app.rb +10 -11
- data/lib/wsoc/config.rb +4 -0
- data/lib/wsoc/course_specs.rb +20 -2
- data/lib/wsoc/helpers.rb +3 -1
- data/lib/wsoc/helpers/authentication.rb +64 -0
- data/lib/wsoc/helpers/course.rb +1 -1
- data/lib/wsoc/specs.rb +24 -9
- data/lib/wsoc/version.rb +1 -1
- data/views/course_auth_start.erb +13 -0
- data/views/course_cookies_get.erb +1 -1
- data/views/course_remote_start.erb +9 -1
- data/views/course_start.erb +2 -0
- data/views/layout.erb +1 -1
- metadata +4 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
data/History.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 0.1.1 / 2010-01-06
|
2
|
+
|
3
|
+
* Added WSOC::Specs.metadata.
|
4
|
+
* Added WSOC::Specs.config.
|
5
|
+
* Added {WSOC::Helpers::Authentication}.
|
6
|
+
* Added a failing link to <tt>/course/remote/start.html</tt> with a bad TLD.
|
7
|
+
* Added a failing link to <tt>/course/remote/start.html</tt> with the bad
|
8
|
+
IP address +191.255.0.0+.
|
9
|
+
* Added <tt>/course/auth</tt> for testing spidering of HTTP Basic
|
10
|
+
Auth protected pages.
|
11
|
+
* Added auth store information to the metadata within the specs.
|
12
|
+
|
1
13
|
=== 0.1.0 / 2010-01-02
|
2
14
|
|
3
15
|
* Initial release:
|
data/Manifest.txt
CHANGED
@@ -11,6 +11,7 @@ lib/wsoc/specs.rb
|
|
11
11
|
lib/wsoc/course_specs.rb
|
12
12
|
lib/wsoc/helpers.rb
|
13
13
|
lib/wsoc/helpers/rendering.rb
|
14
|
+
lib/wsoc/helpers/authentication.rb
|
14
15
|
lib/wsoc/helpers/course.rb
|
15
16
|
lib/wsoc/course.rb
|
16
17
|
lib/wsoc/app.rb
|
@@ -39,4 +40,5 @@ views/course_remote_next.erb
|
|
39
40
|
views/course_cookies_start.erb
|
40
41
|
views/course_cookies_get.erb
|
41
42
|
views/course_redirects_start.erb
|
43
|
+
views/course_auth_start.erb
|
42
44
|
views/welcome.erb
|
data/README.rdoc
CHANGED
@@ -22,7 +22,9 @@ the thoroughness and resilience of Web Spiders.
|
|
22
22
|
* Remote links.
|
23
23
|
* <tt>javascript:</tt> links.
|
24
24
|
* Links within +frameset+ and +iframe+ tags.
|
25
|
+
* Cookie protected pages.
|
25
26
|
* HTTP 300, 301, 302, 303 and 307 Redirects.
|
27
|
+
* HTTP Baisc Auth protected pages.
|
26
28
|
|
27
29
|
== SYNOPSIS:
|
28
30
|
|
data/lib/wsoc/app.rb
CHANGED
@@ -37,7 +37,7 @@ module WSOC
|
|
37
37
|
end
|
38
38
|
|
39
39
|
get '/specs' do
|
40
|
-
@specs = specs
|
40
|
+
@specs = specs[:specs]
|
41
41
|
|
42
42
|
show :specs
|
43
43
|
end
|
@@ -125,23 +125,22 @@ module WSOC
|
|
125
125
|
course_page :course_cookies_get
|
126
126
|
end
|
127
127
|
|
128
|
-
|
129
|
-
response.set_cookie 'auth_level', '2'
|
128
|
+
course_pass '/course/cookies/protected.html'
|
130
129
|
|
131
|
-
|
130
|
+
get '/course/auth/start.html' do
|
131
|
+
protected! do
|
132
|
+
course_page :course_auth_start
|
133
|
+
end
|
132
134
|
end
|
133
135
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
get '/course/auth/protected.html' do
|
137
|
+
protected! do
|
138
|
+
course_page :course_pass
|
139
|
+
end
|
138
140
|
end
|
139
141
|
|
140
|
-
course_pass '/course/cookies/protected/1.html'
|
141
|
-
|
142
142
|
get '/*' do
|
143
143
|
redirect remote_url('/course/fail')
|
144
144
|
end
|
145
|
-
|
146
145
|
end
|
147
146
|
end
|
data/lib/wsoc/config.rb
CHANGED
data/lib/wsoc/course_specs.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
require 'wsoc/specs'
|
22
|
+
require 'wsoc/config'
|
22
23
|
|
23
24
|
module WSOC
|
24
25
|
module CourseSpecs
|
@@ -86,7 +87,11 @@ module WSOC
|
|
86
87
|
'should visit normal remote links'
|
87
88
|
should_fail 'http://spidr.rubyforge.org:1337/course/remote/fail.html',
|
88
89
|
'should safely fail on closed ports'
|
89
|
-
should_fail 'http://
|
90
|
+
should_fail 'http://191.255.0.0/course/remote/fail.html',
|
91
|
+
'should safely fail on unreachable IP Addresses'
|
92
|
+
should_fail 'http://bad.tld/course/remote/fail.html',
|
93
|
+
'should safely fail on host-names with invalid TLDs'
|
94
|
+
should_fail 'http://bad.url.lol.com/course/remote/fail.html',
|
90
95
|
'should safely fail on bad host-names'
|
91
96
|
|
92
97
|
# Cookies
|
@@ -94,7 +99,7 @@ module WSOC
|
|
94
99
|
'should visit the cookies start page'
|
95
100
|
should_visit '/course/cookies/get.html',
|
96
101
|
'should visit the cookies GET request test page'
|
97
|
-
should_visit '/course/cookies/protected
|
102
|
+
should_visit '/course/cookies/protected.html',
|
98
103
|
'should visit the first cookie protected page'
|
99
104
|
|
100
105
|
# HTTP Redirects
|
@@ -120,5 +125,18 @@ module WSOC
|
|
120
125
|
'should visit the 307 HTTP redirect test page'
|
121
126
|
should_visit '/course/redirects/307/pass.html',
|
122
127
|
'should follow HTTP 307 redirects'
|
128
|
+
|
129
|
+
config :auth_store, {
|
130
|
+
'/course/auth/' => {
|
131
|
+
:user, Config::COURSE_AUTH_USER,
|
132
|
+
:password, Config::COURSE_AUTH_PASSWORD
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
# HTTP Auth
|
137
|
+
should_visit '/course/auth/start.html',
|
138
|
+
'should visit the HTTP Auth start page'
|
139
|
+
should_visit '/course/auth/protected.html',
|
140
|
+
'should visit the HTTP Auth protected page'
|
123
141
|
end
|
124
142
|
end
|
data/lib/wsoc/helpers.rb
CHANGED
@@ -18,8 +18,9 @@
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
#
|
20
20
|
|
21
|
-
require 'wsoc/helpers/
|
21
|
+
require 'wsoc/helpers/authentication'
|
22
22
|
require 'wsoc/helpers/rendering'
|
23
|
+
require 'wsoc/helpers/course'
|
23
24
|
|
24
25
|
require 'rack'
|
25
26
|
|
@@ -28,6 +29,7 @@ module WSOC
|
|
28
29
|
include Rack::Utils
|
29
30
|
alias :h :escape_html
|
30
31
|
|
32
|
+
include Authentication
|
31
33
|
include Rendering
|
32
34
|
include Course
|
33
35
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
module WSOC
|
22
|
+
module Helpers
|
23
|
+
module Authentication
|
24
|
+
|
25
|
+
#
|
26
|
+
# Protects an action by requiring HTTP Basic Access Authentication.
|
27
|
+
#
|
28
|
+
# @yield []
|
29
|
+
# If a block is given, it will be called if the client is
|
30
|
+
# authenticated.
|
31
|
+
#
|
32
|
+
# @since 0.1.1
|
33
|
+
#
|
34
|
+
def protected!(&block)
|
35
|
+
if authorized?
|
36
|
+
block.call() if block
|
37
|
+
else
|
38
|
+
response['WWW-Authenticate'] = %(Basic realm="HTTP Auth Test")
|
39
|
+
throw :halt, [401, "Not authorized\n"]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Checks to see if the requesting user is authorized.
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
47
|
+
# Specifies whether or not the client is authenticated.
|
48
|
+
#
|
49
|
+
# @since 0.1.1
|
50
|
+
#
|
51
|
+
def authorized?
|
52
|
+
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
53
|
+
|
54
|
+
@auth.provided? && \
|
55
|
+
@auth.basic? && \
|
56
|
+
@auth.credentials && \
|
57
|
+
@auth.credentials == [
|
58
|
+
WSOC::Config::COURSE_AUTH_USER,
|
59
|
+
WSOC::Config::COURSE_AUTH_PASSWORD
|
60
|
+
]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/wsoc/helpers/course.rb
CHANGED
data/lib/wsoc/specs.rb
CHANGED
@@ -22,29 +22,44 @@ module WSOC
|
|
22
22
|
module Specs
|
23
23
|
def self.included(base)
|
24
24
|
base.module_eval do
|
25
|
+
def self.hash
|
26
|
+
@@specs_hash ||= {}
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.specs
|
26
|
-
|
30
|
+
self.hash[:specs] ||= []
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.metadata
|
34
|
+
self.hash[:metadata] ||= {}
|
27
35
|
end
|
28
36
|
|
29
37
|
def self.should(behavior,options)
|
30
38
|
self.specs << {:behavior => behavior}.merge(options)
|
31
39
|
end
|
32
40
|
|
33
|
-
def self.
|
41
|
+
def self.map(host,port=nil)
|
34
42
|
prefix = "http://#{host}"
|
35
43
|
prefix << ":#{port}" if (port && port != 80)
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
return {
|
46
|
+
:metadata => self.metadata,
|
47
|
+
:specs => self.specs.map { |spec|
|
48
|
+
unless spec[:url] =~ /^[a-zA-Z0-9]+:/
|
49
|
+
spec.merge(:url => prefix + spec[:url])
|
50
|
+
else
|
51
|
+
spec
|
52
|
+
end
|
53
|
+
}
|
54
|
+
}
|
44
55
|
end
|
45
56
|
|
46
57
|
protected
|
47
58
|
|
59
|
+
def self.config(name,value)
|
60
|
+
self.metadata[name.to_sym] = value
|
61
|
+
end
|
62
|
+
|
48
63
|
def self.should_visit(url,message=nil)
|
49
64
|
self.should(:visit,:url => url, :message => message)
|
50
65
|
end
|
data/lib/wsoc/version.rb
CHANGED
@@ -24,7 +24,15 @@
|
|
24
24
|
</li>
|
25
25
|
|
26
26
|
<li>
|
27
|
-
<a href="http://
|
27
|
+
<a href="http://191.255.0.0/course/remote/fail.html">should ignore links with unreachable IP Addresses</a>
|
28
|
+
</li>
|
29
|
+
|
30
|
+
<li>
|
31
|
+
<a href="http://bad.tld/course/remote/fail.html">should ignore links with invalid TLDs</a>
|
32
|
+
</li>
|
33
|
+
|
34
|
+
<li>
|
35
|
+
<a href="http://bad.url.lol.com/course/remote/fail.html">should ignore links that fail</a>
|
28
36
|
</li>
|
29
37
|
</ul>
|
30
38
|
</body>
|
data/views/course_start.erb
CHANGED
@@ -15,8 +15,10 @@
|
|
15
15
|
<li><a href="empty/start.html">Empty links</a></li>
|
16
16
|
<li><a href="javascript/start.html">Bogus JavaScript Links</a></li>
|
17
17
|
<li><a href="frames/start.html">Frames</a></li>
|
18
|
+
<li><a href="auth/start.html">HTTP Auth</a></li>
|
18
19
|
<li><a href="cookies/start.html">Cookies</a></li>
|
19
20
|
<li><a href="redirects/start.html">HTTP Redirects</a></li>
|
21
|
+
<li><a href="auth/start.html">HTTP Auth</a></li>
|
20
22
|
</ul>
|
21
23
|
</body>
|
22
24
|
</html>
|
data/views/layout.erb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
<div id="footer">
|
18
18
|
<p><a href="http://github.com/postmodern/wsoc">Web Spider Obstacle Course</a> | Version <%= WSOC::VERSION %></p>
|
19
|
-
<p>Copyright © 2009 Hal Brodigan</p>
|
19
|
+
<p>Copyright © 2009-2010 Hal Brodigan</p>
|
20
20
|
<p>Powered by <a href="http://www.ruby-lang.org/">Ruby</a> <%= RUBY_VERSION %> and <a href="http://www.sinatrarb.com/">Sinatra</a></p>
|
21
21
|
<p>Made with <a href="http://www.vim.org/">Vim</a> | <a href="http://validator.w3.org/check?uri=referer">XHTML 1.1 Strict</a></p>
|
22
22
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wsoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
pDj+ws7QjtH/Qcrr1l9jfN0ehDs=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2010-01-
|
33
|
+
date: 2010-01-06 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/wsoc/course_specs.rb
|
100
100
|
- lib/wsoc/helpers.rb
|
101
101
|
- lib/wsoc/helpers/rendering.rb
|
102
|
+
- lib/wsoc/helpers/authentication.rb
|
102
103
|
- lib/wsoc/helpers/course.rb
|
103
104
|
- lib/wsoc/course.rb
|
104
105
|
- lib/wsoc/app.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- views/course_cookies_start.erb
|
128
129
|
- views/course_cookies_get.erb
|
129
130
|
- views/course_redirects_start.erb
|
131
|
+
- views/course_auth_start.erb
|
130
132
|
- views/welcome.erb
|
131
133
|
has_rdoc: yard
|
132
134
|
homepage: http://github.com/postmodern/wsoc
|
metadata.gz.sig
CHANGED
Binary file
|