codez-tarantula 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +14 -0
- data/.gitignore +12 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +64 -0
- data/DSL_EXAMPLES.md +120 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +136 -0
- data/Rakefile +36 -0
- data/ci/rails2.gemfile +4 -0
- data/ci/rails3.gemfile +4 -0
- data/laf/images/header_bg.jpg +0 -0
- data/laf/images/logo.png +0 -0
- data/laf/images/tagline.png +0 -0
- data/laf/javascripts/jquery-1.2.3.js +3408 -0
- data/laf/javascripts/jquery-ui-tabs.js +890 -0
- data/laf/javascripts/jquery.tablesorter.js +861 -0
- data/laf/javascripts/tarantula.js +10 -0
- data/laf/stylesheets/tarantula.css +346 -0
- data/lib/relevance/core_extensions/ellipsize.rb +38 -0
- data/lib/relevance/core_extensions/file.rb +15 -0
- data/lib/relevance/core_extensions/metaclass.rb +78 -0
- data/lib/relevance/core_extensions/response.rb +14 -0
- data/lib/relevance/core_extensions/test_case.rb +21 -0
- data/lib/relevance/tarantula.rb +55 -0
- data/lib/relevance/tarantula/attack.rb +22 -0
- data/lib/relevance/tarantula/attack_handler.rb +43 -0
- data/lib/relevance/tarantula/basic_attack.rb +44 -0
- data/lib/relevance/tarantula/crawler.rb +271 -0
- data/lib/relevance/tarantula/detail.html.erb +81 -0
- data/lib/relevance/tarantula/form.rb +29 -0
- data/lib/relevance/tarantula/form_submission.rb +98 -0
- data/lib/relevance/tarantula/html_document_handler.rb +42 -0
- data/lib/relevance/tarantula/html_report_helper.rb +46 -0
- data/lib/relevance/tarantula/html_reporter.rb +111 -0
- data/lib/relevance/tarantula/index.html.erb +37 -0
- data/lib/relevance/tarantula/invalid_html_handler.rb +27 -0
- data/lib/relevance/tarantula/io_reporter.rb +40 -0
- data/lib/relevance/tarantula/link.rb +105 -0
- data/lib/relevance/tarantula/log_grabber.rb +22 -0
- data/lib/relevance/tarantula/rails_integration_proxy.rb +90 -0
- data/lib/relevance/tarantula/recording.rb +12 -0
- data/lib/relevance/tarantula/response.rb +19 -0
- data/lib/relevance/tarantula/result.rb +83 -0
- data/lib/relevance/tarantula/test_report.html.erb +32 -0
- data/lib/relevance/tarantula/tidy_handler.rb +35 -0
- data/lib/relevance/tarantula/transform.rb +21 -0
- data/lib/relevance/tarantula/version.rb +5 -0
- data/lib/relevance/tasks/tarantula_tasks.rake +42 -0
- data/lib/tarantula-rails3.rb +9 -0
- data/spec/relevance/core_extensions/ellipsize_spec.rb +19 -0
- data/spec/relevance/core_extensions/file_spec.rb +7 -0
- data/spec/relevance/core_extensions/response_spec.rb +48 -0
- data/spec/relevance/core_extensions/test_case_spec.rb +19 -0
- data/spec/relevance/tarantula/attack_handler_spec.rb +29 -0
- data/spec/relevance/tarantula/basic_attack_spec.rb +12 -0
- data/spec/relevance/tarantula/crawler_spec.rb +409 -0
- data/spec/relevance/tarantula/form_spec.rb +50 -0
- data/spec/relevance/tarantula/form_submission_spec.rb +171 -0
- data/spec/relevance/tarantula/html_document_handler_spec.rb +43 -0
- data/spec/relevance/tarantula/html_report_helper_spec.rb +46 -0
- data/spec/relevance/tarantula/html_reporter_spec.rb +82 -0
- data/spec/relevance/tarantula/invalid_html_handler_spec.rb +33 -0
- data/spec/relevance/tarantula/io_reporter_spec.rb +11 -0
- data/spec/relevance/tarantula/link_spec.rb +132 -0
- data/spec/relevance/tarantula/log_grabber_spec.rb +26 -0
- data/spec/relevance/tarantula/rails_integration_proxy_spec.rb +100 -0
- data/spec/relevance/tarantula/result_spec.rb +85 -0
- data/spec/relevance/tarantula/tidy_handler_spec.rb +58 -0
- data/spec/relevance/tarantula/transform_spec.rb +20 -0
- data/spec/relevance/tarantula_spec.rb +23 -0
- data/spec/spec_helper.rb +43 -0
- data/tarantula.gemspec +25 -0
- data/template/tarantula_test.rb +22 -0
- data/vendor/xss-shield/MIT-LICENSE +20 -0
- data/vendor/xss-shield/README +76 -0
- data/vendor/xss-shield/init.rb +16 -0
- data/vendor/xss-shield/lib/xss_shield.rb +6 -0
- data/vendor/xss-shield/lib/xss_shield/erb_hacks.rb +111 -0
- data/vendor/xss-shield/lib/xss_shield/haml_hacks.rb +42 -0
- data/vendor/xss-shield/lib/xss_shield/safe_string.rb +47 -0
- data/vendor/xss-shield/lib/xss_shield/secure_helpers.rb +40 -0
- data/vendor/xss-shield/test/test_actionview_integration.rb +40 -0
- data/vendor/xss-shield/test/test_erb.rb +44 -0
- data/vendor/xss-shield/test/test_haml.rb +43 -0
- data/vendor/xss-shield/test/test_helpers.rb +25 -0
- data/vendor/xss-shield/test/test_safe_string.rb +55 -0
- metadata +247 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Relevance::Tarantula::LogGrabber' do
|
4
|
+
before do
|
5
|
+
@grabber = Relevance::Tarantula::LogGrabber.new(log_file)
|
6
|
+
FileUtils.mkdir_p(test_output_dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
def log_file
|
10
|
+
File.join(File.join(test_output_dir, "example.log"))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can clear the log file" do
|
14
|
+
File.open(log_file, "w") {|f| f.print "sample log"}
|
15
|
+
File.size(log_file).should == 10
|
16
|
+
@grabber.clear!
|
17
|
+
File.size(log_file).should == 0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can grab the log file" do
|
21
|
+
File.open(log_file, "w") {|f| f.print "sample log"}
|
22
|
+
@grabber.grab!.should == "sample log"
|
23
|
+
File.size(log_file).should == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Relevance::Tarantula::RailsIntegrationProxy rails_integration_test" do
|
4
|
+
before {
|
5
|
+
Relevance::Tarantula::Crawler.any_instance.stubs(:crawl)
|
6
|
+
Relevance::Tarantula::Crawler.any_instance.stubs(:rails_root).returns("STUB_RAILS_ROOT")
|
7
|
+
Relevance::Tarantula::RailsIntegrationProxy.stubs(:rails_root).returns("STUB_RAILS_ROOT")
|
8
|
+
Relevance::Tarantula::RailsIntegrationProxy.stubs(:new).returns(stub(:integration_test => stub(:method_name => @test_name)))
|
9
|
+
@test_name = "test_user_pages"
|
10
|
+
}
|
11
|
+
|
12
|
+
it "strips leading hostname from link urls" do
|
13
|
+
crawler = Relevance::Tarantula::RailsIntegrationProxy.rails_integration_test(stub(:host => "foo.com"))
|
14
|
+
crawler.transform_url("http://foo.com/path").should == "/path"
|
15
|
+
crawler.transform_url("http://bar.com/path").should == "http://bar.com/path"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "allows override of max_url_length" do
|
19
|
+
crawler = Relevance::Tarantula::RailsIntegrationProxy.rails_integration_test(stub(:host => "foo.com"),
|
20
|
+
:max_url_length => 16)
|
21
|
+
crawler.max_url_length.should == 16
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has some useful defaults" do
|
25
|
+
crawler = Relevance::Tarantula::RailsIntegrationProxy.rails_integration_test(stub(:host => "foo.com"))
|
26
|
+
crawler.log_grabber.should_not be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "Relevance::Tarantula::RailsIntegrationProxy" do
|
32
|
+
%w{get post}.each do |http_method|
|
33
|
+
it "can #{http_method}" do
|
34
|
+
@rip = Relevance::Tarantula::RailsIntegrationProxy.new(stub)
|
35
|
+
@response = stub({:code => :foo})
|
36
|
+
@rip.integration_test = stub_everything(:response => @response)
|
37
|
+
@rip.send(http_method, "/url").should == @response
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "adds a response accessor to its delegate rails integration test" do
|
42
|
+
o = Object.new
|
43
|
+
Relevance::Tarantula::RailsIntegrationProxy.new(o)
|
44
|
+
o.methods(false).map(&:to_s).sort.should == %w{response response=}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "Relevance::Tarantula::RailsIntegrationProxy errors" do
|
49
|
+
it "alters response to contain the error message" do
|
50
|
+
@rip = Relevance::Tarantula::RailsIntegrationProxy.new(stub)
|
51
|
+
@response = Struct.new(:body, :code).new(nil, nil)
|
52
|
+
@rip.integration_test = stub_everything(:response => @response) do |stub|
|
53
|
+
stub.stubs(:get).raises(Exception, 'Internal Server Error')
|
54
|
+
end
|
55
|
+
response = @rip.get("/url")
|
56
|
+
response.code.should == '500'
|
57
|
+
response.body.should =~ /\AInternal Server Error\n\n/
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "Relevance::Tarantula::RailsIntegrationProxy patching" do
|
62
|
+
before do
|
63
|
+
@rip = Relevance::Tarantula::RailsIntegrationProxy.new(stub)
|
64
|
+
@rip.stubs(:rails_root).returns("faux_rails_root")
|
65
|
+
@response = stub_everything({:code => "404", :headers => {}})
|
66
|
+
File.stubs(:exist?).returns(true)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "patches in Relevance::CoreExtensions::Response" do
|
70
|
+
@rip = Relevance::Tarantula::RailsIntegrationProxy.new(stub)
|
71
|
+
@rip.stubs(:rails_root).returns("faux_rails_root")
|
72
|
+
@response = stub_everything({:code => "404", :headers => {}, :content_type => Mime::Type.new("text/html")})
|
73
|
+
@response.meta.ancestors.should_not include(Relevance::CoreExtensions::Response)
|
74
|
+
@rip.patch_response("/url", @response)
|
75
|
+
@response.meta.ancestors.should include(Relevance::CoreExtensions::Response)
|
76
|
+
@response.should be_html
|
77
|
+
end
|
78
|
+
|
79
|
+
it "replaces 404s with 200s, pulling content from public, for known text types" do
|
80
|
+
File.expects(:extension).returns("html")
|
81
|
+
@rip.expects(:static_content_file).with("/url").returns("File body")
|
82
|
+
@rip.patch_response("/url", @response)
|
83
|
+
@response.headers.should == {"type" => "text/html"}
|
84
|
+
end
|
85
|
+
|
86
|
+
it "logs and skips types we haven't dealt with yet" do
|
87
|
+
File.expects(:extension).returns("whizzy")
|
88
|
+
@rip.expects(:log).with("Skipping unknown type /url")
|
89
|
+
@rip.patch_response("/url", @response)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "can find static content relative to rails root" do
|
93
|
+
@rip.static_content_path("foo").should == File.expand_path("faux_rails_root/public/foo")
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can read static content relative to rails root" do
|
97
|
+
File.expects(:read).with(@rip.static_content_path("foo"))
|
98
|
+
@rip.static_content_file("foo")
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Relevance::Tarantula::Result" do
|
4
|
+
before do
|
5
|
+
@result = Relevance::Tarantula::Result.new(
|
6
|
+
:success => true,
|
7
|
+
:method => "get",
|
8
|
+
:url => "/some/url?arg1=foo&arg2=bar"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has a short description" do
|
13
|
+
@result.short_description.should == "get /some/url?arg1=foo&arg2=bar"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a sequence number" do
|
17
|
+
@result.class.next_number = 0
|
18
|
+
@result.sequence_number.should == 1
|
19
|
+
@result.class.next_number.should == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has link to the url at localhost" do
|
23
|
+
@result.full_url.should == "http://localhost:3000/some/url?arg1=foo&arg2=bar"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "Relevance::Tarantula::Result class methods" do
|
29
|
+
before do
|
30
|
+
@rh = Relevance::Tarantula::Result
|
31
|
+
end
|
32
|
+
|
33
|
+
it "defines HTTP responses that are considered 'successful' when spidering" do
|
34
|
+
%w{200 201 302 401}.each do |code|
|
35
|
+
@rh.successful?(stub(:code => code)).should == true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "adds successful responses to success collection" do
|
40
|
+
stub = stub_everything(:code => "200")
|
41
|
+
@rh.handle(Relevance::Tarantula::Result.new(:response => stub)).success.should == true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "adds failed responses to failure collection" do
|
45
|
+
stub = stub_everything(:code => "500")
|
46
|
+
result = @rh.handle(Relevance::Tarantula::Result.new(:response => stub))
|
47
|
+
result.success.should == false
|
48
|
+
result.description.should == "Bad HTTP Response"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "Relevance::Tarantula::Result allowed errors" do
|
54
|
+
before do
|
55
|
+
Relevance::Tarantula::Result.allow_errors_for = {}
|
56
|
+
end
|
57
|
+
|
58
|
+
it "defaults to *not* skip errors" do
|
59
|
+
Relevance::Tarantula::Result.can_skip_error?(stub(:code => "404")).should == false
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can skip errors matching code and url" do
|
63
|
+
Relevance::Tarantula::Result.allow_errors_for = {"404" => [/some_url/]}
|
64
|
+
Relevance::Tarantula::Result.can_skip_error?(stub(:code => "404", :url => "this_is_some_url")).should == true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "does not skip errors matching code only" do
|
68
|
+
Relevance::Tarantula::Result.allow_errors_for = {"404" => [/some_other_url/]}
|
69
|
+
Relevance::Tarantula::Result.can_skip_error?(stub(:code => "404", :url => "this_is_some_url")).should == false
|
70
|
+
end
|
71
|
+
|
72
|
+
it "users allow_nnn_for syntax to specify allowed errors" do
|
73
|
+
Relevance::Tarantula::Result.allow_404_for(/this_url/)
|
74
|
+
Relevance::Tarantula::Result.allow_errors_for.should == {"404" => [/this_url/]}
|
75
|
+
Relevance::Tarantula::Result.allow_404_for(/another_url/)
|
76
|
+
Relevance::Tarantula::Result.allow_errors_for.should == {"404" => [/this_url/, /another_url/]}
|
77
|
+
end
|
78
|
+
|
79
|
+
it "chains to super method missing" do
|
80
|
+
lambda{Relevance::Tarantula::Result.allow_xxx_for}.should raise_error(NoMethodError)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if defined?(Tidy) && ENV['TIDY_PATH']
|
4
|
+
describe "Relevance::Tarantula::TidyHandler default" do
|
5
|
+
before do
|
6
|
+
@handler = Relevance::Tarantula::TidyHandler.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "likes a good document" do
|
10
|
+
response = stub(:html? => true, :body => <<-BODY, :code => 200)
|
11
|
+
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
|
12
|
+
<html>
|
13
|
+
<title></title>
|
14
|
+
<body></body>
|
15
|
+
</html>
|
16
|
+
BODY
|
17
|
+
@handler.handle(Result.new(:response => response)).should == nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "rejects a document with errors" do
|
21
|
+
response = stub(:html? => true, :body => "<hotml>", :code => 200)
|
22
|
+
result = @handler.handle(Result.new(:response => response))
|
23
|
+
result.should.not.be nil
|
24
|
+
result.data.should =~ /Error: <hotml> is not recognized!/
|
25
|
+
result.description.should == "Bad HTML (Tidy)"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "rejects a document with warnings" do
|
29
|
+
response = stub(:html? => true, :body => <<-BODY, :code => 200)
|
30
|
+
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
|
31
|
+
<html>
|
32
|
+
</html>
|
33
|
+
BODY
|
34
|
+
result = @handler.handle(Result.new(:response => response))
|
35
|
+
result.should.not.be nil
|
36
|
+
result.data.should =~ /Warning: inserting missing 'title' element/
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "Relevance::Tarantula::TidyHandler with :show_warnings => false" do
|
42
|
+
before do
|
43
|
+
@handler = Relevance::Tarantula::TidyHandler.new(:show_warnings => false)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "permits a document with warnings" do
|
47
|
+
response = stub(:html? => true, :body => <<-BODY, :code => 200)
|
48
|
+
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
|
49
|
+
<html>
|
50
|
+
</html>
|
51
|
+
BODY
|
52
|
+
result = @handler.handle(Result.new(:response => response))
|
53
|
+
result.should.be nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
puts "TIDY_PATH not set. Tidy test will not run"
|
58
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Relevance::Tarantula::Transform" do
|
4
|
+
it "can do a simple replace" do
|
5
|
+
t = Relevance::Tarantula::Transform.new(/\w/, ".")
|
6
|
+
t["hello world"].should == "..... ....."
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can do a replace with a block" do
|
10
|
+
t = Relevance::Tarantula::Transform.new(/([aeiou])/, Proc.new {|value| value.upcase})
|
11
|
+
t["hello world"].should == "hEllO wOrld"
|
12
|
+
end
|
13
|
+
|
14
|
+
# this is broken in Ruby?
|
15
|
+
it "cannot access groups from a block, despite Ruby docs" do
|
16
|
+
p = Proc.new {|value| $1.upcase}
|
17
|
+
t = Relevance::Tarantula::Transform.new(/([aeiou])/, p)
|
18
|
+
lambda {t["hello world"]}.should raise_error(NoMethodError)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Relevance::Tarantula do
|
4
|
+
include Relevance::Tarantula
|
5
|
+
attr_accessor :verbose
|
6
|
+
|
7
|
+
it "writes to stdout if verbose" do
|
8
|
+
self.verbose = true
|
9
|
+
expects(:puts).with("foo")
|
10
|
+
log("foo")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "swallows output if !verbose" do
|
14
|
+
self.verbose = false
|
15
|
+
expects(:puts).never
|
16
|
+
log("foo")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "puts RAILS_ROOT behind a method call" do
|
20
|
+
lambda{rails_root}.should raise_error(NameError)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
if rails_version = ENV['RAILS_VERSION']
|
2
|
+
require 'rubygems'
|
3
|
+
gem "rails", rails_version
|
4
|
+
end
|
5
|
+
|
6
|
+
require "rails/version"
|
7
|
+
puts "==== Testing with Rails #{Rails::VERSION::STRING} ===="
|
8
|
+
|
9
|
+
require 'relevance/tarantula'
|
10
|
+
require 'bundler'
|
11
|
+
Bundler.require
|
12
|
+
require 'ostruct'
|
13
|
+
|
14
|
+
def test_output_dir
|
15
|
+
File.join(File.dirname(__FILE__), "..", "tmp", "test_output")
|
16
|
+
end
|
17
|
+
|
18
|
+
# TODO change puts/print to use a single method for logging, which will then make the stubbing cleaner
|
19
|
+
def stub_puts_and_print(obj)
|
20
|
+
obj.stubs(:puts)
|
21
|
+
obj.stubs(:print)
|
22
|
+
end
|
23
|
+
|
24
|
+
def make_link(link, crawler=Relevance::Tarantula::Crawler.new, referrer=nil)
|
25
|
+
Relevance::Tarantula::Link.new(link, crawler, referrer)
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_form(form, crawler=Relevance::Tarantula::Crawler.new, referrer=nil)
|
29
|
+
Relevance::Tarantula::Form.new(form, crawler, referrer)
|
30
|
+
end
|
31
|
+
|
32
|
+
def not_in_editor?
|
33
|
+
['TM_MODE', 'EMACS', 'VIM'].all? { |k| !ENV.has_key?(k) }
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec.configure do |c|
|
37
|
+
c.alias_example_to :fit, :focused => true
|
38
|
+
c.alias_example_to :xit, :disabled => true
|
39
|
+
c.mock_with :mocha
|
40
|
+
c.color_enabled = not_in_editor?
|
41
|
+
c.filter_run :focused => true
|
42
|
+
c.run_all_when_everything_filtered = true
|
43
|
+
end
|
data/tarantula.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "relevance/tarantula/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "codez-tarantula"
|
7
|
+
s.version = Relevance::Tarantula::VERSION
|
8
|
+
s.authors = ["Relevance, Inc.", "code!z"]
|
9
|
+
s.email = ["spam@codez.ch"]
|
10
|
+
s.homepage = "https://github.com/codez/tarantula"
|
11
|
+
s.summary = %q{A big hairy fuzzy spider that crawls your site, wreaking havoc}
|
12
|
+
s.description = "Tarantula is a big fuzzy spider. It crawls your Rails 2.3 and 3.x applications, fuzzing data to see what breaks."
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {examples,template}`.split("\n")
|
16
|
+
|
17
|
+
s.add_runtime_dependency "htmlentities", "~> 4.3.0"
|
18
|
+
s.add_runtime_dependency "hpricot", "~> 0.8.4"
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec", "~> 2.12.0"
|
21
|
+
s.add_development_dependency 'rdoc', '~> 3.12.0'
|
22
|
+
s.add_development_dependency "log_buddy", "~> 0.6.0"
|
23
|
+
s.add_development_dependency "mocha", "~> 0.13.2"
|
24
|
+
s.add_development_dependency "rails", ">= 2.3.0"
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "relevance/tarantula"
|
3
|
+
|
4
|
+
class TarantulaTest < ActionController::IntegrationTest
|
5
|
+
# Load enough test data to ensure that there's a link to every page in your
|
6
|
+
# application. Doing so allows Tarantula to follow those links and crawl
|
7
|
+
# every page. For many applications, you can load a decent data set by
|
8
|
+
# loading all fixtures.
|
9
|
+
fixtures :all
|
10
|
+
|
11
|
+
def test_tarantula
|
12
|
+
# If your application requires users to log in before accessing certain
|
13
|
+
# pages, uncomment the lines below and update them to allow this test to
|
14
|
+
# log in to your application. Doing so allows Tarantula to crawl the
|
15
|
+
# pages that are only accessible to logged-in users.
|
16
|
+
#
|
17
|
+
# post '/session', :login => 'quentin', :password => 'monkey'
|
18
|
+
# follow_redirect!
|
19
|
+
|
20
|
+
tarantula_crawl(self)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Trampoline Systems
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,76 @@
|
|
1
|
+
FIXME: THIS README IS NOT UP-TO-DATE.
|
2
|
+
|
3
|
+
This plugin provides XSS protection for views coded in HAML and RHTML.
|
4
|
+
|
5
|
+
ERB templates are sometimes used for HTML, and sometimes for
|
6
|
+
other kinds of languages (SQL, email templates, YAML etc.).
|
7
|
+
XSS Shield protects only those templates with .rhtml extension,
|
8
|
+
leaving templates with .erb extension unprotected.
|
9
|
+
|
10
|
+
=== Quick start ===
|
11
|
+
|
12
|
+
Assuming you're using HAML for all your templates.
|
13
|
+
|
14
|
+
* Install plugin.
|
15
|
+
* Edit all your layout files and change:
|
16
|
+
= @content_for_layout
|
17
|
+
= yield(:foo) # Foo being usually :js or :css
|
18
|
+
to:
|
19
|
+
= @content_for_layout.mark_as_xss_protected
|
20
|
+
= yield(:foo).mark_as_xss_protected
|
21
|
+
* By this point your application should be runnanble,
|
22
|
+
but might need some tweaking here and there to avoid potential
|
23
|
+
double-escaping.
|
24
|
+
|
25
|
+
=== How it works ===
|
26
|
+
|
27
|
+
It works by subclassing String into SafeString.
|
28
|
+
When HAML engine seems a "= foo" fragment it check if result of executing "foo"
|
29
|
+
is a SafeString. If it is - it copies it to the output, if it's anything else
|
30
|
+
(String, Integer, nil and so on) it HTML-escapes it first.
|
31
|
+
|
32
|
+
To avoid double-escaping output of h is a SafeString, as is everything you
|
33
|
+
mark as XSS-protected.
|
34
|
+
= h(@foo)
|
35
|
+
= @foo # fully equivalent to h(@foo)
|
36
|
+
= "X <br /> Y".mark_as_xss_protected
|
37
|
+
|
38
|
+
It would be cumbersome to require mark_as_xss_protected every time you use
|
39
|
+
some helper like render :partial or link_to, so some helpers are modified
|
40
|
+
to return SafeString.
|
41
|
+
|
42
|
+
= render :partial => "foo"
|
43
|
+
= link_to "Bar", :action => :bar
|
44
|
+
|
45
|
+
If you trust your helpers, make them as XSS-protected:
|
46
|
+
|
47
|
+
module Some::Module
|
48
|
+
mark_helpers_as_xss_protected :text_field, :check_box
|
49
|
+
end
|
50
|
+
|
51
|
+
Because it is not possible to alter syntactic keywords like yield
|
52
|
+
or instance variables like @content_for_layout to mark them automatically
|
53
|
+
as secure, layout files need some manual tweaking.
|
54
|
+
|
55
|
+
=== Other template engines ===
|
56
|
+
|
57
|
+
If a templates uses some templating engine other than HAML or ERB,
|
58
|
+
or it uses ERB but has extension .erb not .rhtml, XSS Shield does not protect it.
|
59
|
+
|
60
|
+
However some helpers like link_to and button_to are patched by XSS Shield to
|
61
|
+
make them more secure, and this extra security will be there even when used
|
62
|
+
in an otherwise unprotected context.
|
63
|
+
|
64
|
+
For example with XSS shield
|
65
|
+
link_to "A & B", "/foo"
|
66
|
+
will return (marked as safe):
|
67
|
+
'<a href="/foo">A & B</a>'
|
68
|
+
not (plain String):
|
69
|
+
'<a href="/foo">A & B</a>'
|
70
|
+
|
71
|
+
Also - RHTML protection only works with default ERB engine (erb.rb from Ruby base).
|
72
|
+
If you use some alternative ERB engine it probably won't work.
|
73
|
+
|
74
|
+
Adding support for alternative templating engine should be relatively straightforward.
|
75
|
+
It's mostly a matter of changing to_s to to_s_xss_protected in a few places
|
76
|
+
in their source.
|