hashicorp-checkpoint 0.1.3 → 0.1.4
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/checkpoint.rb +14 -4
- data/lib/checkpoint/version.rb +1 -1
- data/spec/checkpoint_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8bdfc4771a54a9e57d70af10ebbc33d7b76b7a7
|
4
|
+
data.tar.gz: cc5563d354f76e62d8f182c1bc1d57ba5c956c0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91267521c05618d871b0378c255f7c541ad6678aeb1f167198306911dac8fbd94b5abcad59bc7d40c41ab927d6e8cec56df238a512ecb37a8ae0e36f0f4110b5
|
7
|
+
data.tar.gz: b7b749ac3140ec5ff63a8454fbc2140d8579bdccbb11c2c1f13fe2d1e4d63f5019138f21342297127fe714422dd094c26694b2b04212b8d458aee48004d79b04
|
data/lib/checkpoint.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "cgi"
|
2
2
|
require "json"
|
3
3
|
require "net/http"
|
4
|
+
require "net/https"
|
4
5
|
require "securerandom"
|
5
6
|
require "uri/http"
|
6
7
|
|
@@ -55,11 +56,15 @@ module Checkpoint
|
|
55
56
|
if opts[:signature_file]
|
56
57
|
if !File.file?(opts[:signature_file])
|
57
58
|
File.open(opts[:signature_file], "w+") do |f|
|
58
|
-
f.write(SecureRandom.uuid.to_s + "\n")
|
59
|
+
f.write(SecureRandom.uuid.to_s + "\n\n")
|
60
|
+
f.write("This signature is a randomly generated UUID used to de-duplicate\n")
|
61
|
+
f.write("alerts and version information. This signature is random, it is\n")
|
62
|
+
f.write("not based on any personally identifiable information. To create\n")
|
63
|
+
f.write("a new signature, you can simply delete this file at any time.\n")
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
|
-
query[:signature] = File.read(opts[:signature_file]).chomp
|
67
|
+
query[:signature] = File.read(opts[:signature_file]).lines.first.chomp
|
63
68
|
end
|
64
69
|
|
65
70
|
# Turn the raw query parameters into a proper query string
|
@@ -71,7 +76,7 @@ module Checkpoint
|
|
71
76
|
|
72
77
|
# Build the URL
|
73
78
|
uri = URI::HTTP.build(
|
74
|
-
host: "api.
|
79
|
+
host: "checkpoint-api.hashicorp.com",
|
75
80
|
path: "/v1/check/#{opts[:product]}",
|
76
81
|
query: query,
|
77
82
|
)
|
@@ -80,7 +85,9 @@ module Checkpoint
|
|
80
85
|
"Accept" => "application/json",
|
81
86
|
"User-Agent" => "HashiCorp/ruby-checkpoint #{VERSION}",
|
82
87
|
}
|
83
|
-
http = Net::HTTP.new(uri.host,
|
88
|
+
http = Net::HTTP.new(uri.host, 443)
|
89
|
+
http.use_ssl = true
|
90
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
84
91
|
resp = http.get("#{uri.path}?#{uri.query}", headers)
|
85
92
|
if !resp.is_a?(Net::HTTPSuccess)
|
86
93
|
return nil
|
@@ -95,6 +102,9 @@ module Checkpoint
|
|
95
102
|
|
96
103
|
build_check(resp.body)
|
97
104
|
rescue Exception
|
105
|
+
# If we want errors, raise it
|
106
|
+
raise if opts[:raise_error]
|
107
|
+
|
98
108
|
# We don't want check to fail for any reason, so just return nil
|
99
109
|
return nil
|
100
110
|
end
|
data/lib/checkpoint/version.rb
CHANGED
data/spec/checkpoint_spec.rb
CHANGED