summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-10-21 16:16:06 -0400
committerDan Timoney <dtimoney@att.com>2020-10-21 16:16:06 -0400
commitdc2682a99d1ac34ef36730220df1e4e806d48027 (patch)
tree348e4a46728e3279f2b0ea29e5a7c1898332b6b6
parentc72e5c56a6c05d3dd8acb71ff4525be4d6af7173 (diff)
Fix pattern validation
Pattern validation incorrectly disallows period as part of file name Change-Id: I3b3692093e16c41c312b326246a5dee83f674ee0 Issue-ID: CCSDK-2918 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rwxr-xr-xutils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java2
-rw-r--r--utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java6
2 files changed, 4 insertions, 4 deletions
diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java
index 29d35d6ef..518fb30d3 100755
--- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java
+++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java
@@ -62,7 +62,7 @@ public abstract class EnvVarFileResolver implements PropertiesFileResolver {
final File fileFromEnvVariable;
if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) {
fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile();
- if(PathValidator.isValidFilePath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) {
+ if(PathValidator.isValidPropertiesPath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) {
return Optional.of(fileFromEnvVariable);
}
}
diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java
index 973525019..08f0fc050 100644
--- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java
+++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java
@@ -3,15 +3,15 @@ import java.util.regex.Pattern;
public class PathValidator {
public static boolean isValidXmlPath(String path) {
- Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.xml$");
+ Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.xml$");
return (allowList.matcher(path).matches());
}
public static boolean isValidPropertiesPath(String path) {
- Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.properties$");
+ Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.properties$");
return (allowList.matcher(path).matches());
}
public static boolean isValidFilePath(String path) {
- Pattern allowList = Pattern.compile("[-\\w/\\/]+");
+ Pattern allowList = Pattern.compile("[-.\\w/\\/]+$");
return (allowList.matcher(path).matches());
}
}