Skip to content

Commit 4989610

Browse files
CopilotGrantBirki
andcommitted
Complete security audit: final cleanup and test coverage improvements
Co-authored-by: GrantBirki <[email protected]>
1 parent ecee4c5 commit 4989610

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/hooks/plugins/auth/shared_secret.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class SharedSecret < Base
5656
# headers: request.headers,
5757
# config: { auth: { header: 'Authorization' } }
5858
# )
59-
def self.valid?(payload:, headers:, config:)
59+
def self.valid?(_payload:, headers:, config:)
6060
secret = fetch_secret(config)
6161

6262
validator_config = build_config(config)

spec/unit/lib/hooks/plugins/auth/base_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def self.valid?(payload:, headers:, config:)
234234

235235
expect(described_class.find_header_value(headers, "Missing-Header")).to be_nil
236236
expect(described_class.find_header_value(headers, "")).to be_nil
237+
expect(described_class.find_header_value(headers, " ")).to be_nil
237238
expect(described_class.find_header_value(headers, nil)).to be_nil
238239
end
239240

spec/unit/lib/hooks/plugins/auth/shared_secret_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,20 @@ def valid_with(args = {})
390390
expect(result).to be false
391391
expect(Hooks::Log.instance).to have_received(:warn).with("Auth::SharedSecret validation failed: Signature mismatch")
392392
end
393+
394+
it "logs error and returns false on exception" do
395+
# Force an exception by mocking fetch_secret to raise
396+
allow(described_class).to receive(:fetch_secret).and_raise(StandardError, "Test error")
397+
398+
result = described_class.valid?(
399+
payload: '{"data":"value"}',
400+
headers: { "Authorization" => "test" },
401+
config: test_config
402+
)
403+
404+
expect(result).to be false
405+
expect(Hooks::Log.instance).to have_received(:error).with("Auth::SharedSecret validation failed: Test error")
406+
end
393407
end
394408
end
395409
end

0 commit comments

Comments
 (0)