diff --git a/CHANGELOG.md b/CHANGELOG.md index 22dc797..3bac2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # Version 1.1.4 +## Improvements + +- No longer does false validation on Azure and GCP cloud storage paths ([#171](https://github.com/nextflow-io/nf-validation/pull/171)) + ## Vulnerability fix - Updated the org.json package to version `20240303` ([#172](https://github.com/nextflow-io/nf-validation/pull/172)) diff --git a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/DirectoryPathValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/DirectoryPathValidator.groovy index 0d935b5..1c64a7c 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/DirectoryPathValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/DirectoryPathValidator.groovy @@ -11,8 +11,8 @@ public class DirectoryPathValidator implements FormatValidator { @Override public Optional validate(final String subject) { - if (subject.startsWith('s3://')) { - log.debug("S3 paths are not supported by 'DirectoryPathValidator': '${subject}'") + if (subject.matches("(s3://|az://|gs://).*")) { + log.debug("Cloud storage paths are not supported by 'DirectoryPathValidator': '${subject}'") return Optional.empty() } Path file = Nextflow.file(subject) as Path diff --git a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy index 4ddaaea..84dbf7f 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy @@ -11,8 +11,8 @@ public class FilePathPatternValidator implements FormatValidator { @Override public Optional validate(final String subject) { - if (subject.startsWith('s3://')) { - log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'") + if (subject.matches("(s3://|az://|gs://).*")) { + log.debug("Cloud storage paths are not supported by 'FilePathPatternValidator': '${subject}'") return Optional.empty() } ArrayList files = Nextflow.files(subject) diff --git a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathValidator.groovy index a49ec6c..089e342 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathValidator.groovy @@ -11,8 +11,8 @@ public class FilePathValidator implements FormatValidator { @Override public Optional validate(final String subject) { - if (subject.startsWith('s3://')) { - log.debug("S3 paths are not supported by 'FilePathValidator': '${subject}'") + if (subject.matches("(s3://|az://|gs://).*")) { + log.debug("Cloud storage paths are not supported by 'FilePathValidator': '${subject}'") return Optional.empty() } Path file = Nextflow.file(subject) as Path diff --git a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/PathValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/PathValidator.groovy index afe82e0..800f05b 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/PathValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/FormatValidators/PathValidator.groovy @@ -11,8 +11,8 @@ public class PathValidator implements FormatValidator { @Override public Optional validate(final String subject) { - if (subject.startsWith('s3://')) { - log.debug("S3 paths are not supported by 'PathValidator': '${subject}'") + if (subject.matches("(s3://|az://|gs://).*")) { + log.debug("Cloud storage paths are not supported by 'PathValidator': '${subject}'") return Optional.empty() } Path file = Nextflow.file(subject) as Path diff --git a/plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy b/plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy index 9d70112..9a4c3ec 100644 --- a/plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy +++ b/plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy @@ -615,8 +615,8 @@ class SchemaValidator extends PluginExtensionPoint { // Function to check if a file or directory exists // List pathExists(String path, String paramName, Boolean s3PathCheck) { - if (path.startsWith('s3://') && !s3PathCheck) { - log.debug "Ignoring validation of S3 URL path '${path}'".toString() + if (path.matches("(s3://|az://|gs://).*") && !s3PathCheck) { + log.debug "Ignoring validation of cloud storage path '${path}'".toString() } else { def Path file = Nextflow.file(path) as Path if (!file.exists()) { diff --git a/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF b/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF index 16d6abc..b2fc81c 100644 --- a/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF +++ b/plugins/nf-validation/src/resources/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Plugin-Id: nf-validation -Plugin-Version: 1.1.3 +Plugin-Version: 1.1.4 Plugin-Class: nextflow.validation.ValidationPlugin Plugin-Provider: nextflow Plugin-Requires: >=22.10.0 diff --git a/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy b/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy index 6b66c2a..b5cd882 100644 --- a/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy +++ b/plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy @@ -445,6 +445,72 @@ class PluginExtensionMethodsTest extends Dsl2Spec{ !stdout } + def 'should ignore s3 path' () { + given: + def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString() + def SCRIPT_TEXT = """ + params.input = 's3://fake/path' + include { validateParameters } from 'plugin/nf-validation' + + validateParameters(parameters_schema: '$schema') + """ + + when: + dsl_eval(SCRIPT_TEXT) + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + + def 'should ignore az path' () { + given: + def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString() + def SCRIPT_TEXT = """ + params.input = 'az://fake/path' + include { validateParameters } from 'plugin/nf-validation' + + validateParameters(parameters_schema: '$schema') + """ + + when: + dsl_eval(SCRIPT_TEXT) + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + + def 'should ignore gs path' () { + given: + def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString() + def SCRIPT_TEXT = """ + params.input = 'gs://fake/path' + include { validateParameters } from 'plugin/nf-validation' + + validateParameters(parameters_schema: '$schema') + """ + + when: + dsl_eval(SCRIPT_TEXT) + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + def 'correct validation of numbers with lenient mode' () { given: def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() diff --git a/plugins/nf-validation/src/testResources/nextflow_schema_file_cloud_path.json b/plugins/nf-validation/src/testResources/nextflow_schema_file_cloud_path.json new file mode 100644 index 0000000..69860f0 --- /dev/null +++ b/plugins/nf-validation/src/testResources/nextflow_schema_file_cloud_path.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json", + "title": "nf-core/testpipeline pipeline parameters", + "description": "this is a test", + "type": "object", + "definitions": { + "file_patterns": { + "title": "Input/output options", + "type": "object", + "fa_icon": "fas fa-terminal", + "properties": { + "input": { + "type": "string", + "format": "file-path", + "exists": true + } + } + } + }, + "allOf": [ + { + "$ref": "#/definitions/file_patterns" + } + ] +} \ No newline at end of file