From 8d783f365d820141bdb01aeecb6cdab899d044a9 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Mon, 20 Jan 2020 13:27:05 +0100 Subject: Require scheme and host as well --- .../controller/api/integration/deployment/ApplicationVersion.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java index 685eed22699..816d647dfbb 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java @@ -51,7 +51,10 @@ public class ApplicationVersion implements Comparable { if (commit.isPresent() && commit.get().length() > 128) throw new IllegalArgumentException("Commit may not be longer than 128 characters"); - sourceUrl.map(URI::create); + sourceUrl.map(URI::create).ifPresent(url -> { + if (url.getHost() == null || url.getScheme() == null) + throw new IllegalArgumentException("Source URL must include scheme and host"); + }); if (authorEmail.isPresent() && ! authorEmail.get().matches("[^@]+@[^@]+")) throw new IllegalArgumentException("Invalid author email '" + authorEmail.get() + "'."); -- cgit v1.2.3 From a737add463949a9e59754af5f5982121f5e606a5 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Mon, 20 Jan 2020 13:40:57 +0100 Subject: Move verification to handler, only for explicit URLs --- .../controller/api/integration/deployment/ApplicationVersion.java | 5 ----- .../hosted/controller/restapi/application/ApplicationApiHandler.java | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java index 816d647dfbb..bbe533db9b5 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java @@ -51,11 +51,6 @@ public class ApplicationVersion implements Comparable { if (commit.isPresent() && commit.get().length() > 128) throw new IllegalArgumentException("Commit may not be longer than 128 characters"); - sourceUrl.map(URI::create).ifPresent(url -> { - if (url.getHost() == null || url.getScheme() == null) - throw new IllegalArgumentException("Source URL must include scheme and host"); - }); - if (authorEmail.isPresent() && ! authorEmail.get().matches("[^@]+@[^@]+")) throw new IllegalArgumentException("Invalid author email '" + authorEmail.get() + "'."); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 0c0b1f67b90..6db665ae143 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -1998,6 +1998,11 @@ public class ApplicationApiHandler extends LoggingRequestHandler { Optional sourceUrl = optional("sourceUrl", submitOptions); Optional authorEmail = optional("authorEmail", submitOptions); + sourceUrl.map(URI::create).ifPresent(url -> { + if (url.getHost() == null || url.getScheme() == null) + throw new IllegalArgumentException("Source URL must include scheme and host"); + }); + ApplicationPackage applicationPackage = new ApplicationPackage(dataParts.get(EnvironmentResource.APPLICATION_ZIP), true); controller.applications().verifyApplicationIdentityConfiguration(TenantName.from(tenant), -- cgit v1.2.3