Begin Main...
(logger=None)
| 286 | |
| 287 | |
| 288 | def main(logger=None): |
| 289 | """ |
| 290 | Begin Main... |
| 291 | """ |
| 292 | if logger is None: |
| 293 | logger = LoggingUtil.create_log(__name__) |
| 294 | |
| 295 | now = datetime.now() |
| 296 | print("Starting: " + str(now)) |
| 297 | logger.info("Starting...") |
| 298 | |
| 299 | # Connect to the remote databases |
| 300 | mongo_connector = MongoConnector.MongoConnector() |
| 301 | rm_connector = RemoteMongoConnector.RemoteMongoConnector() |
| 302 | dns_manager = DNSManager.DNSManager(mongo_connector) |
| 303 | zones = ZoneManager.get_distinct_zones(mongo_connector) |
| 304 | |
| 305 | jobs_manager = JobsManager.JobsManager(mongo_connector, "remote_download") |
| 306 | jobs_manager.record_job_start() |
| 307 | |
| 308 | remote_jobs_collection = rm_connector.get_jobs_connection() |
| 309 | |
| 310 | # Check the status of the Censys job on the remote database |
| 311 | try: |
| 312 | status = remote_jobs_collection.find_one({"job_name": "censys"}) |
| 313 | except: |
| 314 | logger.error("Can not connect to remote database") |
| 315 | jobs_manager.record_job_error() |
| 316 | exit(1) |
| 317 | |
| 318 | if ( |
| 319 | status is not None |
| 320 | and "status" in status |
| 321 | and status["status"] != jobs_manager.COMPLETE |
| 322 | ): |
| 323 | logger.info("Censys scans status is not COMPLETE") |
| 324 | elif ( |
| 325 | status is not None |
| 326 | and "status" in status |
| 327 | and status["status"] == jobs_manager.COMPLETE |
| 328 | ): |
| 329 | # Get connections to the relevant collections. |
| 330 | censys_collection = mongo_connector.get_zgrab_443_data_connection() |
| 331 | remote_censys_collection = rm_connector.get_zgrab_443_data_connection() |
| 332 | |
| 333 | download_censys_scan_info(logger, censys_collection, remote_censys_collection) |
| 334 | |
| 335 | # Tell the remote database that is safe to start processing the next Censys file |
| 336 | remote_jobs_collection.update_one( |
| 337 | {"job_name": "censys"}, |
| 338 | {"$currentDate": {"updated": True}, "$set": {"status": jobs_manager.READY}}, |
| 339 | ) |
| 340 | |
| 341 | # Get connections to the relevant HTTPS collections. |
| 342 | zgrab_443_data_collection = mongo_connector.get_zgrab_443_data_connection() |
| 343 | remote_zgrab_443_data_collection = rm_connector.get_zgrab_443_data_connection() |
| 344 | |
| 345 | download_zgrab_info( |
no test coverage detected