def scan_unsigned_file(file, temp_file)
@unsigned_keys = []
continued_line = false
rr_counter = 0
need_to_parse = false
soa = nil
zone_reader = Dnsruby::ZoneReader.new(@config.name, @config.soa ? @config.soa.minimum : nil,
@config.soa ? @config.soa.ttl : nil)
IO.foreach((file.to_s+"").untaint) {|line|
next if (line[0,1] == ";")
next if (line.strip.length == 0)
next if (!line || (line.length == 0))
if (!continued_line)
need_to_parse = (line.index("(") || line.index("\"") || line.index("\'"))
end
ret_line = line
if (need_to_parse || continued_line || ret_line.index("soa") || ret_line.index("SOA") ||
(line.index("$TTL") == 0) || (line.index("$ORIGIN") == 0))
begin
ret_line = zone_reader.process_line(line)
rescue Exception => e
KASPAuditor.exit("ERROR - Can't process zone file : #{file.inspect} : #{e}", 1)
end
if (!ret_line)
continued_line = true
next
end
need_to_parse = false
continued_line = false
end
next if (line.index("$ORIGIN") == 0)
next if (line.index("$TTL") == 0)
if (ret_line=~/DNSKEY|RRSIG|NSEC|NSEC3|NSEC3PARAM|TYPE/)
begin
rr = RR.create(ret_line)
if ([Types::RRSIG, Types::DNSKEY, Types::NSEC, Types::NSEC3, Types::NSEC3PARAM].include?rr.type)
@parent.log(LOG_WARNING, "#{rr.type} present in unsigned file : #{ret_line.chomp}")
need_to_parse = false
continued_line = false
if (rr.type == Types::DNSKEY)
@unsigned_keys.push(rr)
end
next
end
rescue Exception
end
end
if (ret_line.index("soa") || ret_line.index("SOA"))
rr = RR.create(ret_line)
if (rr.type == Types::SOA)
if (soa)
@parent.log(LOG_ERR, "Multiple SOA records found in signed file")
end
soa = ret_line
end
end
need_to_parse = false
continued_line = false
rr_name = ret_line.split()[0]
if (rr_name[rr_name.length-1, 1] != ".") || (rr_name.downcase=~/#{@config.name.downcase}\.$/)
rr_counter += 1
end
}
return rr_counter, soa
end