Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASM setting for automated user events. #3070

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading