Insert results so that their entries are current
(logger, dns_result, dns_manager, result, source)
| 119 | |
| 120 | |
| 121 | def insert_current_results(logger, dns_result, dns_manager, result, source): |
| 122 | """ |
| 123 | Insert results so that their entries are current |
| 124 | """ |
| 125 | for dns_entry in dns_result: |
| 126 | if is_tracked_zone(dns_entry["fqdn"], result["zone"]): |
| 127 | new_entry = {} |
| 128 | new_entry["updated"] = datetime.now() |
| 129 | new_entry["zone"] = result["zone"] |
| 130 | new_entry["fqdn"] = dns_entry["fqdn"] |
| 131 | if "created" in result: |
| 132 | new_entry["created"] = result["created"] |
| 133 | else: |
| 134 | new_entry["created"] = datetime.now() |
| 135 | new_entry["value"] = dns_entry["value"] |
| 136 | new_entry["type"] = dns_entry["type"] |
| 137 | new_entry["status"] = "confirmed" |
| 138 | |
| 139 | if "sonar_timestamp" in result: |
| 140 | new_entry["sonar_timestamp"] = result["sonar_timestamp"] |
| 141 | |
| 142 | if source.endswith("_saved"): |
| 143 | dns_manager.insert_record(new_entry, source) |
| 144 | else: |
| 145 | dns_manager.insert_record(new_entry, source + "_saved") |
| 146 | else: |
| 147 | logger.debug( |
| 148 | "Failed to insert record for " |
| 149 | + dns_entry["fqdn"] |
| 150 | + " because it is not in the tracked zone:" |
| 151 | + result["zone"] |
| 152 | + " for the domain: " |
| 153 | + result["fqdn"] |
| 154 | ) |
| 155 | |
| 156 | |
| 157 | def main(logger=None): |
no test coverage detected