Skip to content

Commit

Permalink
chore: release 2.4.0 Ruby Gem (#953)
Browse files Browse the repository at this point in the history
Forgots.

---------

Co-authored-by: Kenny Hoxworth <[email protected]>
  • Loading branch information
hoxworth and Kenny Hoxworth authored Jan 24, 2024
1 parent 8cfb6d7 commit d2ab0f6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
readme-metrics (2.3.0)
readme-metrics (2.4.0)
httparty (~> 0.18)
rack (>= 2.2, < 4)

Expand All @@ -21,7 +21,7 @@ GEM
json (2.6.2)
json-schema (2.8.1)
addressable (>= 2.4)
mini_mime (1.1.2)
mini_mime (1.1.5)
multi_xml (0.6.0)
parallel (1.22.1)
parser (3.1.2.1)
Expand Down
4 changes: 1 addition & 3 deletions packages/ruby/lib/readme/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class HttpRequest

def initialize(env)
# Sanitize the auth header, if it exists
if env.has_key?("HTTP_AUTHORIZATION")
env["HTTP_AUTHORIZATION"] = Readme::Mask.mask(env["HTTP_AUTHORIZATION"])
end
env['HTTP_AUTHORIZATION'] = Readme::Mask.mask(env['HTTP_AUTHORIZATION']) if env.key?('HTTP_AUTHORIZATION')
@request = Rack::Request.new(env)

return unless IS_RACK_V3
Expand Down
12 changes: 6 additions & 6 deletions packages/ruby/lib/readme/mask.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'digest'

module Readme
class Mask
def self.mask(data)
digest = Digest::SHA2.new(512).base64digest(data)
opts = data.length >= 4 ? data[-4,4] : data
"sha512-#{digest}?#{opts}"
end
class Mask
def self.mask(data)
digest = Digest::SHA2.new(512).base64digest(data)
opts = data.length >= 4 ? data[-4, 4] : data
"sha512-#{digest}?#{opts}"
end
end
end
2 changes: 1 addition & 1 deletion packages/ruby/lib/readme/metrics/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Readme
class Metrics
VERSION = '2.3.0'
VERSION = '2.4.0'
end
end
4 changes: 1 addition & 3 deletions packages/ruby/spec/readme/http_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@

expect(request.headers).to eq(
{
'Authorization' => Readme::Mask.mask('Basic xxx:aaa'),
'Authorization' => Readme::Mask.mask('Basic xxx:aaa')
}
)
end


it 'matches the hashing output of the node.js SDK' do
env = {
'HTTP_AUTHORIZATION' => 'Bearer: a-random-api-key'
Expand All @@ -193,7 +192,6 @@
}
)
end

end

describe '#body' do
Expand Down
4 changes: 2 additions & 2 deletions packages/ruby/spec/readme/payload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
development: true
)

expect(JSON.parse(result.to_json)["group"]["id"]).to match(Readme::Mask.mask(id))
expect(JSON.parse(result.to_json)['group']['id']).to match(Readme::Mask.mask(id))
expect(result.to_json).to match_json_schema('payload')
end

Expand All @@ -32,7 +32,7 @@
development: true
)

expect(JSON.parse(result.to_json)["group"]["id"]).to match(Readme::Mask.mask(api_key))
expect(JSON.parse(result.to_json)['group']['id']).to match(Readme::Mask.mask(api_key))
expect(result.to_json).to match_json_schema('payload')
end

Expand Down

0 comments on commit d2ab0f6

Please sign in to comment.