Skip to content

Commit

Permalink
Only allow base 10 numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Dec 15, 2023
1 parent 9eeb431 commit b3e8f7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datadog/core/configuration/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def coerce_env_variable(value)

def coerce_env_var_int(value)
# Strict integer parsing
Integer(value)
Integer(value, 10)
rescue ArgumentError => e
# Try also parsing as a whole floating point numbers
begin
Expand Down
7 changes: 7 additions & 0 deletions spec/datadog/core/configuration/option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@
expect(option.get).to eq 1234
end

context 'with an octal number' do
let(:env_value) { '010' }
it 'parses in base 10' do
expect(option.get).to eq 10
end
end

context 'with a whole float' do
let(:env_value) { '10.0' }
it 'coerce value' do
Expand Down

0 comments on commit b3e8f7c

Please sign in to comment.