Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/c7n_gcp/utils.py: 7%

15 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:51 +0000

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