Skip to content

Commit

Permalink
di redact
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Aug 26, 2024
1 parent edc0489 commit 7c84fe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion spec/datadog/di/redactor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
describe '#redact_type?' do
class SensitiveType; end

let(:redacted_type_names) { %w[SensitiveType] }
let(:redacted_type_names) { %w[SensitiveType WildCard*] }

class WildCardClass; end

before do
expect(di_settings).to receive(:redacted_type_names).and_return(redacted_type_names)
Expand All @@ -53,6 +55,7 @@ class SensitiveType; end
['redacted', SensitiveType.new, true],
['not redacted', /123/, false],
['primitive type', nil, false],
['wild card type', WildCardClass.new, true],
]

CASES.each do |(label, value_, redact_)|
Expand Down
6 changes: 5 additions & 1 deletion spec/datadog/di/serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class SensitiveType
end

class WildCardClass; end

let(:settings) do
double('settings').tap do |settings|
allow(settings).to receive(:internal_dynamic_instrumentation).and_return(di_settings)
Expand All @@ -15,7 +17,7 @@ class SensitiveType
allow(settings).to receive(:enabled).and_return(true)
allow(settings).to receive(:propagate_all_exceptions).and_return(false)
allow(settings).to receive(:redacted_identifiers).and_return([])
allow(settings).to receive(:redacted_type_names).and_return(%w[SensitiveType])
allow(settings).to receive(:redacted_type_names).and_return(%w[SensitiveType WildCard*])
end
end

Expand All @@ -39,6 +41,8 @@ class SensitiveType
{password: {type: 'String', notCapturedReason: 'redactedIdent'}}],
['redacted type', {value: SensitiveType.new},
{value: {type: 'SensitiveType', notCapturedReason: 'redactedType'}}],
['redacted wild card type', {value: WildCardClass.new},
{value: {type: 'WildCardClass', notCapturedReason: 'redactedType'}}],
['empty array', {arr: []},
{arr: {type: 'Array', entries: []}}],
['array of primitives', {arr: [42, 'hello', nil, true]},
Expand Down

0 comments on commit 7c84fe8

Please sign in to comment.