tenable-ruby-sdk 0.1.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/tenable/resources/asset_exports.rb +1 -1
- data/lib/tenable/resources/scans.rb +4 -4
- data/lib/tenable/resources/web_app_scans.rb +31 -20
- data/lib/tenable/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86b71cea395f4634ebeee10f3a73541f012ecb41604c19cd4f8441d64a317ece
|
|
4
|
+
data.tar.gz: 1dd6a81da536e32ebfdcbb6b908d0eeb502ac471ae2f9d7ba713f87c4d76b93b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c83641303c4468e92e859611131006158aaa963e55d3c0c08ae687911748477a0c7327f98a2394bca6e40174b1ac37a5074c07545df7be0fb1fbd0e29a9c4f2d
|
|
7
|
+
data.tar.gz: e4caa53b483ceef74f7279384d3a3da94c34350cbd92623c3365c220ff3e24b535f677d785d1b061df0060f622ff5657b223b4ef11f323dee03a2d6c4119b05e
|
|
@@ -23,7 +23,7 @@ module Tenable
|
|
|
23
23
|
# @param body [Hash] export request parameters (e.g., +chunk_size+, +filters+)
|
|
24
24
|
# @return [Hash] response containing the export UUID
|
|
25
25
|
def export(body = {})
|
|
26
|
-
post('/assets/export', body)
|
|
26
|
+
post('/assets/v2/export', body)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Retrieves the status of an asset export.
|
|
@@ -127,13 +127,13 @@ module Tenable
|
|
|
127
127
|
put("/scans/#{scan_id}/schedule", params)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
# Retrieves the scan history.
|
|
130
|
+
# Retrieves the scan history from the scan details endpoint.
|
|
131
131
|
#
|
|
132
132
|
# @param scan_id [Integer, String] the scan ID
|
|
133
|
-
# @return [Hash]
|
|
133
|
+
# @return [Array<Hash>] array of history records
|
|
134
134
|
def history(scan_id)
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
data = details(scan_id)
|
|
136
|
+
data['history'] || []
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
# Retrieves details for a specific host within a scan.
|
|
@@ -7,7 +7,7 @@ module Tenable
|
|
|
7
7
|
TERMINAL_STATUSES = %w[completed failed cancelled error].freeze
|
|
8
8
|
|
|
9
9
|
# Supported scan export formats.
|
|
10
|
-
SUPPORTED_EXPORT_FORMATS = %w[
|
|
10
|
+
SUPPORTED_EXPORT_FORMATS = %w[json csv xml html pdf].freeze
|
|
11
11
|
|
|
12
12
|
# @return [Integer] default seconds between status polls
|
|
13
13
|
DEFAULT_POLL_INTERVAL = 2
|
|
@@ -90,17 +90,17 @@ module Tenable
|
|
|
90
90
|
get("/was/v2/configs/#{config_id}/scans/#{scan_id}")
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
#
|
|
93
|
+
# Searches vulnerabilities for a specific scan.
|
|
94
94
|
#
|
|
95
|
-
# @param
|
|
96
|
-
# @param params [Hash]
|
|
97
|
-
# @return [Hash]
|
|
95
|
+
# @param scan_id [String] the scan ID
|
|
96
|
+
# @param params [Hash] search parameters
|
|
97
|
+
# @return [Hash] search results with vulnerabilities and pagination
|
|
98
98
|
#
|
|
99
99
|
# @example
|
|
100
|
-
# client.web_app_scans.
|
|
101
|
-
def
|
|
102
|
-
validate_path_segment!(
|
|
103
|
-
|
|
100
|
+
# client.web_app_scans.search_scan_vulnerabilities(scan_id, severity: "high")
|
|
101
|
+
def search_scan_vulnerabilities(scan_id, **params)
|
|
102
|
+
validate_path_segment!(scan_id, name: 'scan_id')
|
|
103
|
+
post("/was/v2/scans/#{scan_id}/vulnerabilities/search", params)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
# Polls until the scan reaches a terminal status.
|
|
@@ -135,7 +135,7 @@ module Tenable
|
|
|
135
135
|
# @return [Hash] the updated scan status
|
|
136
136
|
def stop_scan(scan_id)
|
|
137
137
|
validate_path_segment!(scan_id, name: 'scan_id')
|
|
138
|
-
patch("/was/v2/scans/#{scan_id}
|
|
138
|
+
patch("/was/v2/scans/#{scan_id}", { 'requested_action' => 'stop' })
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
# Deletes a WAS scan.
|
|
@@ -147,12 +147,14 @@ module Tenable
|
|
|
147
147
|
delete("/was/v2/scans/#{scan_id}")
|
|
148
148
|
end
|
|
149
149
|
|
|
150
|
-
# Searches
|
|
150
|
+
# Searches scans for a specific configuration.
|
|
151
151
|
#
|
|
152
|
+
# @param config_id [String] the scan configuration ID
|
|
152
153
|
# @param params [Hash] search parameters
|
|
153
154
|
# @return [Hash] search results with items and pagination
|
|
154
|
-
def search_scans(**params)
|
|
155
|
-
|
|
155
|
+
def search_scans(config_id, **params)
|
|
156
|
+
validate_path_segment!(config_id, name: 'config_id')
|
|
157
|
+
post("/was/v2/configs/#{config_id}/scans/search", params)
|
|
156
158
|
end
|
|
157
159
|
|
|
158
160
|
# Searches WAS vulnerabilities.
|
|
@@ -169,13 +171,13 @@ module Tenable
|
|
|
169
171
|
# @return [Hash] vulnerability details
|
|
170
172
|
def vulnerability_details(vuln_id)
|
|
171
173
|
validate_path_segment!(vuln_id, name: 'vuln_id')
|
|
172
|
-
get("/was/v2/
|
|
174
|
+
get("/was/v2/vulnerabilities/#{vuln_id}")
|
|
173
175
|
end
|
|
174
176
|
|
|
175
|
-
# Initiates
|
|
177
|
+
# Initiates a report export for a specific WAS scan.
|
|
176
178
|
#
|
|
177
179
|
# @param scan_id [String] the scan ID
|
|
178
|
-
# @param format [String] export format — one of "
|
|
180
|
+
# @param format [String] export format — one of "json", "csv", "xml", "html", or "pdf"
|
|
179
181
|
# @param body [Hash] additional export parameters
|
|
180
182
|
# @return [Hash] export initiation response
|
|
181
183
|
# @raise [ArgumentError] if the format is not supported
|
|
@@ -185,16 +187,25 @@ module Tenable
|
|
|
185
187
|
raise ArgumentError, "Unsupported format '#{format}'. Must be one of: #{SUPPORTED_EXPORT_FORMATS.join(', ')}"
|
|
186
188
|
end
|
|
187
189
|
|
|
188
|
-
put("/was/v2/scans/#{scan_id}/
|
|
190
|
+
put("/was/v2/scans/#{scan_id}/report", body.merge('format' => format))
|
|
189
191
|
end
|
|
190
192
|
|
|
191
|
-
#
|
|
193
|
+
# Checks the status of a WAS scan report by attempting to fetch it.
|
|
194
|
+
#
|
|
195
|
+
# The WAS report API has no separate status endpoint. A 404 response
|
|
196
|
+
# indicates the report is still being generated.
|
|
192
197
|
#
|
|
193
198
|
# @param scan_id [String] the scan ID
|
|
194
199
|
# @return [Hash] status data with +"status"+ key ("ready" or "loading")
|
|
195
200
|
def export_scan_status(scan_id)
|
|
196
201
|
validate_path_segment!(scan_id, name: 'scan_id')
|
|
197
|
-
get("/was/v2/scans/#{scan_id}/
|
|
202
|
+
response = @connection.faraday.get("/was/v2/scans/#{scan_id}/report")
|
|
203
|
+
if response.status == 404
|
|
204
|
+
{ 'status' => 'loading' }
|
|
205
|
+
else
|
|
206
|
+
raise_for_status(response)
|
|
207
|
+
{ 'status' => 'ready' }
|
|
208
|
+
end
|
|
198
209
|
end
|
|
199
210
|
|
|
200
211
|
# Downloads a completed WAS scan export as raw binary data.
|
|
@@ -203,7 +214,7 @@ module Tenable
|
|
|
203
214
|
# @return [String] raw binary content of the export
|
|
204
215
|
def download_scan_export(scan_id)
|
|
205
216
|
validate_path_segment!(scan_id, name: 'scan_id')
|
|
206
|
-
get_raw("/was/v2/scans/#{scan_id}/
|
|
217
|
+
get_raw("/was/v2/scans/#{scan_id}/report")
|
|
207
218
|
end
|
|
208
219
|
|
|
209
220
|
# Polls until a WAS scan export is ready for download.
|
data/lib/tenable/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tenable-ruby-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- vudx00
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0.9'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.0'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: rspec
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -186,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
186
200
|
- !ruby/object:Gem::Version
|
|
187
201
|
version: '0'
|
|
188
202
|
requirements: []
|
|
189
|
-
rubygems_version:
|
|
203
|
+
rubygems_version: 3.6.9
|
|
190
204
|
specification_version: 4
|
|
191
205
|
summary: Ruby SDK for the Tenable API
|
|
192
206
|
test_files: []
|