scanii-ruby 1.3.1 → 1.4.0
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/CHANGELOG.md +26 -0
- data/README.md +8 -2
- data/lib/scanii/client.rb +39 -7
- data/lib/scanii/trace_result.rb +0 -3
- data/lib/scanii/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b7caeccb8435e1085c555d60e2c0000ed7c57713fce50087be9d4fa33f6e4d1
|
|
4
|
+
data.tar.gz: e37e050290e8d7e38605861b317040cde9819eda9088e6b0289e836372053e64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae9ced99eb6909f3fa06840a519d953ff77ca729b84ee4a35273dd7bdaaf406c2853b09ba68111a395705bb9a8f7ccd16893eb17b3c86d2844cfc6afddbb8cb1
|
|
7
|
+
data.tar.gz: 8117f19a3d7e78d1451b01ca9a0e12bf1d2716b43fb664362a6edce5323022aec3742a1ae24f59f99cc824c74dff8476c58513936a44b3658a6b6b98c3b460ee
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `scanii-ruby` are documented here. Versions follow [SemVer](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [1.4.0] — split result and trace deletion
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `Scanii::Client#delete(id)` — deletes a previously processed file result
|
|
10
|
+
(`DELETE /files/{id}`). Returns `true` on 204; the processing trace is left intact.
|
|
11
|
+
- `Scanii::Client#delete_trace(id)` — deletes the processing trace separately
|
|
12
|
+
(`DELETE /files/{id}/trace`). Returns `true` on 204; the processing result is left intact.
|
|
13
|
+
|
|
14
|
+
The two resources are independent: deleting one does not remove the other.
|
|
15
|
+
To erase a scan entirely, call both.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Dropped the "v2.2 preview" designation from `retrieve_trace` and `process_from_url`
|
|
20
|
+
in the README and RDoc. Neither is marked preview in the API contract; the methods
|
|
21
|
+
themselves are unchanged.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Path segments are now encoded with `URI.encode_uri_component` rather than
|
|
26
|
+
`URI.encode_www_form_component`, which rendered a space as `+`. Inside a path a
|
|
27
|
+
`+` is a literal plus, so an id containing a space reached the server corrupted.
|
|
28
|
+
Affects every id-taking method. Scanii-issued ids are hex, so this was not
|
|
29
|
+
reachable in practice with server-generated ids.
|
|
30
|
+
|
|
5
31
|
## [1.3.1] — dependency refresh
|
|
6
32
|
|
|
7
33
|
### Changed
|
data/README.md
CHANGED
|
@@ -60,15 +60,21 @@ puts "findings: #{result.findings.inspect}"
|
|
|
60
60
|
| `process_file(path, metadata:, callback:)` | `POST /files` | `Scanii::ProcessingResult` |
|
|
61
61
|
| `process_async(io, filename:, content_type:, metadata:, callback:)` | `POST /files/async` | `Scanii::PendingResult` |
|
|
62
62
|
| `process_async_file(path, metadata:, callback:)` | `POST /files/async` | `Scanii::PendingResult` |
|
|
63
|
-
| `process_from_url(location, callback:, metadata:)` | `POST /files` | `Scanii::ProcessingResult`
|
|
63
|
+
| `process_from_url(location, callback:, metadata:)` | `POST /files` | `Scanii::ProcessingResult` |
|
|
64
64
|
| `fetch(url, metadata:, callback:)` | `POST /files/fetch` | `Scanii::PendingResult` |
|
|
65
65
|
| `retrieve(id)` | `GET /files/{id}` | `Scanii::ProcessingResult` |
|
|
66
|
-
| `retrieve_trace(id)` | `GET /files/{id}/trace` | `Scanii::TraceResult` or `nil`
|
|
66
|
+
| `retrieve_trace(id)` | `GET /files/{id}/trace` | `Scanii::TraceResult` or `nil` |
|
|
67
|
+
| `delete(id)` | `DELETE /files/{id}` | `true` |
|
|
68
|
+
| `delete_trace(id)` | `DELETE /files/{id}/trace` | `true` |
|
|
67
69
|
| `ping` | `GET /ping` | `true` |
|
|
68
70
|
| `create_auth_token(timeout_seconds)` | `POST /auth/tokens` | `Scanii::AuthToken` |
|
|
69
71
|
| `retrieve_auth_token(id)` | `GET /auth/tokens/{id}` | `Scanii::AuthToken` |
|
|
70
72
|
| `delete_auth_token(id)` | `DELETE /auth/tokens/{id}` | `true` |
|
|
71
73
|
|
|
74
|
+
`delete` and `delete_trace` act on independent resources: deleting a scan result
|
|
75
|
+
leaves its trace readable, and deleting a trace leaves the result readable. To erase
|
|
76
|
+
a scan entirely, call both.
|
|
77
|
+
|
|
72
78
|
Full API reference: <https://scanii.github.io/openapi/v22/>.
|
|
73
79
|
|
|
74
80
|
## Regional endpoints
|
data/lib/scanii/client.rb
CHANGED
|
@@ -202,9 +202,6 @@ module Scanii
|
|
|
202
202
|
#
|
|
203
203
|
# Returns nil when no trace exists for the given id (HTTP 404).
|
|
204
204
|
#
|
|
205
|
-
# This is a v2.2 preview surface; the API shape may shift before it is
|
|
206
|
-
# marked stable.
|
|
207
|
-
#
|
|
208
205
|
# @param id [String] processing id returned by process or process_file
|
|
209
206
|
# @see https://scanii.github.io/openapi/v22/ GET /files/{id}/trace
|
|
210
207
|
# @return [Scanii::TraceResult, nil]
|
|
@@ -218,6 +215,41 @@ module Scanii
|
|
|
218
215
|
TraceResult.from_response(resp_body, headers)
|
|
219
216
|
end
|
|
220
217
|
|
|
218
|
+
# Delete a previously processed file result.
|
|
219
|
+
#
|
|
220
|
+
# The processing trace is a separate resource and is *not* removed by this
|
|
221
|
+
# call — it stays readable via {#retrieve_trace} until you delete it with
|
|
222
|
+
# {#delete_trace}. To erase a scan entirely, call both.
|
|
223
|
+
#
|
|
224
|
+
# @param id [String] processing id returned by {#process} or {#process_file}
|
|
225
|
+
# @see https://scanii.github.io/openapi/v22/ DELETE /files/{id}
|
|
226
|
+
# @return [Boolean] true on 204
|
|
227
|
+
# @raise [Scanii::Error] when no result exists for the id (HTTP 404), which is
|
|
228
|
+
# also what a repeated delete of the same id returns
|
|
229
|
+
def delete(id)
|
|
230
|
+
raise ArgumentError, "id must not be empty" if id.nil? || id.empty?
|
|
231
|
+
|
|
232
|
+
status, resp_body, headers = request("DELETE", "/files/#{url_encode(id)}")
|
|
233
|
+
raise_for_status(status, resp_body, headers) unless status == 204
|
|
234
|
+
true
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Delete the processing trace for a previously processed file, leaving the
|
|
238
|
+
# processing result itself untouched.
|
|
239
|
+
#
|
|
240
|
+
# @param id [String] processing id returned by {#process} or {#process_file}
|
|
241
|
+
# @see https://scanii.github.io/openapi/v22/ DELETE /files/{id}/trace
|
|
242
|
+
# @return [Boolean] true on 204
|
|
243
|
+
# @raise [Scanii::Error] when no trace exists for the id (HTTP 404), which is
|
|
244
|
+
# also what a repeated delete of the same id returns
|
|
245
|
+
def delete_trace(id)
|
|
246
|
+
raise ArgumentError, "id must not be empty" if id.nil? || id.empty?
|
|
247
|
+
|
|
248
|
+
status, resp_body, headers = request("DELETE", "/files/#{url_encode(id)}/trace")
|
|
249
|
+
raise_for_status(status, resp_body, headers) unless status == 204
|
|
250
|
+
true
|
|
251
|
+
end
|
|
252
|
+
|
|
221
253
|
# Submit a remote URL for synchronous scanning.
|
|
222
254
|
#
|
|
223
255
|
# Sends the URL as a +location+ field in a multipart/form-data POST to
|
|
@@ -228,9 +260,6 @@ module Scanii
|
|
|
228
260
|
# +location+ must be a String URL. This matches the existing {#fetch}
|
|
229
261
|
# String-URL convention and the Java reference (processFromUrl(String)).
|
|
230
262
|
#
|
|
231
|
-
# This is a v2.2 preview surface; the API shape may shift before it is
|
|
232
|
-
# marked stable.
|
|
233
|
-
#
|
|
234
263
|
# @param location [String] URL of the content to scan
|
|
235
264
|
# @param callback [String, nil] URL to POST the result to on completion
|
|
236
265
|
# @param metadata [Hash{String=>String}, nil] arbitrary key/value pairs attached to the result
|
|
@@ -431,8 +460,11 @@ module Scanii
|
|
|
431
460
|
body
|
|
432
461
|
end
|
|
433
462
|
|
|
463
|
+
# Path-segment encoding. NOT encode_www_form_component, which renders a
|
|
464
|
+
# space as "+" — correct for form bodies, wrong inside a path, where "+"
|
|
465
|
+
# is a literal plus and the id would arrive corrupted.
|
|
434
466
|
def url_encode(value)
|
|
435
|
-
URI.
|
|
467
|
+
URI.encode_uri_component(value)
|
|
436
468
|
end
|
|
437
469
|
end
|
|
438
470
|
end
|
data/lib/scanii/trace_result.rb
CHANGED
|
@@ -3,9 +3,6 @@ require "json"
|
|
|
3
3
|
module Scanii
|
|
4
4
|
# Result of Client#retrieve_trace — ordered processing events for a scan.
|
|
5
5
|
#
|
|
6
|
-
# This is a v2.2 preview surface; the API shape may shift before it is
|
|
7
|
-
# marked stable.
|
|
8
|
-
#
|
|
9
6
|
# @see https://scanii.github.io/openapi/v22/
|
|
10
7
|
class TraceResult
|
|
11
8
|
attr_reader :id, :events, :request_id, :host_id, :raw_response
|
data/lib/scanii/version.rb
CHANGED