Skip to content

Commit b3ded58

Browse files
committed
Raise InvalidSignature if Slack::Events::Request has no signature
Fix regression after #553. The old implementation handled a nil value properly, but the new implementation raises as `nil` does not have `bytesize`
1 parent e20efeb commit b3ded58

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* [#554](https://github.com/slack-ruby/slack-ruby-client/pull/557): Require Faraday >= 2.0.1 - [@anrichvs](https://github.com/AnrichVS).
44
* [#559](https://github.com/slack-ruby/slack-ruby-client/pull/559): Enable name-to-id translation of non-public channels - [@eizengan](https://github.com/eizengan).
55
* [#560](https://github.com/slack-ruby/slack-ruby-client/pull/560): Name-to-id translation can supply all sensible list options - [@eizengan](https://github.com/eizengan).
6+
* [#561](https://github.com/slack-ruby/slack-ruby-client/issues/563): Raise InvalidSignature when verifying a request without a signature - [@wesleyjellis](https://github.com/wesleyjellis).
67
* Your contribution here.
78

89
### 2.6.0 (2025/05/24)

lib/slack/events/request.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def expired?
5555
# Returns true if the signature coming from Slack is valid.
5656
def valid?
5757
raise MissingSigningSecret unless signing_secret
58+
raise InvalidSignature unless signature
5859

5960
digest = OpenSSL::Digest.new('SHA256')
6061
signature_basestring = [version, timestamp, body].join(':')

spec/slack/events/request_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
expect(http_request.body.read).to eq body
4848
end
4949

50+
context 'missing signature' do
51+
subject(:request) do
52+
described_class.new(http_request)
53+
end
54+
55+
let(:signature) { nil }
56+
57+
it 'raises InvalidSignature' do
58+
expect { request.valid? }.to raise_error Slack::Events::Request::InvalidSignature
59+
end
60+
end
61+
5062
context 'with an already read body' do
5163
before do
5264
http_request.body.read

0 commit comments

Comments
 (0)