vaultez-cli 0.3.0 → 0.3.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/vaultez/client.rb +32 -1
- data/lib/vaultez/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78043da2b439dff80b3ed04f33ee62a77936276e5bd60935be94d2eca29592f0
|
|
4
|
+
data.tar.gz: aa76a4503506bd47d5e5b8a582725fbcee604bfdd0b23976e868e13bb7af2240
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1214dc2431ac95bac73be69ce5ed35a6bb1f854ebbdede1e011954bf6161e3031ef1a628f810ff531284fb228808a86f4d8a33df8bfab776c6d756d87c3dec5f
|
|
7
|
+
data.tar.gz: 1c9dcf449a65eeba1412ecae189f4d00cbae4cfe98437c7ed649a559b0868ad4f17e09090d92b6483a4d62c35154918dc738ae0695f4db8465cb251b1b62c8c9
|
data/lib/vaultez/client.rb
CHANGED
|
@@ -4,6 +4,14 @@ require "uri"
|
|
|
4
4
|
|
|
5
5
|
module Vaultez
|
|
6
6
|
class Client
|
|
7
|
+
# A legitimate response (companies/projects/secrets, all short strings)
|
|
8
|
+
# is a handful of KB at most. This bounds how much of a compromised or
|
|
9
|
+
# malicious response - a compromised API backend, a MITM'd/redirected
|
|
10
|
+
# api_url, or a compromised account crafting an oversized payload - this
|
|
11
|
+
# process will hold in memory, independent of any size limit a caller
|
|
12
|
+
# (e.g. the oma-vaultez plugin) enforces on this CLI's own stdout.
|
|
13
|
+
MAX_RESPONSE_BYTES = 4 * 1024 * 1024
|
|
14
|
+
|
|
7
15
|
def initialize
|
|
8
16
|
@api_url = Vaultez::Config.api_url
|
|
9
17
|
@token = Vaultez::Config.token
|
|
@@ -68,7 +76,9 @@ module Vaultez
|
|
|
68
76
|
req.body = body.to_json if body
|
|
69
77
|
|
|
70
78
|
begin
|
|
71
|
-
response = http
|
|
79
|
+
response = fetch_bounded(http, req)
|
|
80
|
+
rescue Vaultez::Error
|
|
81
|
+
raise
|
|
72
82
|
rescue StandardError => error
|
|
73
83
|
raise Vaultez::ApiError, "Could not reach the Vaultez API: #{error.message}"
|
|
74
84
|
end
|
|
@@ -76,6 +86,27 @@ module Vaultez
|
|
|
76
86
|
parse_response(response)
|
|
77
87
|
end
|
|
78
88
|
|
|
89
|
+
# Reads the response body incrementally instead of Net::HTTP's default
|
|
90
|
+
# #request behavior, which fully buffers the entire body in memory
|
|
91
|
+
# before returning with no size limit at all. Aborts (closing the
|
|
92
|
+
# connection) the moment the body crosses MAX_RESPONSE_BYTES, rather
|
|
93
|
+
# than finishing the download and only noticing afterward.
|
|
94
|
+
def fetch_bounded(http, req)
|
|
95
|
+
response = nil
|
|
96
|
+
body = +""
|
|
97
|
+
http.request(req) do |res|
|
|
98
|
+
response = res
|
|
99
|
+
res.read_body do |chunk|
|
|
100
|
+
body << chunk
|
|
101
|
+
if body.bytesize > MAX_RESPONSE_BYTES
|
|
102
|
+
raise Vaultez::ApiError, "Vaultez API response exceeded the maximum allowed size"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
response.body = body
|
|
107
|
+
response
|
|
108
|
+
end
|
|
109
|
+
|
|
79
110
|
def build_request(method, uri)
|
|
80
111
|
case method
|
|
81
112
|
when :get then Net::HTTP::Get.new(uri)
|
data/lib/vaultez/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vaultez-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nur Ketene
|
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '0'
|
|
60
60
|
requirements: []
|
|
61
|
-
rubygems_version:
|
|
61
|
+
rubygems_version: 4.0.16
|
|
62
62
|
specification_version: 4
|
|
63
63
|
summary: CLI tool for Vaultez — manage your secrets from the terminal
|
|
64
64
|
test_files: []
|