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.
1052 1053 1054 1055 1056 1057 1058 |
# File 'lib/nexpose.rb', line 1052 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)*)
1048 1049 1050 |
# File 'lib/nexpose.rb', line 1048 def alerts @alerts end |
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
1034 1035 1036 |
# File 'lib/nexpose.rb', line 1034 def connection @connection end |
#credentials ⇒ Object (readonly)
Array containing (AdminCredentials*)
1046 1047 1048 |
# File 'lib/nexpose.rb', line 1046 def credentials @credentials end |
#description ⇒ Object (readonly)
A Description of the Site
1040 1041 1042 |
# File 'lib/nexpose.rb', line 1040 def description @description end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
1026 1027 1028 |
# File 'lib/nexpose.rb', line 1026 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
1028 1029 1030 |
# File 'lib/nexpose.rb', line 1028 def error_msg @error_msg end |
#hosts ⇒ Object (readonly)
Array containing ((IPRange|HostName)*)
1044 1045 1046 |
# File 'lib/nexpose.rb', line 1044 def hosts @hosts end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
1030 1031 1032 |
# File 'lib/nexpose.rb', line 1030 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
1032 1033 1034 |
# File 'lib/nexpose.rb', line 1032 def response_xml @response_xml end |
#riskfactor ⇒ Object (readonly)
User assigned risk multiplier
1042 1043 1044 |
# File 'lib/nexpose.rb', line 1042 def riskfactor @riskfactor end |
#scanConfig ⇒ Object (readonly)
ScanConfig object which holds Schedule and ScanTrigger Objects
1050 1051 1052 |
# File 'lib/nexpose.rb', line 1050 def scanConfig @scanConfig end |
#site_id ⇒ Object (readonly)
The Site ID
1036 1037 1038 |
# File 'lib/nexpose.rb', line 1036 def site_id @site_id end |
#site_name ⇒ Object (readonly)
The Site Name
1038 1039 1040 |
# File 'lib/nexpose.rb', line 1038 def site_name @site_name end |
Instance Method Details
#_set_connection(connection) ⇒ Object
1104 1105 1106 |
# File 'lib/nexpose.rb', line 1104 def _set_connection(connection) @connection = connection end |
#_set_description(description) ⇒ Object
1092 1093 1094 |
# File 'lib/nexpose.rb', line 1092 def _set_description(description) @description = description end |
#_set_riskfactor(riskfactor) ⇒ Object
1096 1097 1098 |
# File 'lib/nexpose.rb', line 1096 def _set_riskfactor(riskfactor) @riskfactor = riskfactor end |
#_set_scanConfig(scanConfig) ⇒ Object
1100 1101 1102 |
# File 'lib/nexpose.rb', line 1100 def _set_scanConfig(scanConfig) @scanConfig = scanConfig end |
#_set_site_id(site_id) ⇒ Object
1084 1085 1086 |
# File 'lib/nexpose.rb', line 1084 def _set_site_id(site_id) @site_id = site_id end |
#_set_site_name(site_name) ⇒ Object
1088 1089 1090 |
# File 'lib/nexpose.rb', line 1088 def _set_site_name(site_name) @site_name = site_name end |
#addAlert(alert) ⇒ Object
Adds a new alert to the alerts array
1066 1067 1068 |
# File 'lib/nexpose.rb', line 1066 def addAlert(alert) @alerts.push(alert) end |
#addCredentials(credential) ⇒ Object
Adds a new set of credentials to the credentials array
1071 1072 1073 |
# File 'lib/nexpose.rb', line 1071 def addCredentials(credential) @credentials.push(credential) end |
#addHost(host) ⇒ Object
Adds a new host to the hosts array
1061 1062 1063 |
# File 'lib/nexpose.rb', line 1061 def addHost(host) @hosts.push(host) end |
#getSiteConfig(connection, site_id) ⇒ Object
TODO
1076 1077 1078 1079 1080 1081 1082 |
# File 'lib/nexpose.rb', line 1076 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>
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 |
# File 'lib/nexpose.rb', line 1127 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 |