From 6795985b14d8496789dcfed50d20a102d142e89e Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 09:55:22 +0100 Subject: [PATCH 1/7] Container warns if permission is denied --- nf_core/modules/lint/main_nf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index e9e18b3e12..b59e166441 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -328,8 +328,11 @@ def check_process_section(self, lines, fix_version, progress_bar): log.debug(f"Unable to connect to url '{urlunparse(url)}' due to error: {e}") self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) continue - if response.status_code != 200: - self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) + if not response.ok: + if 400 <= response.status_code < 500: + self.warned.append(("container_links", "Access to container URL denied", self.main_nf)) + else: + self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) # Check that all bioconda packages have build numbers # Also check for newer versions From ec334da8bbd13b81e601df48fb8d9a44dc203528 Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 09:58:40 +0100 Subject: [PATCH 2/7] Change to specific status codes --- nf_core/modules/lint/main_nf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index b59e166441..dc29513dc2 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -329,7 +329,7 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) continue if not response.ok: - if 400 <= response.status_code < 500: + if response.status_code in [400, 401, 402, 403]: self.warned.append(("container_links", "Access to container URL denied", self.main_nf)) else: self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) From 8cb66f5e7e5b6f4521ec2d27f0d98763bf67a1fa Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 10:01:47 +0100 Subject: [PATCH 3/7] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db70fce12..13e340465d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Added config `docker.registry` to pipeline template for a configurable default container registry when using Docker containers. Defaults to `quay.io` ([#2133](https://github.com/nf-core/tools/pull/2133)) - Add tower.yml file to the pipeline template ([#2251](https://github.com/nf-core/tools/pull/2251)) - Add mastodon badge to README ([#2253](https://github.com/nf-core/tools/pull/2253)) +- Warn if container access is denied ([#2270](https://github.com/nf-core/tools/pull/2270)) ### Linting From 7d87d6d389fd3cad951a673c1194d1fa73f8fc40 Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 11:01:10 +0100 Subject: [PATCH 4/7] Raise warning for modules --- nf_core/modules/lint/main_nf.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 58d27f0431..3a86e0f314 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -332,10 +332,13 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) continue if not response.ok: - if response.status_code in [400, 401, 402, 403]: - self.warned.append(("container_links", "Access to container URL denied", self.main_nf)) - else: - self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) + self.warned.append( + ( + "container_links", + f"Access to container {response.url} denied, status code: {response.status_code}", + self.main_nf, + ) + ) # Check that all bioconda packages have build numbers # Also check for newer versions From e4cd14a0fccaada8596c4f2437b210080b179a12 Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 11:48:27 +0100 Subject: [PATCH 5/7] More explicit errors regarding connecting to container URLs --- nf_core/modules/lint/main_nf.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 3a86e0f314..5c33d034c3 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -332,13 +332,23 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) continue if not response.ok: - self.warned.append( - ( - "container_links", - f"Access to container {response.url} denied, status code: {response.status_code}", - self.main_nf, + if response.status_code in [400, 401, 402, 403]: + self.warned.append( + ( + "container_links", + f"Access to container {response.url} denied, status code: {response.status_code}", + self.main_nf, + ) + ) + + else: + self.failed.append( + ( + "container_links", + f"Unable to connect to {response.url}, status code: {response.status_code}", + self.main_nf, + ) ) - ) # Check that all bioconda packages have build numbers # Also check for newer versions From 1087e8f158c90e34371c31ca8b43cfff2697a28c Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 2 May 2023 15:47:01 +0200 Subject: [PATCH 6/7] only check for url symbols for docker containers url --- nf_core/modules/lint/main_nf.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 5c33d034c3..703dba18a0 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -597,9 +597,5 @@ def _container_type(line): if url_match: return "singularity" return None - if ( - line.startswith("biocontainers/") - or line.startswith("quay.io/") - or (line.count("/") == 1 and line.count(":") == 1) - ): + if line.count("/") >= 1 and line.count(":") == 1: return "docker" From f067e871ea0dec3a3a6c719e85dc0e3d89fd3245 Mon Sep 17 00:00:00 2001 From: Adam Talbot Date: Tue, 2 May 2023 14:48:11 +0100 Subject: [PATCH 7/7] Better error message when unable to connect to container --- nf_core/modules/lint/main_nf.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/nf_core/modules/lint/main_nf.py b/nf_core/modules/lint/main_nf.py index 703dba18a0..102d5ead12 100644 --- a/nf_core/modules/lint/main_nf.py +++ b/nf_core/modules/lint/main_nf.py @@ -332,23 +332,13 @@ def check_process_section(self, lines, fix_version, progress_bar): self.failed.append(("container_links", "Unable to connect to container URL", self.main_nf)) continue if not response.ok: - if response.status_code in [400, 401, 402, 403]: - self.warned.append( - ( - "container_links", - f"Access to container {response.url} denied, status code: {response.status_code}", - self.main_nf, - ) - ) - - else: - self.failed.append( - ( - "container_links", - f"Unable to connect to {response.url}, status code: {response.status_code}", - self.main_nf, - ) + self.failed.append( + ( + "container_links", + f"Unable to connect to {response.url}, status code: {response.status_code}", + self.main_nf, ) + ) # Check that all bioconda packages have build numbers # Also check for newer versions