Skip to content

Commit

Permalink
Merge pull request #3041 from DataDog/improve-quantization
Browse files Browse the repository at this point in the history
Improve quantization
  • Loading branch information
TonyCTHsu committed Aug 15, 2023
2 parents cfc825a + c9451b7 commit 50a2035
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/datadog/tracing/contrib/utils/quantization/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@ def obfuscate_query(query, options = {})
(?:"|%22)?
)
(?: # common keys
(?:old_?|new_?)?p(?:ass)?w(?:or)?d(?:1|2)? # pw, password variants
|pass(?:_?phrase)? # pass, passphrase variants
(?:old[-_]?|new_?)?p(?:ass)?w(?:or)?d(?:1|2)? # pw, password variants
|pass(?:[-_]?phrase)? # pass, passphrase variants
|secret
|(?: # key, key_id variants
api_?
|private_?
|public_?
|access_?
|secret_?
)key(?:_?id)?
api[-_]?
|private[-_]?
|public[-_]?
|access[-_]?
|secret[-_]?
)key(?:[-_]?id)?
|token
|consumer_?(?:id|key|secret)
|consumer[-_]?(?:id|key|secret)
|sign(?:ed|ature)?
|auth(?:entication|orization)?
)
Expand Down
22 changes: 22 additions & 0 deletions spec/datadog/tracing/contrib/utils/quantization/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
it { is_expected.to eq('http://example.com/path?categories[]') }
end

context 'default behavior for an array with indices' do
let(:url) { 'http://example.com/path?categories[0]=1&categories[1]=2' }

it { is_expected.to eq('http://example.com/path?categories[0]&categories[1]') }
end

context 'default behavior for a hash' do
let(:url) { 'http://example.com/path?categories[foo]=1&categories[bar]=2' }

it { is_expected.to eq('http://example.com/path?categories[foo]&categories[bar]') }
end

context 'with query: show: value' do
let(:options) { { query: { show: ['category_id'] } } }

Expand Down Expand Up @@ -484,13 +496,23 @@
public_key_id
access_key_id
secret_key_id
api-key
api-key-id
private-key
private-key-id
public-key-id
access-key-id
secret-key-id
token
consumerid
consumerkey
consumersecret
consumer_id
consumer_key
consumer_secret
consumer-id
consumer-key
consumer-secret
sign
signed
signature
Expand Down

0 comments on commit 50a2035

Please sign in to comment.