class Nexpose::SiloProfile
Attributes
all_global_engines[RW]
all_global_report_templates[RW]
all_global_scan_templates[RW]
all_licensed_modules[RW]
description[RW]
global_report_templates[RW]
global_scan_engines[RW]
global_scan_templates[RW]
id[RW]
licensed_modules[RW]
name[RW]
restricted_report_formats[RW]
restricted_report_sections[RW]
Public Class Methods
copy(connection, id)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 58 def self.copy(connection, id) profile = load(connection, id) profile.id = nil profile.name = nil profile end
load(connection, id)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 65 def self.load(connection, id) r = connection.execute(connection.make_xml('SiloProfileConfigRequest', { 'silo-profile-id' => id }), '1.2') if r.success r.res.elements.each('SiloProfileConfigResponse/SiloProfileConfig') do |config| return SiloProfile.parse(config) end end nil end
new(&block)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 48 def initialize(&block) instance_eval(&block) if block_given? @global_report_templates = Array(@global_report_templates) @global_scan_engines = Array(@global_scan_engines) @global_scan_templates = Array(@global_scan_templates) @licensed_modules = Array(@licensed_modules) @restricted_report_formats = Array(@restricted_report_formats) @restricted_report_sections = Array(@restricted_report_sections) end
parse(xml)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 76 def self.parse(xml) new do |profile| profile.id = xml.attributes['id'] profile.name = xml.attributes['name'] profile.description = xml.attributes['description'] profile.all_licensed_modules = xml.attributes['all-licensed-modules'].to_s.chomp.eql?('true') profile.all_global_engines = xml.attributes['all-global-engines'].to_s.chomp.eql?('true') profile.all_global_report_templates = xml.attributes['all-global-report-templates'].to_s.chomp.eql?('true') profile.all_global_scan_templates = xml.attributes['all-global-scan-templates'].to_s.chomp.eql?('true') profile.global_report_templates = [] xml.elements.each('GlobalReportTemplates/GlobalReportTemplate') { |template| profile.global_report_templates << template.attributes['name'] } profile.global_scan_engines = [] xml.elements.each('GlobalScanEngines/GlobalScanEngine') { |engine| profile.global_scan_engines << engine.attributes['name'] } profile.global_scan_templates = [] xml.elements.each('GlobalScanTemplates/GlobalScanTemplate') { |template| profile.global_scan_templates << template.attributes['name'] } profile.licensed_modules = [] xml.elements.each('LicensedModules/LicensedModule') { |license_module| profile.licensed_modules << license_module.attributes['name'] } profile.restricted_report_formats = [] xml.elements.each('RestrictedReportFormats/RestrictedReportFormat') { |format| profile.restricted_report_formats << format.attributes['name'] } profile.restricted_report_sections = [] xml.elements.each('RestrictedReportSections/RestrictedReportSection') { |section| profile.restricted_report_sections << section.attributes['name'] } end end
Public Instance Methods
as_xml()
click to toggle source
# File lib/nexpose/silo_profile.rb, line 141 def as_xml xml = REXML::Element.new('SiloProfileConfig') xml.add_attributes({ 'id' => @id, 'name' => @name, 'description' => @description, 'all-licensed-modules' => @all_licensed_modules, 'all-global-engines' => @all_global_engines, 'all-global-report-templates' => @all_global_report_templates, 'all-global-scan-templates' => @all_global_scan_templates }) unless @global_report_templates.empty? templates = xml.add_element('GlobalReportTemplates') @global_report_templates.each do |template| templates.add_element('GlobalReportTemplate', { 'name' => template }) end end unless @global_scan_engines.empty? engines = xml.add_element('GlobalScanEngines') @global_scan_engines.each do |engine| engines.add_element('GlobalScanEngine', { 'name' => engine }) end end unless @global_scan_templates.empty? templates = xml.add_element('GlobalScanTemplates') @global_scan_templates.each do |template| templates.add_element('GlobalScanTemplate', { 'name' => template }) end end unless @licensed_modules.empty? licensed_modules = xml.add_element('LicensedModules') @licensed_modules.each do |licensed_module| licensed_modules.add_element('LicensedModule', { 'name' => licensed_module }) end end unless @restricted_report_formats.empty? formats = xml.add_element('RestrictedReportFormats') @restricted_report_formats.each do |format| formats.add_element('RestrictedReportFormat', { 'name' => format }) end end unless @restricted_report_sections.empty? sections = xml.add_element('RestrictedReportSections') @restricted_report_sections.each do |section| sections.add_element('RestrictedReportSection', { 'name' => section }) end end xml end
create(connection)
click to toggle source
Saves a new silo profile to a Nexpose
console.
@param [Connection] connection Connection
to console where this silo profile will be saved. @return [String] Silo
Profile ID assigned to this configuration, if successful.
# File lib/nexpose/silo_profile.rb, line 130 def create(connection) xml = connection.make_xml('SiloProfileCreateRequest') xml.add_element(as_xml) r = connection.execute(xml, '1.2') @id = r.attributes['silo-profile-id'] if r.success end
delete(connection)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 137 def delete(connection) connection.delete_silo_profile(@id) end
save(connection)
click to toggle source
# File lib/nexpose/silo_profile.rb, line 106 def save(connection) update(connection) rescue APIError => error raise error unless error.message =~ /silo profile(\S*|.*?)does not exist/i create(connection) end
to_xml()
click to toggle source
# File lib/nexpose/silo_profile.rb, line 196 def to_xml as_xml.to_s end
update(connection)
click to toggle source
Updates an existing silo profile on a Nexpose
console.
@param [Connection] connection Connection
to console where this silo profile will be saved. @return [String] Silo
Profile ID assigned to this configuration, if successful.
# File lib/nexpose/silo_profile.rb, line 118 def update(connection) xml = connection.make_xml('SiloProfileUpdateRequest') xml.add_element(as_xml) r = connection.execute(xml, '1.2') @id = r.attributes['silo-profile-id'] if r.success end