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 = []
|
keys = []
|
||||||
return keys if frame.blank?
|
return keys if frame.blank?
|
||||||
inf_data = DnsSecKeys.new(frame)
|
inf_data = DnsSecKeys.new(frame)
|
||||||
|
add_epp_error('2005', nil, nil, %i[dnskeys invalid]) if not_base64?(inf_data)
|
||||||
|
|
||||||
if action == 'rem' &&
|
if action == 'rem' &&
|
||||||
frame.css('rem > all').first.try(:text) == 'true'
|
frame.css('rem > all').first.try(:text) == 'true'
|
||||||
|
@ -333,6 +334,16 @@ class Epp::Domain < Domain
|
||||||
errors.any? ? [] : keys
|
errors.any? ? [] : keys
|
||||||
end
|
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
|
class DnsSecKeys
|
||||||
def initialize(frame)
|
def initialize(frame)
|
||||||
@key_data = []
|
@key_data = []
|
||||||
|
@ -381,7 +392,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
def key_data_from(frame)
|
def key_data_from(frame)
|
||||||
xm_copy frame, KEY_INTERFACE
|
xm_copy frame, KEY_INTERFACE
|
||||||
end
|
end
|
||||||
|
|
||||||
def ds_data_from(frame)
|
def ds_data_from(frame)
|
||||||
frame.css('dsData').each do |ds_data|
|
frame.css('dsData').each do |ds_data|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue