From 35cb47c97b8f8b3ac63c934f714890ea7ee663fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 12 Jun 2023 05:07:54 +0200 Subject: [PATCH] Continued: - added optional --domain parameter to fetch only from one oliphant blocklist files --- fba/boot.py | 1 + fba/commands.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fba/boot.py b/fba/boot.py index 525ef6b..509333d 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -88,6 +88,7 @@ def init_parser(): "fetch_oliphant", help="Fetches CSV files (block recommendations) for more possible instances to disover", ) + parser.add_argument("--domain", help="Instance name (aka. domain) to check") parser.set_defaults(command=commands.fetch_oliphant) ### Fetch instances from given initial instance ### diff --git a/fba/commands.py b/fba/commands.py index 8d5401d..165b67c 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -537,8 +537,13 @@ def fetch_oliphant(args: argparse.Namespace): ) for block in blocklists: + # Is domain given and not equal blocker? + if isinstance(args.domain, str) and args.domain != block["blocker"]: + # DEBUG: print(f"DEBUG: Skipping blocker='{block['blocker']}', not matching args.domain='{args.domain}'") + continue + # Fetch this URL - print(f"DEBUG: Fetching csv_url='{block['csv_url']}' for blocker='{block['blocker']}' ...") + print(f"INFO: Fetching csv_url='{block['csv_url']}' for blocker='{block['blocker']}' ...") response = fba.fetch_url(f"{base_url}/{block['csv_url']}", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))) # DEBUG: print(f"DEBUG: response[]='{type(response)}'") -- 2.39.5