You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by sr...@apache.org on 2018/06/17 16:24:27 UTC
storm git commit: [STORM-3094] : Added topology name validation at
client side
Repository: storm
Updated Branches:
refs/heads/1.1.x-branch 83bc0f3b7 -> f0a35bd65
[STORM-3094] : Added topology name validation at client side
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/f0a35bd6
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/f0a35bd6
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/f0a35bd6
Branch: refs/heads/1.1.x-branch
Commit: f0a35bd65e7561c234f5a68e5a1fef09fe3297e7
Parents: 83bc0f3
Author: Manohar Vanam <ma...@gmail.com>
Authored: Wed Jun 13 19:38:04 2018 +0530
Committer: Stig Rohde Døssing <sr...@apache.org>
Committed: Sun Jun 17 18:24:14 2018 +0200
----------------------------------------------------------------------
.../src/jvm/org/apache/storm/StormSubmitter.java | 4 +++-
.../jvm/org/apache/storm/blobstore/BlobStore.java | 6 ++----
storm-core/src/jvm/org/apache/storm/utils/Utils.java | 15 +++++++++++++++
3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/f0a35bd6/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
index 86ec6c2..4827dbe 100644
--- a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
+++ b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
@@ -236,7 +236,9 @@ public class StormSubmitter {
if (topologyNameExists(name, client)) {
throw new RuntimeException("Topology with name `" + name + "` already exists on cluster");
}
-
+ if (!Utils.isValidKey(name)) {
+ throw new IllegalArgumentException(name + " does not appear to be a valid topology name.");
+ }
// Dependency uploading only makes sense for distributed mode
List<String> jarsBlobKeys = Collections.emptyList();
List<String> artifactsBlobKeys;
http://git-wip-us.apache.org/repos/asf/storm/blob/f0a35bd6/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
index 92f32ec..b9ab21a 100644
--- a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
+++ b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
@@ -31,7 +31,7 @@ import java.util.regex.Pattern;
import javax.security.auth.Subject;
import org.apache.storm.nimbus.NimbusInfo;
-import org.apache.commons.lang.StringUtils;
+import org.apache.storm.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,7 +61,6 @@ import org.apache.storm.generated.SettableBlobMeta;
*/
public abstract class BlobStore implements Shutdownable {
private static final Logger LOG = LoggerFactory.getLogger(BlobStore.class);
- private static final Pattern KEY_PATTERN = Pattern.compile("^[\\w \\t\\.:_-]+$", Pattern.UNICODE_CHARACTER_CLASS);
protected static final String BASE_BLOBS_DIR_NAME = "blobs";
/**
@@ -194,8 +193,7 @@ public abstract class BlobStore implements Shutdownable {
* @param key Key for the blob.
*/
public static final void validateKey(String key) throws AuthorizationException {
- if (StringUtils.isEmpty(key) || "..".equals(key) || ".".equals(key) || !KEY_PATTERN.matcher(key).matches()) {
- LOG.error("'{}' does not appear to be valid {}", key, KEY_PATTERN);
+ if (!Utils.isValidKey(key)) {
throw new AuthorizationException(key+" does not appear to be a valid blob key");
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/f0a35bd6/storm-core/src/jvm/org/apache/storm/utils/Utils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/Utils.java b/storm-core/src/jvm/org/apache/storm/utils/Utils.java
index b3f4bb7..6a347f9 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/Utils.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/Utils.java
@@ -170,6 +170,7 @@ public class Utils {
public static final boolean IS_ON_WINDOWS = "Windows_NT".equals(System.getenv("OS"));
public static final String FILE_PATH_SEPARATOR = System.getProperty("file.separator");
public static final String CLASS_PATH_SEPARATOR = System.getProperty("path.separator");
+ private static final Pattern TOPOLOGY_KEY_PATTERN = Pattern.compile("^[\\w \\t\\.:_-]+$", Pattern.UNICODE_CHARACTER_CLASS);
public static final int SIGKILL = 9;
public static final int SIGTERM = 15;
@@ -2315,4 +2316,18 @@ public class Utils {
}
return topology;
}
+
+ /**
+ * Validates topology name / blob key.
+ *
+ * @param key topology name / Key for the blob.
+ */
+ public static boolean isValidKey(String key) {
+ if (StringUtils.isEmpty(key) || "..".equals(key) || ".".equals(key) || !TOPOLOGY_KEY_PATTERN.matcher(key).matches()) {
+ LOG.error("'{}' does not appear to be valid. It must match {}. And it can't be \".\", \"..\", null or empty string.", key,
+ TOPOLOGY_KEY_PATTERN);
+ return false;
+ }
+ return true;
+ }
}