Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop base64 dependency #1071

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion debug.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ Gem::Specification.new do |spec|

spec.add_dependency "irb", "~> 1.10" # for irb:debug integration
spec.add_dependency "reline", ">= 0.3.8"
spec.add_dependency "base64"
end
5 changes: 2 additions & 3 deletions lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'json'
require 'digest/sha1'
require 'base64'
require 'securerandom'
require 'stringio'
require 'open3'
Expand Down Expand Up @@ -298,7 +297,7 @@ def handshake port, path
show_protocol :<, res

if res.match(/^Sec-WebSocket-Accept: (.*)\r\n/)
correct_key = Base64.strict_encode64 Digest::SHA1.digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
correct_key = Digest::SHA1.base64digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
raise "The Sec-WebSocket-Accept value: #{$1} is not valid" unless $1 == correct_key
else
raise "Unknown response: #{res}"
Expand Down Expand Up @@ -379,7 +378,7 @@ def handshake
show_protocol '>', req

if req.match(/^Sec-WebSocket-Key: (.*)\r\n/)
accept = Base64.strict_encode64 Digest::SHA1.digest "#{$1}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
accept = Digest::SHA1.base64digest "#{$1}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
res = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: #{accept}\r\n\r\n"
@sock.print res
show_protocol :<, res
Expand Down
3 changes: 1 addition & 2 deletions test/support/protocol_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'net/http'
require 'uri'
require 'digest/sha1'
require 'base64'

require_relative 'test_case'
require_relative 'dap_utils'
Expand Down Expand Up @@ -924,7 +923,7 @@ def handshake port, uuid
@sock.print "GET /#{uuid} HTTP/1.1\r\nHost: 127.0.0.1:#{port}\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: #{key}==\r\n\r\n"
server_key = get_server_key

correct_key = Base64.strict_encode64 Digest::SHA1.digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
correct_key = Digest::SHA1.base64digest "#{key}==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
raise "The Sec-WebSocket-Accept value: #{$1} is not valid" unless server_key == correct_key
end

Expand Down
Loading