Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 750a56d

Browse files
authored
Merge pull request #171 from adamrtalbot/do_not_validate_az_and_gcp_paths
Does not validate Azure or Google blob storage
2 parents 0edaedf + 1a93ea9 commit 750a56d

File tree

9 files changed

+107
-11
lines changed

9 files changed

+107
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# Version 1.1.4
44

5+
## Improvements
6+
7+
- No longer does false validation on Azure and GCP cloud storage paths ([#171](https://github.com/nextflow-io/nf-validation/pull/171))
8+
59
## Vulnerability fix
610

711
- Updated the org.json package to version `20240303` ([#172](https://github.com/nextflow-io/nf-validation/pull/172))

plugins/nf-validation/src/main/nextflow/validation/FormatValidators/DirectoryPathValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class DirectoryPathValidator implements FormatValidator {
1111

1212
@Override
1313
public Optional<String> validate(final String subject) {
14-
if (subject.startsWith('s3://')) {
15-
log.debug("S3 paths are not supported by 'DirectoryPathValidator': '${subject}'")
14+
if (subject.matches("(s3://|az://|gs://).*")) {
15+
log.debug("Cloud storage paths are not supported by 'DirectoryPathValidator': '${subject}'")
1616
return Optional.empty()
1717
}
1818
Path file = Nextflow.file(subject) as Path

plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class FilePathPatternValidator implements FormatValidator {
1111

1212
@Override
1313
public Optional<String> validate(final String subject) {
14-
if (subject.startsWith('s3://')) {
15-
log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'")
14+
if (subject.matches("(s3://|az://|gs://).*")) {
15+
log.debug("Cloud storage paths are not supported by 'FilePathPatternValidator': '${subject}'")
1616
return Optional.empty()
1717
}
1818
ArrayList files = Nextflow.files(subject)

plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class FilePathValidator implements FormatValidator {
1111

1212
@Override
1313
public Optional<String> validate(final String subject) {
14-
if (subject.startsWith('s3://')) {
15-
log.debug("S3 paths are not supported by 'FilePathValidator': '${subject}'")
14+
if (subject.matches("(s3://|az://|gs://).*")) {
15+
log.debug("Cloud storage paths are not supported by 'FilePathValidator': '${subject}'")
1616
return Optional.empty()
1717
}
1818
Path file = Nextflow.file(subject) as Path

plugins/nf-validation/src/main/nextflow/validation/FormatValidators/PathValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class PathValidator implements FormatValidator {
1111

1212
@Override
1313
public Optional<String> validate(final String subject) {
14-
if (subject.startsWith('s3://')) {
15-
log.debug("S3 paths are not supported by 'PathValidator': '${subject}'")
14+
if (subject.matches("(s3://|az://|gs://).*")) {
15+
log.debug("Cloud storage paths are not supported by 'PathValidator': '${subject}'")
1616
return Optional.empty()
1717
}
1818
Path file = Nextflow.file(subject) as Path

plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ class SchemaValidator extends PluginExtensionPoint {
615615
// Function to check if a file or directory exists
616616
//
617617
List pathExists(String path, String paramName, Boolean s3PathCheck) {
618-
if (path.startsWith('s3://') && !s3PathCheck) {
619-
log.debug "Ignoring validation of S3 URL path '${path}'".toString()
618+
if (path.matches("(s3://|az://|gs://).*") && !s3PathCheck) {
619+
log.debug "Ignoring validation of cloud storage path '${path}'".toString()
620620
} else {
621621
def Path file = Nextflow.file(path) as Path
622622
if (!file.exists()) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Plugin-Id: nf-validation
3-
Plugin-Version: 1.1.3
3+
Plugin-Version: 1.1.4
44
Plugin-Class: nextflow.validation.ValidationPlugin
55
Plugin-Provider: nextflow
66
Plugin-Requires: >=22.10.0

plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,72 @@ class PluginExtensionMethodsTest extends Dsl2Spec{
445445
!stdout
446446
}
447447

448+
def 'should ignore s3 path' () {
449+
given:
450+
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
451+
def SCRIPT_TEXT = """
452+
params.input = 's3://fake/path'
453+
include { validateParameters } from 'plugin/nf-validation'
454+
455+
validateParameters(parameters_schema: '$schema')
456+
"""
457+
458+
when:
459+
dsl_eval(SCRIPT_TEXT)
460+
def stdout = capture
461+
.toString()
462+
.readLines()
463+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
464+
465+
then:
466+
noExceptionThrown()
467+
!stdout
468+
}
469+
470+
def 'should ignore az path' () {
471+
given:
472+
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
473+
def SCRIPT_TEXT = """
474+
params.input = 'az://fake/path'
475+
include { validateParameters } from 'plugin/nf-validation'
476+
477+
validateParameters(parameters_schema: '$schema')
478+
"""
479+
480+
when:
481+
dsl_eval(SCRIPT_TEXT)
482+
def stdout = capture
483+
.toString()
484+
.readLines()
485+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
486+
487+
then:
488+
noExceptionThrown()
489+
!stdout
490+
}
491+
492+
def 'should ignore gs path' () {
493+
given:
494+
def schema = Path.of('src/testResources/nextflow_schema_file_cloud_path.json').toAbsolutePath().toString()
495+
def SCRIPT_TEXT = """
496+
params.input = 'gs://fake/path'
497+
include { validateParameters } from 'plugin/nf-validation'
498+
499+
validateParameters(parameters_schema: '$schema')
500+
"""
501+
502+
when:
503+
dsl_eval(SCRIPT_TEXT)
504+
def stdout = capture
505+
.toString()
506+
.readLines()
507+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
508+
509+
then:
510+
noExceptionThrown()
511+
!stdout
512+
}
513+
448514
def 'correct validation of numbers with lenient mode' () {
449515
given:
450516
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
4+
"title": "nf-core/testpipeline pipeline parameters",
5+
"description": "this is a test",
6+
"type": "object",
7+
"definitions": {
8+
"file_patterns": {
9+
"title": "Input/output options",
10+
"type": "object",
11+
"fa_icon": "fas fa-terminal",
12+
"properties": {
13+
"input": {
14+
"type": "string",
15+
"format": "file-path",
16+
"exists": true
17+
}
18+
}
19+
}
20+
},
21+
"allOf": [
22+
{
23+
"$ref": "#/definitions/file_patterns"
24+
}
25+
]
26+
}

0 commit comments

Comments
 (0)