fwr.cidr.version is never false or nil, so this only sorts by the cidr, potentially mixing IPv4 and IPv6 cidrs. I believe the intention here is to show all IPv4 addresses before all IPv6 addresses, so this changes the code to do that.
24 lines
637 B
Ruby
24 lines
637 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Serializers::Firewall < Serializers::Base
|
|
def self.serialize_internal(firewall, options = {})
|
|
base = {
|
|
id: firewall.ubid,
|
|
name: firewall.name,
|
|
description: firewall.description,
|
|
location: firewall.display_location,
|
|
firewall_rules: Serializers::FirewallRule.serialize(firewall.firewall_rules.sort_by { [it.cidr.version, it.cidr.to_s] })
|
|
}
|
|
|
|
if options[:include_path]
|
|
base[:path] = firewall.path
|
|
end
|
|
|
|
if options[:detailed]
|
|
base[:private_subnets] = Serializers::PrivateSubnet.serialize(firewall.private_subnets)
|
|
end
|
|
|
|
base
|
|
end
|
|
end
|