Begin Main...
(logger=None)
| 246 | |
| 247 | |
| 248 | def main(logger=None): |
| 249 | """ |
| 250 | Begin Main... |
| 251 | """ |
| 252 | if logger is None: |
| 253 | logger = LoggingUtil.create_log(__name__) |
| 254 | |
| 255 | now = datetime.now() |
| 256 | print("Starting: " + str(now)) |
| 257 | logger.info("Starting...") |
| 258 | |
| 259 | # Set up the common objects |
| 260 | mongo_connector = MongoConnector.MongoConnector() |
| 261 | ct_collection = mongo_connector.get_certificate_transparency_connection() |
| 262 | zones = ZoneManager.get_distinct_zones(mongo_connector) |
| 263 | jobs_manager = JobsManager.JobsManager(mongo_connector, "get_crt_sh") |
| 264 | jobs_manager.record_job_start() |
| 265 | |
| 266 | save_location = "crt-sh" |
| 267 | download_method = "dbAndSave" |
| 268 | |
| 269 | parser = argparse.ArgumentParser( |
| 270 | description="Download DNS and/or certificate information from crt.sh." |
| 271 | ) |
| 272 | parser.add_argument( |
| 273 | "--fetch_dns_records", |
| 274 | action="store_true", |
| 275 | help="Indicates whether to add DNS entries to the database", |
| 276 | ) |
| 277 | parser.add_argument( |
| 278 | "--download_methods", |
| 279 | choices=["dbAndSave", "dbOnly"], |
| 280 | default=download_method, |
| 281 | help="Indicates whether to download the raw files or just record in the database.", |
| 282 | ) |
| 283 | parser.add_argument( |
| 284 | "--cert_save_location", |
| 285 | required=False, |
| 286 | default=save_location, |
| 287 | help="Indicates the folder name when choosing dbAndSave", |
| 288 | ) |
| 289 | parser.add_argument( |
| 290 | "--storage_system", |
| 291 | choices=[ |
| 292 | StorageManager.StorageManager.AWS_S3, |
| 293 | StorageManager.StorageManager.AZURE_BLOB, |
| 294 | StorageManager.StorageManager.LOCAL_FILESYSTEM, |
| 295 | ], |
| 296 | default=StorageManager.StorageManager.LOCAL_FILESYSTEM, |
| 297 | help="Indicates where to save the files when dbAndSave is chosen", |
| 298 | ) |
| 299 | args = parser.parse_args() |
| 300 | |
| 301 | if args.cert_save_location: |
| 302 | save_location = args.cert_save_location |
| 303 | |
| 304 | if args.storage_system == StorageManager.StorageManager.LOCAL_FILESYSTEM: |
| 305 | if "/" not in save_location: |
no test coverage detected