class Nessus6::Policy

The Policy class is for defining scan test parameters. localhost:8834/api#/resources/policies

Public Class Methods

new(client) click to toggle source
# File lib/Nessus6/policy.rb, line 10
def initialize(client)
  @client = client
end

Public Instance Methods

configure(policy_id, uuid, settings_acl) click to toggle source

Changes the parameters of a policy

@param policy_id [String, Fixnum] The id of the policy to change @param uuid [String] The uuid for the editor template to use @param settings_acl [Array] An array containing permissions to apply to the policy @return [Hash]

# File lib/Nessus6/policy.rb, line 21
def configure(policy_id, uuid, settings_acl)
  response = @client.put "policies/#{policy_id}", uuid: uuid, 'settings.acl' => settings_acl
  verify response,
         not_found: 'The requested policy does not exist.',
         internal_server_error: 'Error occurred while saving the configuration.'
end
copy(policy_id) click to toggle source

Copy a policy

@param policy_id [String, Fixnum] The id of the policy to copy @return [Hash]

# File lib/Nessus6/policy.rb, line 32
def copy(policy_id)
  response = @client.post "policies/#{policy_id}/copy"
  verify response,
         unauthorized: 'You do not have permission to copy this policy.',
         not_found: 'The requested policy does not exist.',
         internal_server_error: 'Failed to copy the policy. Internal server error.'
end
create(uuid) click to toggle source

Creates a policy

@param uuid [String] The uuid of the editor template to use @return [Hash]

# File lib/Nessus6/policy.rb, line 44
def create(uuid)
  response = @client.post 'policies', uuid: uuid
  verify response,
         not_found: 'Could not find a scan with the requested UUID',
         internal_server_error: 'Failed to save policy. Internal server error.'
end
delete(policy_id) click to toggle source

Delete a policy

@param policy_id [String, Fixnum] The id of the policy to delete @return [Hash]

# File lib/Nessus6/policy.rb, line 56
def delete(policy_id)
  response = @client.delete "policies/#{policy_id}"
  verify response,
         unauthorized: 'You do not have permission to delete the policy.',
         not_found: 'Could not find a policy with the provided ID.',
         not_allowed: 'Policy is in use by a scan.'
end
details(policy_id) click to toggle source

Returns the details for the given policy

@param policy_id [String, Fixnum] The id of the policy to retrieve. @return [Hash]

# File lib/Nessus6/policy.rb, line 68
def details(policy_id)
  response = @client.get "policies/#{policy_id}"
  verify response,
         not_found: 'Could not find a policy with that ID.'
end
export(policy_id) click to toggle source

Export the given policy

@param policy_id [String, Fixnum] The id of the policy to export @return [Hash]

# File lib/Nessus6/policy.rb, line 78
def export(policy_id)
  response = @client.get "policies/#{policy_id}/export"
  verify response,
         unauthorized: 'You do not have permission to export the policy.',
         not_found: 'Policy with the provided ID does not exist'
end
list() click to toggle source

Returns the policy list

@return [Hash] Policy resource(s)

# File lib/Nessus6/policy.rb, line 88
def list
  response = @client.get 'policies'
  verify response,
         internal_server_error: 'Internal server error occurred.'
end