owasp_zap 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +17 -0
- data/lib/owasp_zap.rb +87 -0
- data/lib/owasp_zap/alert.rb +18 -0
- data/lib/owasp_zap/attack.rb +21 -0
- data/lib/owasp_zap/auth.rb +72 -0
- data/lib/owasp_zap/spider.rb +27 -0
- data/lib/owasp_zap/string_extension.rb +16 -0
- data/lib/owasp_zap/version.rb +3 -0
- data/owasp_zap.gemspec +29 -0
- data/spec/auth_spec.rb +52 -0
- data/spec/helper.rb +8 -0
- data/spec/zap_spec.rb +122 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a80255539473310bacf8733abfdc8f71b4abec7d
|
4
|
+
data.tar.gz: 508ea5d854379c64d306da68d08a577c90d207c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b9147943357fdd6fee21cc68375f419c2cbc46ca8fe6ac3cae2400f5dbdd18f49f755dbabd8a4819be1a82de0e71a25b52e5818a11d254675755c820dd95f1d
|
7
|
+
data.tar.gz: 56f636883c71f7399bf8008e7bc16f44adbb16bb6fd9a8512a8b5b9bd16bc73cc00f18e1163dac6c9bf1badcdf5cfd5983941d47e35275b2d0c4be4b12e0b291
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# OwaspZap
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'owasp_zap'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install owasp_zap
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs.push ["lib/owasp_zap","spec"]
|
6
|
+
t.test_files = FileList['spec/*_spec.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :test do
|
11
|
+
desc "test coverage report"
|
12
|
+
task :coverage do
|
13
|
+
Rake::Task["test"].execute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default=> :test
|
data/lib/owasp_zap.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require "json"
|
2
|
+
require "rest_client"
|
3
|
+
require "addressable/uri"
|
4
|
+
require "cgi"
|
5
|
+
|
6
|
+
require_relative "owasp_zap/version"
|
7
|
+
require_relative "owasp_zap/string_extension"
|
8
|
+
require_relative "owasp_zap/spider"
|
9
|
+
require_relative "owasp_zap/attack"
|
10
|
+
require_relative "owasp_zap/alert"
|
11
|
+
require_relative "owasp_zap/auth"
|
12
|
+
|
13
|
+
module OwaspZap
|
14
|
+
class ZapException < Exception;end
|
15
|
+
|
16
|
+
class Zap
|
17
|
+
attr_accessor :target,:base
|
18
|
+
|
19
|
+
def initialize(params = {})
|
20
|
+
#TODO
|
21
|
+
# handle params
|
22
|
+
@base = params[:base] || "http://127.0.0.1:8080/JSON"
|
23
|
+
@target = params[:target]
|
24
|
+
@zap_bin = params [:zap] || "#{ENV['HOME']}/ZAP/zap.sh"
|
25
|
+
end
|
26
|
+
|
27
|
+
def status_for(component)
|
28
|
+
case component
|
29
|
+
when :ascan
|
30
|
+
Zap::Attack.new(:base=>@base,:target=>@target).status
|
31
|
+
when :spider
|
32
|
+
Zap::Spider.new(:base=>@base,:target=>@target).status
|
33
|
+
else
|
34
|
+
{:status=>"unknown component"}.to_json
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
def ok?(json_data)
|
39
|
+
json_data.is_a?(Hash) and json_data[0] == "OK"
|
40
|
+
end
|
41
|
+
|
42
|
+
def running?
|
43
|
+
begin
|
44
|
+
response = RestClient::get "#{@base}"
|
45
|
+
rescue Errno::ECONNREFUSED
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
response.code == 200
|
49
|
+
end
|
50
|
+
|
51
|
+
def alerts
|
52
|
+
Zap::Alert.new(:base=>@base,:target=>@target)
|
53
|
+
end
|
54
|
+
|
55
|
+
#attack
|
56
|
+
def ascan
|
57
|
+
Zap::Attack.new(:base=>@base,:target=>@target)
|
58
|
+
end
|
59
|
+
|
60
|
+
def spider
|
61
|
+
Zap::Spider.new(:base=>@base,:target=>@target)
|
62
|
+
end
|
63
|
+
|
64
|
+
def auth
|
65
|
+
Zap::Auth.new(:base=>@base)
|
66
|
+
end
|
67
|
+
|
68
|
+
#TODO
|
69
|
+
#DOCUMENT the step necessary: install ZAP under $home/ZAP or should be passed to new as :zap parameter
|
70
|
+
def start
|
71
|
+
fork do
|
72
|
+
exec @zap_bin
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#shutdown zap
|
77
|
+
def shutdown
|
78
|
+
RestClient::get "#{@base}/core/action/shutdown/"
|
79
|
+
end
|
80
|
+
|
81
|
+
#xml report
|
82
|
+
#maybe it should be refactored to alert.
|
83
|
+
def xml_report
|
84
|
+
RestClient::get "#{@base}/OTHER/core/other/xmlreport/"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OwaspZap
|
2
|
+
class Alert
|
3
|
+
def initialize(params = {})
|
4
|
+
#handle params
|
5
|
+
@base = params[:base]
|
6
|
+
@target = params[:target]
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# the API has an option to give an offset (start) and the amount of alerts (count) as parameter
|
11
|
+
def view
|
12
|
+
#http://localhost:8080/JSON/core/view/alerts/?zapapiformat=JSON&baseurl=http%3A%2F%2F192.168.1.113&start=&count=
|
13
|
+
url = Addressable::URI.parse "#{@base}/core/view/alerts/"
|
14
|
+
url.query_values = {:zapapiformat=>"JSON",:baseurl=>@target}
|
15
|
+
RestClient::get url.normalize.to_str
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OwaspZap
|
2
|
+
class Attack
|
3
|
+
def initialize(params = {})
|
4
|
+
#TODO
|
5
|
+
#handle it
|
6
|
+
@base = params[:base]
|
7
|
+
@target = params[:target]
|
8
|
+
end
|
9
|
+
|
10
|
+
def start
|
11
|
+
url = Addressable::URI.parse "#{@base}/ascan/action/scan/"
|
12
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>@target}
|
13
|
+
RestClient::get url.normalize.to_str
|
14
|
+
end
|
15
|
+
|
16
|
+
def status
|
17
|
+
RestClient::get "#{@base}/ascan/view/status/?zapapiformat=JSON"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module OwaspZap
|
2
|
+
class Auth
|
3
|
+
attr_accessor :ctx,:base
|
4
|
+
def initialize(params = {})
|
5
|
+
@ctx = params[:context] || 1 #default context is the1
|
6
|
+
@base = params[:base] || "http://127.0.0.1:8080/JSON"
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# define dynamically the methods from: http://127.0.0.1:8080/UI/auth/
|
11
|
+
#
|
12
|
+
#
|
13
|
+
[:login_url, :logout_url, :login_data, :logout_data, :logged_in_indicator, :logged_out_indicator].each do |method|
|
14
|
+
define_method method do
|
15
|
+
RestClient::get "#{@base}/auth/view/#{to_url(method)}/?zapapiformat=JSON&contextId=#{@ctx}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# define methods login, logout
|
21
|
+
#
|
22
|
+
#
|
23
|
+
[:login,:logout].each do |method|
|
24
|
+
define_method method do
|
25
|
+
RestClient::get "#{@base}/auth/action/#{to_url(method)}/?zapapiformat=JSON&contextId=#{@ctx}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# params:
|
30
|
+
# args a hash with the following keys -> values
|
31
|
+
# url: url including http://
|
32
|
+
# post_data: an already encoded string like "email%3Dfoo%2540example.org%26passwd%3Dfoobar"
|
33
|
+
# TODO: offer a way to encode it, giving a hash?
|
34
|
+
def set_login_url(args)
|
35
|
+
url = Addressable::URI.parse "#{@base}/auth/action/setLoginUrl/"
|
36
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>args[:url],:postData=>args[:post_data],:contextId=>@ctx}
|
37
|
+
RestClient::get url.normalize.to_str
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_logout_url(args)
|
41
|
+
url = Addressable::URI.parse "#{@base}/auth/action/setLogoutUrl/"
|
42
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>args[:url],:postData=>args[:post_data],:contextId=>@ctx}
|
43
|
+
RestClient::get url.normalize.to_str
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_logged_in_indicator(args)
|
47
|
+
url = Addressable::URI.parse "#{@base}/auth/action/setLoggedInIndicator/"
|
48
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>args[:url],:postData=>args[:indicator],:contextId=>@ctx}
|
49
|
+
RestClient::get url.normalize.to_str
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_logged_out_indicator(args)
|
53
|
+
url = Addressable::URI.parse "#{@base}/auth/action/setLoggedOutIndicator/"
|
54
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>args[:url],:indicator=>args[:indicator],:contextId=>@ctx}
|
55
|
+
RestClient::get url.normalize.to_str
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def to_url(str)
|
60
|
+
method_str = str.to_s
|
61
|
+
method_str.extend OwaspZap::StringExtension # monkey patch just this instance
|
62
|
+
method_str.camel_case
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_method(str)
|
66
|
+
method_str = str.to_s
|
67
|
+
method_str.extend OwaspZap::StringExtension # monkey patch just this instance
|
68
|
+
method_str.snake_case
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module OwaspZap
|
2
|
+
class Spider
|
3
|
+
|
4
|
+
def initialize(params = {})
|
5
|
+
#TODO
|
6
|
+
#handle it
|
7
|
+
@base = params[:base]
|
8
|
+
@target = params[:target]
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
#http://localhost:8080/JSON/spider/action/scan/?zapapiformat=JSON&url=
|
13
|
+
url = Addressable::URI.parse "#{@base}/spider/action/scan/"
|
14
|
+
url.query_values = {:zapapiformat=>"JSON",:url=>@target}
|
15
|
+
RestClient::get url.normalize.to_str
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
RestClient::get "#{@base}/spider/action/stop/?zapapiformat=JSON"
|
20
|
+
end
|
21
|
+
|
22
|
+
def status
|
23
|
+
RestClient::get "#{@base}/spider/view/status/?zapapiformat=JSON"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OwaspZap
|
2
|
+
# extending String instance
|
3
|
+
module StringExtension
|
4
|
+
# from camel_case to snake_case: ie: fooBar to foo_bar
|
5
|
+
def snake_case
|
6
|
+
return downcase if match(/\A[A-Z]+\z/)
|
7
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
8
|
+
gsub(/([a-z])([A-Z])/, '\1_\2').
|
9
|
+
downcase
|
10
|
+
end
|
11
|
+
# from snake_case to camel_case: ie: foo_bar to fooBar
|
12
|
+
def camel_case
|
13
|
+
self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/owasp_zap.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'owasp_zap/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "owasp_zap"
|
8
|
+
spec.version = OwaspZap::VERSION
|
9
|
+
spec.authors = ["Victor Pereira"]
|
10
|
+
spec.email = ["vpereira@suse.de"]
|
11
|
+
spec.description = %q{ruby wrapper for ZAP}
|
12
|
+
spec.summary = %q{ruby wrapper for the zed application proxy}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
spec.add_development_dependency "simplecov"
|
25
|
+
spec.add_development_dependency "webmock"
|
26
|
+
spec.add_dependency "rest-client"
|
27
|
+
spec.add_dependency "addressable"
|
28
|
+
end
|
29
|
+
|
data/spec/auth_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe OwaspZap::Auth do
|
4
|
+
before do
|
5
|
+
@auth = OwaspZap::Auth.new
|
6
|
+
end
|
7
|
+
it "should have context 1" do
|
8
|
+
assert_equal(@auth.ctx,1)
|
9
|
+
end
|
10
|
+
it "should have base on localhost" do
|
11
|
+
assert_equal @auth.base,"http://127.0.0.1:8080/JSON"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Auth view methods" do
|
16
|
+
before do
|
17
|
+
@h = OwaspZap::Auth.new
|
18
|
+
@methods = [:login_url, :logout_url, :login_data, :logout_data, :logged_in_indicator, :logged_out_indicator]
|
19
|
+
@methods.each do |m|
|
20
|
+
m_str = m.to_s
|
21
|
+
m_str.extend OwaspZap::StringExtension
|
22
|
+
m_str = m_str.camel_case
|
23
|
+
stub_request(:get, "http://127.0.0.1:8080/JSON/auth/view/#{m_str}/?zapapiformat=JSON&contextId=1").to_return(:status => 200, :body => "{\"Result\":\"OK\"}" , :headers => {})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should request all view methods" do
|
28
|
+
@methods.each do |m|
|
29
|
+
m_str = m.to_s
|
30
|
+
m_str.extend OwaspZap::StringExtension
|
31
|
+
m_str = m_str.camel_case
|
32
|
+
@h.send(m)
|
33
|
+
assert_requested :get,"http://127.0.0.1:8080/JSON/auth/view/#{m_str}/?zapapiformat=JSON&contextId=1"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "Login/Logout" do
|
39
|
+
before do
|
40
|
+
@h = OwaspZap::Auth.new
|
41
|
+
stub_request(:get, "http://127.0.0.1:8080/JSON/auth/action/logout/?zapapiformat=JSON&contextId=1").to_return(:status => 200, :body => "{\"Result\":\"OK\"}" , :headers => {})
|
42
|
+
stub_request(:get, "http://127.0.0.1:8080/JSON/auth/action/login/?zapapiformat=JSON&contextId=1").to_return(:status => 200, :body => "{\"Result\":\"OK\"}" , :headers => {})
|
43
|
+
end
|
44
|
+
it "should call the login url" do
|
45
|
+
@h.login
|
46
|
+
assert_requested :get,"http://127.0.0.1:8080/JSON/auth/action/login/?zapapiformat=JSON&contextId=1"
|
47
|
+
end
|
48
|
+
it "should call the logout url" do
|
49
|
+
@h.logout
|
50
|
+
assert_requested :get,"http://127.0.0.1:8080/JSON/auth/action/logout/?zapapiformat=JSON&contextId=1"
|
51
|
+
end
|
52
|
+
end
|
data/spec/helper.rb
ADDED
data/spec/zap_spec.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
include OwaspZap
|
4
|
+
|
5
|
+
describe Zap do
|
6
|
+
before do
|
7
|
+
@zap = Zap.new(:target=>'http://127.0.0.1')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "shouldnt be nil" do
|
11
|
+
@zap.wont_be :nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a target" do
|
15
|
+
@zap.respond_to? :target
|
16
|
+
end
|
17
|
+
|
18
|
+
it "target shouldnt be nil" do
|
19
|
+
@zap.target.wont_be :nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a base" do
|
23
|
+
assert_respond_to @zap,:base
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have method start" do
|
27
|
+
assert_respond_to @zap,:start
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a method shutdown" do
|
31
|
+
assert_respond_to @zap,:shutdown
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should respond_to to spider" do
|
35
|
+
assert_respond_to @zap,:spider
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should call spider and get a spider object" do
|
39
|
+
assert_equal @zap.spider.class,Zap::Spider
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respond_to auth" do
|
43
|
+
assert_respond_to @zap,:auth
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should call auth and get an auth object" do
|
47
|
+
assert_equal @zap.auth.class, Zap::Auth
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should respond_to ascan" do
|
51
|
+
assert_respond_to @zap,:ascan
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should call ascan and get an attack object" do
|
55
|
+
assert_equal @zap.ascan.class, Zap::Attack
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should respond_to alerts" do
|
59
|
+
assert_respond_to @zap,:alerts
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should call alerts and get a alert object" do
|
63
|
+
assert_equal @zap.alerts.class,Zap::Alert
|
64
|
+
end
|
65
|
+
|
66
|
+
it "base shouldnt be nil" do
|
67
|
+
@zap.base.wont_be :nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
it "base default should be http://127.0.0.1:8080/JSON" do
|
71
|
+
assert_equal @zap.base, "http://127.0.0.1:8080/JSON"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "changing default params" do
|
76
|
+
it "should be able to set base" do
|
77
|
+
@zap = Zap.new(:target=>'http://127.0.0.1',:base=>'http://127.0.0.2:8383')
|
78
|
+
assert_equal @zap.base, "http://127.0.0.2:8383"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "method shutdown" do
|
83
|
+
before do
|
84
|
+
@h = Zap::Zap.new :target=>"http://127.0.0.1"
|
85
|
+
stub_request(:get, "http://127.0.0.1:8080/JSON/core/action/shutdown/").to_return(:status => 200, :body => "{\"Result\":\"OK\"}" , :headers => {})
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should receive a json as answer" do
|
89
|
+
@h.shutdown.wont_be :nil?
|
90
|
+
end
|
91
|
+
it "should request the shutdown url" do
|
92
|
+
@h.shutdown
|
93
|
+
assert_requested :get,"http://127.0.0.1:8080/JSON/core/action/shutdown/"
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "StringExtension" do
|
99
|
+
it "should not respond_to camel_case and snake_case" do
|
100
|
+
@str = ""
|
101
|
+
[:camel_case,:snake_case].each do |m|
|
102
|
+
refute_respond_to(@str,m)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
it "should respond_to camel_case and snake_case" do
|
106
|
+
@str = ""
|
107
|
+
@str.extend Zap::StringExtension
|
108
|
+
[:camel_case,:snake_case].each do |m|
|
109
|
+
assert_respond_to @str,m
|
110
|
+
end
|
111
|
+
end
|
112
|
+
it "should answer to camel_case" do
|
113
|
+
@str = "foo_bar"
|
114
|
+
@str.extend Zap::StringExtension
|
115
|
+
assert_equal @str.camel_case,"fooBar"
|
116
|
+
end
|
117
|
+
it "should answer to snake_case" do
|
118
|
+
@str = "fooBar"
|
119
|
+
@str.extend Zap::StringExtension
|
120
|
+
assert_equal @str.snake_case,"foo_bar"
|
121
|
+
end
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: owasp_zap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Victor Pereira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: addressable
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: ruby wrapper for ZAP
|
112
|
+
email:
|
113
|
+
- vpereira@suse.de
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/owasp_zap.rb
|
125
|
+
- lib/owasp_zap/alert.rb
|
126
|
+
- lib/owasp_zap/attack.rb
|
127
|
+
- lib/owasp_zap/auth.rb
|
128
|
+
- lib/owasp_zap/spider.rb
|
129
|
+
- lib/owasp_zap/string_extension.rb
|
130
|
+
- lib/owasp_zap/version.rb
|
131
|
+
- owasp_zap.gemspec
|
132
|
+
- spec/auth_spec.rb
|
133
|
+
- spec/helper.rb
|
134
|
+
- spec/zap_spec.rb
|
135
|
+
homepage: ''
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.0.14
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: ruby wrapper for the zed application proxy
|
159
|
+
test_files:
|
160
|
+
- spec/auth_spec.rb
|
161
|
+
- spec/helper.rb
|
162
|
+
- spec/zap_spec.rb
|