nexpose 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/nexpose/api_request.rb +14 -9
- data/lib/nexpose/report.rb +10 -5
- metadata +2 -2
data/lib/nexpose/api_request.rb
CHANGED
@@ -55,7 +55,7 @@ module Nexpose
|
|
55
55
|
@raw_response_data = @raw_response.read_body
|
56
56
|
@res = parse_xml(@raw_response_data)
|
57
57
|
|
58
|
-
|
58
|
+
unless @res.root
|
59
59
|
@error = 'Nexpose service returned invalid XML.'
|
60
60
|
return @sid
|
61
61
|
end
|
@@ -68,12 +68,19 @@ module Nexpose
|
|
68
68
|
@success = true
|
69
69
|
else
|
70
70
|
@success = false
|
71
|
-
@
|
72
|
-
|
73
|
-
@error =
|
71
|
+
if @api_version =~ /1.2/
|
72
|
+
@res.elements.each('//Exception/Message') do |message|
|
73
|
+
@error = message.text.sub(/.*Exception: */, '')
|
74
74
|
end
|
75
|
-
|
76
|
-
@trace =
|
75
|
+
@res.elements.each('//Exception/Stacktrace') do |stacktrace|
|
76
|
+
@trace = stacktrace.text
|
77
|
+
end
|
78
|
+
else
|
79
|
+
@res.elements.each('//message') do |message|
|
80
|
+
@error = message.text.sub(/.*Exception: */, '')
|
81
|
+
end
|
82
|
+
@res.elements.each('//stacktrace') do |stacktrace|
|
83
|
+
@trace = stacktrace.text
|
77
84
|
end
|
78
85
|
end
|
79
86
|
end
|
@@ -123,9 +130,7 @@ module Nexpose
|
|
123
130
|
def self.execute(url, req, api_version='1.1')
|
124
131
|
obj = self.new(req, url, api_version)
|
125
132
|
obj.execute
|
126
|
-
|
127
|
-
raise APIError.new(obj, "Action failed: #{obj.error}")
|
128
|
-
end
|
133
|
+
raise APIError.new(obj, "Action failed: #{obj.error}") unless obj.success
|
129
134
|
obj
|
130
135
|
end
|
131
136
|
|
data/lib/nexpose/report.rb
CHANGED
@@ -179,6 +179,8 @@ module Nexpose
|
|
179
179
|
attr_accessor :template_id
|
180
180
|
# Format. One of: pdf|html|rtf|xml|text|csv|db|raw-xml|raw-xml-v2|ns-xml|qualys-xml
|
181
181
|
attr_accessor :format
|
182
|
+
attr_accessor :owner
|
183
|
+
attr_accessor :time_zone
|
182
184
|
|
183
185
|
# Array of filters associated with this report.
|
184
186
|
attr_accessor :filters
|
@@ -190,9 +192,11 @@ module Nexpose
|
|
190
192
|
# particular date.
|
191
193
|
attr_accessor :baseline
|
192
194
|
|
193
|
-
def initialize(template_id, format, site_id = nil)
|
195
|
+
def initialize(template_id, format, site_id = nil, owner = nil, time_zone = nil)
|
194
196
|
@template_id = template_id
|
195
197
|
@format = format
|
198
|
+
@owner = owner
|
199
|
+
@time_zone = time_zone
|
196
200
|
|
197
201
|
@filters = []
|
198
202
|
@filters << Filter.new('site', site_id) if site_id
|
@@ -204,13 +208,16 @@ module Nexpose
|
|
204
208
|
end
|
205
209
|
|
206
210
|
def to_xml
|
207
|
-
xml = %Q
|
211
|
+
xml = %Q(<AdhocReportConfig format='#{@format}' template-id='#{@template_id}')
|
212
|
+
xml << %Q( owner='#{@owner}') if @owner
|
213
|
+
xml << %Q( timezone='#{@time_zone}') if @time_zone
|
214
|
+
xml << '>'
|
208
215
|
|
209
216
|
xml << '<Filters>'
|
210
217
|
@filters.each { |filter| xml << filter.to_xml }
|
211
218
|
xml << '</Filters>'
|
212
219
|
|
213
|
-
xml << %Q
|
220
|
+
xml << %Q(<Baseline compareTo='#{@baseline}' />) if @baseline
|
214
221
|
|
215
222
|
xml << '</AdhocReportConfig>'
|
216
223
|
end
|
@@ -257,8 +264,6 @@ module Nexpose
|
|
257
264
|
attr_accessor :id
|
258
265
|
# The unique name assigned to the report definition.
|
259
266
|
attr_accessor :name
|
260
|
-
attr_accessor :owner
|
261
|
-
attr_accessor :time_zone
|
262
267
|
|
263
268
|
# Description associated with this report.
|
264
269
|
attr_accessor :description
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexpose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: librex
|