Get the list of current certificates from zgrab scans for the specified zones. Append any new entries to the provided array of current_certs. This currently does not check
(
mongo_connector, zgrab_collection, zone, current_certs
)
| 512 | |
| 513 | |
| 514 | def add_initial_zgrab2_certificates( |
| 515 | mongo_connector, zgrab_collection, zone, current_certs |
| 516 | ): |
| 517 | """ |
| 518 | Get the list of current certificates from zgrab scans for the specified zones. |
| 519 | Append any new entries to the provided array of current_certs. |
| 520 | This currently does not check |
| 521 | """ |
| 522 | |
| 523 | results = mongo_connector.perform_find( |
| 524 | zgrab_collection, |
| 525 | { |
| 526 | "$or": [ |
| 527 | { |
| 528 | "data.http.result.redirect_response_chain.0.request.tls_log.handshake_log.server_certificates.certificate.parsed.subject.common_name": { |
| 529 | "$regex": r"^(.+\.)*" + zone + "$" |
| 530 | } |
| 531 | }, |
| 532 | { |
| 533 | "data.http.result.redirect_response_chain.0.request.tls_log.handshake_log.server_certificates.certificate.parsed.extensions.subject_alt_name.dns_names": { |
| 534 | "$regex": r"^(.+\.)*" + zone + "$" |
| 535 | } |
| 536 | }, |
| 537 | ] |
| 538 | }, |
| 539 | filter={"data.http.result.redirect_response_chain": 1}, |
| 540 | ) |
| 541 | |
| 542 | for result in results: |
| 543 | i = next( |
| 544 | ( |
| 545 | index |
| 546 | for (index, item) in enumerate(current_certs) |
| 547 | if item["id"] |
| 548 | == result["data"]["http"]["result"]["redirect_response_chain"][0][ |
| 549 | "request" |
| 550 | ]["tls_log"]["handshake_log"]["server_certificates"]["certificate"][ |
| 551 | "parsed" |
| 552 | ][ |
| 553 | "fingerprint_sha256" |
| 554 | ] |
| 555 | ), |
| 556 | None, |
| 557 | ) |
| 558 | if i is None: |
| 559 | item = { |
| 560 | "id": result["data"]["http"]["result"]["redirect_response_chain"][0][ |
| 561 | "request" |
| 562 | ]["tls_log"]["handshake_log"]["server_certificates"]["certificate"][ |
| 563 | "parsed" |
| 564 | ][ |
| 565 | "fingerprint_sha256" |
| 566 | ] |
| 567 | } |
| 568 | dns_list = [] |
| 569 | try: |
| 570 | for dns_name in result["data"]["http"]["result"][ |
| 571 | "redirect_response_chain" |
no test coverage detected