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

Function add_initial_zgrab2_certificates

python3_cron_scripts/create_cert_graphs.py:514–638  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

512
513
514def 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"

Callers 1

mainFunction · 0.85

Calls 2

get_scan_countFunction · 0.85
perform_findMethod · 0.80

Tested by

no test coverage detected