Class: Nexpose::SiteConfig
- Inherits:
-
Object
- Object
- Nexpose::SiteConfig
- Defined in:
- lib/nexpose.rb
Overview
Description
Object that represents the configuration of a Site. This object is automatically created when a new Site object is instantiated.
Instance Attribute Summary collapse
-
#alerts ⇒ Object
readonly
Array containing ((SmtpAlera|SnmpAlert|SyslogAlert)*).
-
#connection ⇒ Object
readonly
The NSC Connection associated with this object.
-
#credentials ⇒ Object
readonly
Array containing (AdminCredentials*).
-
#description ⇒ Object
readonly
A Description of the Site.
-
#error ⇒ Object
readonly
true if an error condition exists; false otherwise.
-
#error_msg ⇒ Object
readonly
Error message string.
-
#hosts ⇒ Object
readonly
Array containing ((IPRange|HostName)*).
-
#request_xml ⇒ Object
readonly
The last XML request sent by this object.
-
#response_xml ⇒ Object
readonly
The last XML response received by this object.
-
#riskfactor ⇒ Object
readonly
User assigned risk multiplier.
-
#scanConfig ⇒ Object
readonly
ScanConfig object which holds Schedule and ScanTrigger Objects.
-
#site_id ⇒ Object
readonly
The Site ID.
-
#site_name ⇒ Object
readonly
The Site Name.
Instance Method Summary collapse
- #_set_connection(connection) ⇒ Object
- #_set_description(description) ⇒ Object
- #_set_riskfactor(riskfactor) ⇒ Object
- #_set_scanConfig(scanConfig) ⇒ Object
- #_set_site_id(site_id) ⇒ Object
- #_set_site_name(site_name) ⇒ Object
-
#addAlert(alert) ⇒ Object
Adds a new alert to the alerts array.
-
#addCredentials(credential) ⇒ Object
Adds a new set of credentials to the credentials array.
-
#addHost(host) ⇒ Object
Adds a new host to the hosts array.
-
#getSiteConfig(connection, site_id) ⇒ Object
TODO.
-
#initialize ⇒ SiteConfig
constructor
A new instance of SiteConfig.
-
#parse(response) ⇒ Object
<SiteConfigResponse success=‘1’> <Site name=‘Site1’ id=‘243’ description=” riskfactor=‘1.0’> <Hosts> <range from=‘127.0.0.1’/> </Hosts> <Credentials> </Credentials> <Alerting> </Alerting> <ScanConfig configID=‘243’ name=‘Full audit’ configVersion=‘3’ engineID=‘2’ templateID=‘full-audit’> <Schedules> </Schedules> <ScanTriggers> </ScanTriggers> </ScanConfig> </Site>.
Constructor Details
#initialize ⇒ SiteConfig
Returns a new instance of SiteConfig.
704 705 706 707 708 709 710 |
# File 'lib/nexpose.rb', line 704 def initialize() @xml_tag_stack = Array.new() @hosts = Array.new() @credentials = Array.new() @alerts = Array.new() @error = false end |
Instance Attribute Details
#alerts ⇒ Object (readonly)
Array containing ((SmtpAlera|SnmpAlert|SyslogAlert)*)
700 701 702 |
# File 'lib/nexpose.rb', line 700 def alerts @alerts end |
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
686 687 688 |
# File 'lib/nexpose.rb', line 686 def connection @connection end |
#credentials ⇒ Object (readonly)
Array containing (AdminCredentials*)
698 699 700 |
# File 'lib/nexpose.rb', line 698 def credentials @credentials end |
#description ⇒ Object (readonly)
A Description of the Site
692 693 694 |
# File 'lib/nexpose.rb', line 692 def description @description end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
678 679 680 |
# File 'lib/nexpose.rb', line 678 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
680 681 682 |
# File 'lib/nexpose.rb', line 680 def error_msg @error_msg end |
#hosts ⇒ Object (readonly)
Array containing ((IPRange|HostName)*)
696 697 698 |
# File 'lib/nexpose.rb', line 696 def hosts @hosts end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
682 683 684 |
# File 'lib/nexpose.rb', line 682 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
684 685 686 |
# File 'lib/nexpose.rb', line 684 def response_xml @response_xml end |
#riskfactor ⇒ Object (readonly)
User assigned risk multiplier
694 695 696 |
# File 'lib/nexpose.rb', line 694 def riskfactor @riskfactor end |
#scanConfig ⇒ Object (readonly)
ScanConfig object which holds Schedule and ScanTrigger Objects
702 703 704 |
# File 'lib/nexpose.rb', line 702 def scanConfig @scanConfig end |
#site_id ⇒ Object (readonly)
The Site ID
688 689 690 |
# File 'lib/nexpose.rb', line 688 def site_id @site_id end |
#site_name ⇒ Object (readonly)
The Site Name
690 691 692 |
# File 'lib/nexpose.rb', line 690 def site_name @site_name end |
Instance Method Details
#_set_connection(connection) ⇒ Object
756 757 758 |
# File 'lib/nexpose.rb', line 756 def _set_connection(connection) @connection = connection end |
#_set_description(description) ⇒ Object
744 745 746 |
# File 'lib/nexpose.rb', line 744 def _set_description(description) @description = description end |
#_set_riskfactor(riskfactor) ⇒ Object
748 749 750 |
# File 'lib/nexpose.rb', line 748 def _set_riskfactor(riskfactor) @riskfactor = riskfactor end |
#_set_scanConfig(scanConfig) ⇒ Object
752 753 754 |
# File 'lib/nexpose.rb', line 752 def _set_scanConfig(scanConfig) @scanConfig = scanConfig end |
#_set_site_id(site_id) ⇒ Object
736 737 738 |
# File 'lib/nexpose.rb', line 736 def _set_site_id(site_id) @site_id = site_id end |
#_set_site_name(site_name) ⇒ Object
740 741 742 |
# File 'lib/nexpose.rb', line 740 def _set_site_name(site_name) @site_name = site_name end |
#addAlert(alert) ⇒ Object
Adds a new alert to the alerts array
718 719 720 |
# File 'lib/nexpose.rb', line 718 def addAlert(alert) @alerts.push(alert) end |
#addCredentials(credential) ⇒ Object
Adds a new set of credentials to the credentials array
723 724 725 |
# File 'lib/nexpose.rb', line 723 def addCredentials(credential) @credentials.push(credential) end |
#addHost(host) ⇒ Object
Adds a new host to the hosts array
713 714 715 |
# File 'lib/nexpose.rb', line 713 def addHost(host) @hosts.push(host) end |
#getSiteConfig(connection, site_id) ⇒ Object
TODO
728 729 730 731 732 733 734 |
# File 'lib/nexpose.rb', line 728 def getSiteConfig(connection,site_id) @connection = connection @site_id = site_id r = APIRequest.execute(@connection.url,'<SiteConfigRequest session-id="' + @connection.session_id + '" site-id="' + @site_id + '"/>') parse(r.res) end |
#parse(response) ⇒ Object
<SiteConfigResponse success=‘1’> <Site name=‘Site1’ id=‘243’ description=” riskfactor=‘1.0’> <Hosts> <range from=‘127.0.0.1’/> </Hosts> <Credentials> </Credentials> <Alerting> </Alerting> <ScanConfig configID=‘243’ name=‘Full audit’ configVersion=‘3’ engineID=‘2’ templateID=‘full-audit’> <Schedules> </Schedules> <ScanTriggers> </ScanTriggers> </ScanConfig> </Site>
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 |
# File 'lib/nexpose.rb', line 779 def parse(response) response.elements.each('SiteConfigResponse/Site') do |s| @site_id = s.attributes['id'] @site_name = s.attributes['name'] @description = s.attributes['description'] @riskfactor = s.attributes['riskfactor'] s.elements.each('Hosts/range') do |r| @hosts.push(IPRange.new(r.attributes['from'],r.attributes['to'])) end s.elements.each('ScanConfig') do |c| @scanConfig = ScanConfig.new(c.attributes['configID'], c.attributes['name'], c.attributes['configVersion'], c.attributes['templateID']) s.elements.each('Schedule') do |schedule| schedule = new Schedule(schedule.attributes["type"], schedule.attributes["interval"], schedule.attributes["start"], schedule.attributes["enabled"]) @scanConfig.addSchedule(schedule) end end s.elements.each('Alerting/Alert') do |a| a.elements.each('smtpAlert') do |smtp| smtp_alert = SmtpAlert.new(a.attributes["name"], smtp.attributes["sender"], smtp.attributes["limitText"], a.attributes["enabled"]) smtp.elements.each('recipient') do |recipient| smtp_alert.addRecipient(recipient.text) end @alerts.push(smtp_alert) end a.elements.each('snmpAlert') do |snmp| snmp_alert = SnmpAlert.new(a.attributes["name"], snmp.attributes["community"], snmp.attributes["server"], a.attributes["enabled"]) @alerts.push(snmp_alert) end a.elements.each('syslogAlert') do |syslog| syslog_alert = SyslogAlert.new(a.attributes["name"], syslog.attributes["server"], a.attributes["enabled"]) @alerts.push(syslog_alert) end a.elements.each('vulnFilter') do |vulnFilter| #vulnfilter = new VulnFilter.new(a.attributes["typemask"], a.attributes["severityThreshold"], $attrs["MAXALERTS"]) # Pop off the top alert on the stack #$alert = @alerts.pop() # Add the new recipient string to the Alert Object #$alert.setVulnFilter($vulnfilter) # Push the alert back on to the alert stack #array_push($this->alerts, $alert) end a.elements.each('scanFilter') do |scanFilter| #<scanFilter scanStop='0' scanFailed='0' scanStart='1'/> #scanfilter = ScanFilter.new(scanFilter.attributes['scanStop'],scanFilter.attributes['scanFailed'],scanFilter.attributes['scanStart']) #alert = @alerts.pop() #alert.setScanFilter(scanfilter) #@alerts.push(alert) end end end end |