mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Add check if key is Base64-encoded
This commit is contained in:
parent
cdf1721ba2
commit
db729d2421
1 changed files with 12 additions and 1 deletions
|
@ -312,6 +312,7 @@ class Epp::Domain < Domain
|
|||
keys = []
|
||||
return keys if frame.blank?
|
||||
inf_data = DnsSecKeys.new(frame)
|
||||
add_epp_error('2005', nil, nil, %i[dnskeys invalid]) if not_base64?(inf_data)
|
||||
|
||||
if action == 'rem' &&
|
||||
frame.css('rem > all').first.try(:text) == 'true'
|
||||
|
@ -333,6 +334,16 @@ class Epp::Domain < Domain
|
|||
errors.any? ? [] : keys
|
||||
end
|
||||
|
||||
def not_base64?(inf_data)
|
||||
inf_data.key_data.any? do |key|
|
||||
value = key[:public_key]
|
||||
|
||||
!value.is_a?(String) || Base64.strict_encode64(Base64.strict_decode64(value)) != value
|
||||
end
|
||||
rescue ArgumentError
|
||||
true
|
||||
end
|
||||
|
||||
class DnsSecKeys
|
||||
def initialize(frame)
|
||||
@key_data = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue