Class: OwaspZap::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/owasp_zap/scanner.rb

Overview

TODO maybe create a policy class as well

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Scanner

Returns a new instance of Scanner.



5
6
7
# File 'lib/owasp_zap/scanner.rb', line 5

def initialize(params = {})
    @base = params[:base]
end

Instance Method Details

#disable(policy_ids = [0]) ⇒ Object



16
17
18
19
20
21
# File 'lib/owasp_zap/scanner.rb', line 16

def disable(policy_ids=[0])
    # http://127.0.0.1:8080/JSON/ascan/action/disableScanners/?zapapiformat=JSON&ids=0
    url = Addressable::URI.parse("#{@base}/JSON/ascan/action/disableScanners/")
    url.query_values = {:zapapiformat=>"JSON",:ids=>policy_ids.join(',')}
    RestClient::get url.normalize.to_str
end

#enable(policy_ids = [0]) ⇒ Object



23
24
25
26
27
28
# File 'lib/owasp_zap/scanner.rb', line 23

def enable(policy_ids=[0])
    # http://127.0.0.1:8080/JSON/ascan/action/enableScanners/?zapapiformat=JSON&ids=0
    url = Addressable::URI.parse("#{@base}/JSON/ascan/action/enableScanners/")
    url.query_values = {:zapapiformat=>"JSON",:ids=>policy_ids.join(',')}
    RestClient::get url.normalize.to_str
end

#view(policy_id = 0) ⇒ Object



9
10
11
12
13
14
# File 'lib/owasp_zap/scanner.rb', line 9

def view(policy_id = 0)
    # http://127.0.0.1:8080/JSON/ascan/view/scanners/?zapapiformat=JSON&policyId=0
    url = Addressable::URI.parse("#{@base}/JSON/ascan/view/scanners/")
    url.query_values = {:zapapiformat=>"JSON",:policyId=>policy_id}
    RestClient::get url.normalize.to_str
end