summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-04-02 16:37:01 +0200
committerGitHub <noreply@github.com>2022-04-02 16:37:01 +0200
commitd0317f54368c56bcc26758e7e3d11cf79bdd9f91 (patch)
tree0d9b1decd293952442945a987020773122676d1d
parenta4bef5cc8746be403fdb0dbb952e80a2a6db6f33 (diff)
parent2b3c3922531eef06d114191ab1685d663c83301e (diff)
Merge pull request #21954 from vespa-engine/jonmv/require-http
Require HTTP(S) protocol
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java4
-rw-r--r--vespajlib/src/test/java/ai/vespa/validation/NameTest.java4
2 files changed, 4 insertions, 4 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
index b585f7e7e32..8072dab978f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
@@ -16,6 +16,8 @@ import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
+import java.util.List;
+import java.util.Locale;
/**
* @author baldersheim
@@ -96,6 +98,8 @@ public class ApplicationFileManager implements AddFileInterface {
file = new File(tmpDir, path.getRelative());
Files.createDirectories(file.getParentFile().toPath());
URL website = new URL(uri);
+ if ( ! List.of("http", "https").contains(website.getProtocol().toLowerCase(Locale.ROOT)))
+ throw new IllegalArgumentException("only HTTP(S) supported for URI type resources");
rbc = Channels.newChannel(website.openStream());
fos = new FileOutputStream(file);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
diff --git a/vespajlib/src/test/java/ai/vespa/validation/NameTest.java b/vespajlib/src/test/java/ai/vespa/validation/NameTest.java
index 0b50340870e..26a640b0ec0 100644
--- a/vespajlib/src/test/java/ai/vespa/validation/NameTest.java
+++ b/vespajlib/src/test/java/ai/vespa/validation/NameTest.java
@@ -1,12 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.validation;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import java.nio.file.Path;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**