Commit 7ad4803e authored by Stan Hu's avatar Stan Hu

Fix Cf-Ray HTTP header not being logged

The Cf-Ray header ends with a suffix of the datacenter (e.g. `-IAD`),
and the regex did not properly handle the dash. This change fixes the
regexp to allow for alphanumeric characters and the dash.
parent f2375df8
......@@ -14,7 +14,7 @@ module Gitlab
def valid_cloudflare_header?(value)
return false unless value.present?
return false if value.length > 64
return false if value.index(/[^[:alnum:]]/)
return false if value.index(/[^[A-Za-z0-9-]]/)
true
end
......
......@@ -19,7 +19,7 @@ describe Gitlab::Logging::CloudflareHelper do
end
context 'with normal headers' do
let(:headers) { { 'Cf-Ray' => SecureRandom.hex, 'Cf-Request-Id' => SecureRandom.hex } }
let(:headers) { { 'Cf-Ray' => '592f0aa22b3dea38-IAD', 'Cf-Request-Id' => SecureRandom.hex } }
it 'adds Cf-Ray-Id and Cf-Request-Id' do
helper.store_cloudflare_headers!(payload, request)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment