gcp.compute package¶
Submodules¶
gcp.compute.helpers module¶
-
gcp.compute.helpers.
does_firewall_open_all_ports_to_any
(firewall)[source]¶ Returns True if firewall has a rule to open all ports to any source. Excludes ICMP.
>>> does_firewall_open_all_ports_to_any({}) False >>> does_firewall_open_all_ports_to_any({'sourceRanges': ['1.1.1.1/1'], 'allowed': [{'ports': ['1', '2', '300']}]}) False >>> does_firewall_open_all_ports_to_any({'sourceRanges': ['1.1.1.1/1'], 'allowed': [{'ports': ['0-65535']}]}) True >>> does_firewall_open_all_ports_to_any({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['0-65535']}]}) True >>> does_firewall_open_all_ports_to_any({'sourceRanges': ['10.0.0.5/32'], 'allowed': [{'ports': ['0-65535']}]}) True
-
gcp.compute.helpers.
does_firewall_open_all_ports_to_all
(firewall)[source]¶ Returns True if firewall has a rule to open all ports to all. Excludes ICMP.
>>> does_firewall_open_all_ports_to_all({}) False >>> does_firewall_open_all_ports_to_all({'sourceRanges': ['1.1.1.1/1']}) False >>> does_firewall_open_all_ports_to_all({'sourceRanges': ['1.1.1.1/1'], 'allowed': [{'ports': ['0-65535']}]}) False >>> does_firewall_open_all_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['0-65535']}]}) True
-
gcp.compute.helpers.
does_firewall_open_any_ports_to_all
(firewall, allowed_ports=None)[source]¶ Returns True if firewall has a rule to open any ports (except 80/443) to all. Excludes ICMP.
>>> does_firewall_open_any_ports_to_all({}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['1.1.1.1/1']}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['1.1.1.1/1'], 'allowed': [{'ports': ['0-65535']}]}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['0-65535']}]}) True >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['1.1.1.1/1'], 'allowed': [{'ports': ['123']}]}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['123']}]}) True >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['80']}]}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['443']}]}) False >>> does_firewall_open_any_ports_to_all({'sourceRanges': ['0.0.0.0/0'], 'allowed': [{'ports': ['22', '80', '443']}]}) True