Skip to content

Commit

Permalink
Disallow the empty uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
ugexe committed Jun 11, 2024
1 parent 9231a16 commit 7516541
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/minfraud/components/report/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def validate
validate_uuid('minfraud_id', @minfraud_id)

if ip_address.nil? &&
minfraud_id.nil? &&
(minfraud_id.nil? || is_empty_uuid(minfraud_id)) &&
(maxmind_id.nil? || maxmind_id.empty?) &&
(transaction_id.nil? || transaction_id.empty?)
raise ArgumentError, 'At least one of the following is required: ip_address, minfraud_id, maxmind_id, transaction_id.'
end
end

def is_empty_uuid(value)
stripped_value = value.to_s.gsub('-', '')
return stripped_value == '0' * 32
end
end
end
end
Expand Down

0 comments on commit 7516541

Please sign in to comment.