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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59f507c7bf915ef7e7c7d2bb7a4714bacba9639e
4
- data.tar.gz: e0c1df7cefc3083f1852fcbeeb6ea9643ff10c86
3
+ metadata.gz: f8bdfc4771a54a9e57d70af10ebbc33d7b76b7a7
4
+ data.tar.gz: cc5563d354f76e62d8f182c1bc1d57ba5c956c0b
5
5
  SHA512:
6
- metadata.gz: d78554e6f8cb3877a73acf828d75c5a29fbb8ab29b00112e13217efeb38954a4962593371a4d2409599790afb01805f60783b0bf6e16319e1ef08f54f2e8c92a
7
- data.tar.gz: a420427719020ba274f21c5a3d196aa2f23013e442bc794b04dfccc50719fbb114731c55f1384c56d5e240523203bf82a03f2a9ac4afacf9e58823f6a54f3a16
6
+ metadata.gz: 91267521c05618d871b0378c255f7c541ad6678aeb1f167198306911dac8fbd94b5abcad59bc7d40c41ab927d6e8cec56df238a512ecb37a8ae0e36f0f4110b5
7
+ data.tar.gz: b7b749ac3140ec5ff63a8454fbc2140d8579bdccbb11c2c1f13fe2d1e4d63f5019138f21342297127fe714422dd094c26694b2b04212b8d458aee48004d79b04
@@ -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.checkpoint.hashicorp.com",
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, uri.port)
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
@@ -1,3 +1,3 @@
1
1
  module Checkpoint
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -9,6 +9,7 @@ describe Checkpoint do
9
9
  described_class.check(
10
10
  product: "test",
11
11
  version: "1.0",
12
+ raise_error: true,
12
13
  )
13
14
  end
14
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashicorp-checkpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto