diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a09bf..6d5124d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## dev + + ## [3.1.0] + +### Added + +- Added support to run the tool without SSL chain verification for users behind proxy servers who act as MITM + ### Changed - Scoring formula changed to: diff --git a/fusion_report/arguments.json b/fusion_report/arguments.json index 3a25384..295523a 100644 --- a/fusion_report/arguments.json +++ b/fusion_report/arguments.json @@ -111,6 +111,11 @@ "key": "--no-mitelman", "help": "Do not download mitelman fusion database", "action": "store_true" + }, + { + "key": "-no_ssl", + "help": "Turn off verification of SSL certificates when downloading data.", + "action": "store_true" } ], "cosmic": [ diff --git a/fusion_report/common/net.py b/fusion_report/common/net.py index 00e5f28..198c8ab 100644 --- a/fusion_report/common/net.py +++ b/fusion_report/common/net.py @@ -96,13 +96,12 @@ def get_cosmic_qiagen_token(params: Namespace): return json.loads(token_response)["access_token"] @staticmethod - def get_large_file(url: str) -> None: + def get_large_file(url: str, no_ssl) -> None: """Method for downloading a large file.""" LOG.info(f"Downloading {url}") try: headers = {"User-Agent": "Mozilla/5.0"} - response = requests.get(url, headers=headers, stream=True) - + response = requests.get(url, headers=headers, stream=True, verify=no_ssl) file = url.split("/")[-1].split("?")[0] if ( @@ -118,7 +117,7 @@ def get_large_file(url: str) -> None: raise DownloadException(ex) @staticmethod - def get_cosmic_from_sanger(token: str, return_err: List[str]) -> None: + def get_cosmic_from_sanger(token: str, return_err: List[str], no_ssl) -> None: """Method for download COSMIC database from sanger website.""" files = [] file: str = Settings.COSMIC["FILE"] @@ -131,10 +130,10 @@ def get_cosmic_from_sanger(token: str, return_err: List[str]) -> None: ), } try: - res = requests.get(url, headers=headers) + res = requests.get(url, headers=headers, verify=no_ssl) auth_url: str = res.json()["url"] LOG.info(f"auth_url: {auth_url}") - Net.get_large_file(auth_url) + Net.get_large_file(auth_url, no_ssl) files.append(".".join(file.split(".")[:-1])) with gzip.open(file, "rb") as archive, open(files[0], "wb") as out_file: @@ -170,11 +169,11 @@ def get_cosmic_from_qiagen(token: str, return_err: List[str], outputpath: str) - return_err.append(f'{Settings.COSMIC["NAME"]}: {ex}') @staticmethod - def get_fusiongdb2(self, return_err: List[str]) -> None: + def get_fusiongdb2(self, return_err: List[str], no_ssl) -> None: """Method for download FusionGDB2 database.""" try: url: str = f'{Settings.FUSIONGDB2["HOSTNAME"]}/{Settings.FUSIONGDB2["FILE"]}' - Net.get_large_file(url) + Net.get_large_file(url, no_ssl) file: str = f'{Settings.FUSIONGDB2["FILE"]}' df = pd.read_excel(file, engine="openpyxl") df["fusion"] = df["5'-gene (text format)"] + "--" + df["3'-gene (text format)"] @@ -188,11 +187,11 @@ def get_fusiongdb2(self, return_err: List[str]) -> None: return_err.append(f"FusionGDB2: {ex}") @staticmethod - def get_mitelman(self, return_err: List[str]) -> None: + def get_mitelman(self, return_err: List[str], no_ssl) -> None: """Method for download Mitelman database.""" try: url: str = f'{Settings.MITELMAN["HOSTNAME"]}/{Settings.MITELMAN["FILE"]}' - Net.get_large_file(url) + Net.get_large_file(url, no_ssl) with ZipFile(Settings.MITELMAN["FILE"], "r") as archive: files = [ x for x in archive.namelist() if "MBCA.TXT.DATA" in x and not "MACOSX" in x diff --git a/fusion_report/download.py b/fusion_report/download.py index e739d32..b6aa668 100644 --- a/fusion_report/download.py +++ b/fusion_report/download.py @@ -42,21 +42,23 @@ def download_all(self, params: Namespace) -> None: if not params.no_mitelman: # MITELMAN - Net.get_mitelman(self, return_err) + Net.get_mitelman(self, return_err, params.no_ssl) if not params.no_fusiongdb2: # FusionGDB2 - Net.get_fusiongdb2(self, return_err) + Net.get_fusiongdb2(self, return_err, params.no_ssl) if not params.no_cosmic: # COSMIC self.validate(params) if params.qiagen: Logger(__name__).info("Downloading resources from QIAGEN...") - Net.get_cosmic_from_qiagen(self.cosmic_token, return_err, params.output) + Net.get_cosmic_from_qiagen( + self.cosmic_token, return_err, params.output, params.no_ssl + ) else: Logger(__name__).info("Downloading resources from SANGER...") - Net.get_cosmic_from_sanger(self.cosmic_token, return_err) + Net.get_cosmic_from_sanger(self.cosmic_token, return_err, params.no_ssl) if len(return_err) > 0: raise DownloadException(return_err)