MCPcopy Create free account
hub / github.com/adobe/Marinus / check_in_zone

Function check_in_zone

python3_cron_scripts/zgrab_http_ip.py:126–183  ·  view source on GitHub ↗

Obtain the DNS names from the common_name and dns_zones from the entry's SSL certificate. Determine if the entry's DNS names is in the list of provided zones. Return the matched zone.

(entry, zones)

Source from the content-addressed store, hash-verified

124
125
126def check_in_zone(entry, zones):
127 """
128 Obtain the DNS names from the common_name and dns_zones from the entry's SSL certificate.
129 Determine if the entry's DNS names is in the list of provided zones.
130 Return the matched zone.
131 """
132
133 if "zgrab2" in global_zgrab_path:
134 if "redirect_response_chain" in entry["data"]["http"]["result"]:
135 try:
136 certificate = entry["data"]["http"]["result"][
137 "redirect_response_chain"
138 ][0]["request"]["tls_log"]["handshake_log"]["server_certificates"][
139 "certificate"
140 ]
141 except:
142 return []
143 else:
144 try:
145 certificate = entry["data"]["http"]["result"]["response"]["request"][
146 "tls_log"
147 ]["handshake_log"]["server_certificates"]["certificate"]
148 except:
149 return []
150 else:
151 if "redirect_response_chain" in entry["data"]["http"]:
152 try:
153 certificate = entry["data"]["http"]["redirect_response_chain"][0][
154 "request"
155 ]["tls_handshake"]["server_certificates"]["certificate"]
156 except:
157 return []
158 else:
159 try:
160 certificate = entry["data"]["http"]["response"]["request"][
161 "tls_handshake"
162 ]["server_certificates"]["certificate"]
163 except:
164 return []
165
166 try:
167 temp1 = certificate["parsed"]["subject"]["common_name"]
168 except KeyError:
169 temp1 = []
170
171 try:
172 temp2 = certificate["parsed"]["extensions"]["subject_alt_name"]["dns_names"]
173 except KeyError:
174 temp2 = []
175
176 cert_zones = []
177 value_array = temp1 + temp2
178 for value in value_array:
179 zone = zone_compare(value, zones)
180 if zone is not None and zone not in cert_zones:
181 cert_zones.append(zone)
182
183 return cert_zones

Callers 1

insert_resultFunction · 0.70

Calls 1

zone_compareFunction · 0.70

Tested by

no test coverage detected