Skip to content

Commit b7c85f1

Browse files
committed
add unit test for control chars
1 parent ff9d041 commit b7c85f1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ def create_timestamped_signature(timestamp, version = "v0")
282282
long_headers = { default_header => long_signature }
283283
expect(valid_with(payload: long_payload, headers: long_headers)).to be true
284284
end
285+
286+
it "returns false and logs for signature containing non-null control characters" do
287+
control_char = "\x01"
288+
headers_with_control = { default_header => signature + control_char }
289+
expect(log).to receive(:warn).with(/control characters/)
290+
expect(valid_with(headers: headers_with_control)).to be false
291+
end
285292
end
286293

287294
context "format mismatch attacks" do

0 commit comments

Comments
 (0)