Fix CAA entries: escape double quotes (and forbid them in new entries).

This commit is contained in:
Philippe Pittoli 2024-12-10 13:08:10 +01:00
parent 177da35f6e
commit f0d9104e56

View File

@ -766,11 +766,11 @@ class DNSManager::Storage::Zone
def to_s(io : IO) def to_s(io : IO)
io << "(#{ "%4d" % @rrid }) " io << "(#{ "%4d" % @rrid }) "
io << "#{ "%.30s" % @name} #{ "%6d" % @ttl} CAA " io << "#{ "%.30s" % @name} #{ "%6d" % @ttl} CAA "
io << "#{ "%.3s" % @caa.flag} #{ "%.15s" % @caa.tag} #{quoted_string @caa.value}\n" io << "#{ "%.3s" % @caa.flag} #{ "%.15s" % @caa.tag} #{quoted_string escape_double_quotes @caa.value}\n"
end end
def to_bind9(io : IO) def to_bind9(io : IO)
io << "#{@name} #{@ttl} IN CAA #{@caa.flag} #{@caa.tag.to_s.downcase} #{quoted_string @caa.value}\n" io << "#{@name} #{@ttl} IN CAA #{@caa.flag} #{@caa.tag.to_s.downcase} #{quoted_string escape_double_quotes @caa.value}\n"
end end
def get_errors : Array(Error) def get_errors : Array(Error)
@ -784,6 +784,11 @@ class DNSManager::Storage::Zone
errors << "CAA invalid ttl: #{@ttl}, shouldn't be less than #{Zone.ttl_limit_min}" errors << "CAA invalid ttl: #{@ttl}, shouldn't be less than #{Zone.ttl_limit_min}"
end end
# This is an arbitrary limitation, we don't want people crashing their zones without knowing it.
if @caa.value.includes? '"'
errors << "CAA value contains double quotes"
end
# TODO: rest of the errors. # TODO: rest of the errors.
errors errors