Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/c7n_gcp/utils.py: 7%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1def get_firewall_port_ranges(firewall_resources):
2 for r_index, r in enumerate(firewall_resources):
3 action = "allowed" if "allowed" in r else "denied"
4 for protocol_index, protocol in enumerate(r[action]):
5 if "ports" in protocol:
6 port_ranges = []
7 for port in protocol["ports"]:
8 if "-" in port:
9 port_split = port.split("-")
10 port_ranges.append({"beginPort": port_split[0], "endPort": port_split[1]})
11 else:
12 port_ranges.append({"beginPort": port, "endPort": port})
13 protocol['portRanges'] = port_ranges
14 r[action][protocol_index] = protocol
15 firewall_resources[r_index] = r
16 return firewall_resources