Skip to content

Commit

Permalink
Merge pull request #3070 from DataDog/asm-fix-automated-useer-events-…
Browse files Browse the repository at this point in the history
…settings

Fix ASM setting for automated user events.
  • Loading branch information
GustavoCaso committed Aug 23, 2023
2 parents e1079ba + f73885d commit f3c7f96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/datadog/appsec/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module Settings
'safe',
'extended'
].freeze
APPSEC_VALID_TRACK_USER_EVENTS_ENABLED_VALUES = [
'1',
'true'
].concat(APPSEC_VALID_TRACK_USER_EVENTS_MODE).freeze

def self.extended(base)
base = base.singleton_class unless base.is_a?(Class)
Expand Down Expand Up @@ -100,7 +104,7 @@ def self.add_settings!(base)
if env_value == 'disabled'
false
else
['1', 'true'].include?(env_value.strip.downcase)
APPSEC_VALID_TRACK_USER_EVENTS_ENABLED_VALUES.include?(env_value.strip.downcase)
end
end
end
Expand All @@ -112,6 +116,8 @@ def self.add_settings!(base)
o.setter do |v|
if APPSEC_VALID_TRACK_USER_EVENTS_MODE.include?(v)
v
elsif v == 'disabled'
'safe'
else
Datadog.logger.warn(
'The appsec.track_user_events.mode value provided is not supported.' \
Expand Down
1 change: 1 addition & 0 deletions sig/datadog/appsec/configuration/settings.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Datadog
DEFAULT_OBFUSCATOR_KEY_REGEX: ::String
DEFAULT_OBFUSCATOR_VALUE_REGEX: ::String
APPSEC_VALID_TRACK_USER_EVENTS_MODE: ::Array[String]
APPSEC_VALID_TRACK_USER_EVENTS_ENABLED_VALUES: ::Array[String]

def self.extended: (untyped base) -> untyped

Expand Down
8 changes: 8 additions & 0 deletions spec/datadog/appsec/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,14 @@ def patcher

it { is_expected.to eq(false) }
end

context 'using the mode values: extended | safe' do
['extended', 'safe'].each do |value|
let(:track_user_events_enabled) { value }

it { is_expected.to eq(true) }
end
end
end
end
end
Expand Down

0 comments on commit f3c7f96

Please sign in to comment.