class OwaspZap::Spider

Public Class Methods

new(params = {}) click to toggle source
# File lib/owasp_zap/spider.rb, line 4
def initialize(params = {})
    #TODO
    #handle it
    @base = params[:base]
    @target = params[:target]
end

Public Instance Methods

depth() click to toggle source
# File lib/owasp_zap/spider.rb, line 38
def depth
     JSON.parse(RestClient::get("#{@base}/JSON/spider/view/optionMaxDepth/?zapapiformat=JSON"))
end
running?() click to toggle source
# File lib/owasp_zap/spider.rb, line 42
def running?
     self.status != 100
end
set_depth(max_d) click to toggle source
# File lib/owasp_zap/spider.rb, line 31
def set_depth(max_d)
     #http://localhost:8084/JSON/spider/action/setOptionMaxDepth/?Integer=1
     url = Addressable::URI.parse("#{@base}/JSON/spider/action/setOptionMaxDepth/")
     url.query_values = {:integer=>max_d.to_i}
     RestClient::get url.normalize.to_str
end
start() click to toggle source
# File lib/owasp_zap/spider.rb, line 11
def start
    #http://localhost:8080/JSON/spider/action/scan/?zapapiformat=JSON&url=
    url = Addressable::URI.parse "#{@base}/JSON/spider/action/scan/"
    url.query_values = {:zapapiformat=>"JSON",:url=>@target}
    RestClient::get url.normalize.to_str
end
status() click to toggle source
# File lib/owasp_zap/spider.rb, line 22
 def status
     ret = JSON.parse(RestClient::get("#{@base}/JSON/spider/view/status/?zapapiformat=JSON"))
     if ret.has_key? "status"
         ret["status"].to_i
     else
         100 # it means not running
     end
end
stop() click to toggle source
# File lib/owasp_zap/spider.rb, line 18
def stop
    RestClient::get "#{@base}/JSON/spider/action/stop/?zapapiformat=JSON"
end