bitget.rb 0.9.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bd1994cc4ea95cfc2714a150370fc1e57e980d4863a4469d86ad8d47730dacb
4
- data.tar.gz: 750189227ba39d64b44150b52bd10ca04828b6e80c18a4165a4626a484e276e7
3
+ metadata.gz: 1c22bb60a209681136a580eecdf81cf0298cf3c78f51b99588a49b6b13c3c6db
4
+ data.tar.gz: '09f25185c72ad7fadf3ffb1bf1264650e0cdf2fd297423e3128b7ddeb5f696da'
5
5
  SHA512:
6
- metadata.gz: d50ee7d4f450ec7eeaa1f58ac8b8c731ad1a9d57d9f1d39ceffb8a5fa8bafc30624bdb6fc66d51d26271b0e82235af1535b24de03e88a26553139ef40ffa9485
7
- data.tar.gz: ab32e33cade60ba97923a72d18c4fb669a8c76a1b061a5fcde7d07300351882b5ea0464ff656dd1e71c72765ef3edcfba6ded4f644bf8b02d1245f997f34aa06
6
+ metadata.gz: e36b1a7ff42846eb1a95f2b4eae6d9ede1b2955a62724e48781e25145cb1079508e6c95e110c41507d6522fc71327089625f4d7496af1866474cdc9c06263f50
7
+ data.tar.gz: b7bea187cba271df689255f4b46411f49808a9aad28b8c40468c3190415b1bd7ced84e3d82586a335fbdcf6eafd0b69436f340c615720f56ededa5236784db3d
data/CHANGELOG CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## 20261115
4
4
 
5
+ 0.9.1: Fix the request log exposing the credentials.
6
+
7
+ 1. + Bitget::V2::Client::CREDENTIAL_HEADERS: ACCESS-KEY and ACCESS-PASSPHRASE.
8
+ 2. + Bitget::V2::Client#masked: The credential headers' values are replaced with [FILTERED].
9
+ 3. ~ Bitget::V2::Client#log_request: The headers are logged through #masked. The key and passphrase were written to the log as sent.
10
+ 4. ~ test/V2/Client_test.rb: The logged key and passphrase are masked, and the signature is not.
11
+ 5. ~ README.md: The Logging section says the credential headers are masked.
12
+ 6. ~ Bitget::VERSION: /0.9.0/0.9.1/
13
+
5
14
  0.9.0: ~ Bitget::Client#initialize: - options:; - Bitget.configure, Bitget::Configuration.
6
15
 
7
16
  1. ~ Bitget::V2::Client#initialize: + debug:, + logger:, - options:. Nothing falls back upon Bitget.configuration, under which a client worked or failed according to what had run before it.
data/README.md CHANGED
@@ -70,6 +70,9 @@ fell back upon them, the rest going under `options:`. Pass them to each client i
70
70
  A client logs when it has somewhere to log to, and not at all when it does not. Hand it any
71
71
  object answering to `#info` and `#error`; the standard library's `Logger` will do.
72
72
 
73
+ A request is logged with its headers, the key and the passphrase being written as
74
+ `[FILTERED]`.
75
+
73
76
  ```ruby
74
77
  require 'logger'
75
78
 
@@ -15,6 +15,7 @@ module Bitget
15
15
  class Client
16
16
 
17
17
  API_HOST = 'api.bitget.com'
18
+ CREDENTIAL_HEADERS = %w{ACCESS-KEY ACCESS-PASSPHRASE}
18
19
 
19
20
  class << self
20
21
 
@@ -1894,10 +1895,14 @@ module Bitget
1894
1895
  if log_args?(args)
1895
1896
  log_string << " Args: #{args}\n"
1896
1897
  end
1897
- log_string << " Headers: #{headers}\n"
1898
+ log_string << " Headers: #{masked(headers)}\n"
1898
1899
  logger.info(log_string)
1899
1900
  end
1900
1901
 
1902
+ def masked(headers)
1903
+ headers.to_h{|name, value| [name, CREDENTIAL_HEADERS.include?(name) ? '[FILTERED]' : value]}
1904
+ end
1905
+
1901
1906
  def log_response(code:, message:, body:)
1902
1907
  log_string = "Code: #{code}\n"
1903
1908
  log_string << "Message: #{message}\n"
@@ -2,5 +2,5 @@
2
2
  # Bitget::VERSION
3
3
 
4
4
  module Bitget
5
- VERSION = '0.9.0'
5
+ VERSION = '0.9.1'
6
6
  end
@@ -1167,6 +1167,18 @@ describe Bitget::V2::Client do
1167
1167
  _(log.string).must_match(/Args: \{coin: "BTC"}/)
1168
1168
  _(log.string).must_match(/Headers: .+"Content-Type" => "application\/json"/)
1169
1169
  end
1170
+
1171
+ it "masks the credentials and not the signature" do
1172
+ VCR.use_cassette("v2/spot/public/coins-when_coin_is_supplied") do
1173
+ client.spot_public_coins(coin: "BTC")
1174
+ end
1175
+ %w{ACCESS-KEY ACCESS-PASSPHRASE}.each do |name|
1176
+ _(log.string).must_include(%{"#{name}" => "[FILTERED]"})
1177
+ end
1178
+ _(log.string).wont_include(api_key)
1179
+ _(log.string).wont_include(api_passphrase)
1180
+ _(log.string).must_match(/"ACCESS-SIGN" => "[^\[]/)
1181
+ end
1170
1182
  end
1171
1183
 
1172
1184
  describe "response logging" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitget.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran