You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2022/01/05 14:04:31 UTC
[unomi] branch addValidationOnFileName created (now ddfa7da)
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a change to branch addValidationOnFileName
in repository https://gitbox.apache.org/repos/asf/unomi.git.
at ddfa7da UNOMI-543: add validation on importConfigId for ImportConfigurationServiceEndPoint
This branch includes the following new commits:
new ddfa7da UNOMI-543: add validation on importConfigId for ImportConfigurationServiceEndPoint
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[unomi] 01/01: UNOMI-543: add validation on importConfigId for ImportConfigurationServiceEndPoint
Posted by jk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch addValidationOnFileName
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit ddfa7da97d622801bbe98d840ebf53b168bbd480
Author: Kevan <ke...@jahia.com>
AuthorDate: Wed Jan 5 15:04:16 2022 +0100
UNOMI-543: add validation on importConfigId for ImportConfigurationServiceEndPoint
---
extensions/router/router-rest/pom.xml | 5 +++++
.../unomi/router/rest/ImportConfigurationServiceEndPoint.java | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/extensions/router/router-rest/pom.xml b/extensions/router/router-rest/pom.xml
index ce55a80..2216a00 100644
--- a/extensions/router/router-rest/pom.xml
+++ b/extensions/router/router-rest/pom.xml
@@ -85,6 +85,11 @@
<artifactId>osgi.cmpn</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
index a21404b..ad943e9 100644
--- a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
+++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
@@ -20,6 +20,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
import org.apache.unomi.api.services.ConfigSharingService;
+import org.apache.unomi.api.utils.ValidationPattern;
import org.apache.unomi.router.api.ImportConfiguration;
import org.apache.unomi.router.api.RouterConstants;
import org.apache.unomi.router.api.services.ImportExportConfigurationService;
@@ -30,6 +31,8 @@ import org.slf4j.LoggerFactory;
import javax.jws.WebMethod;
import javax.jws.WebService;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -106,7 +109,8 @@ public class ImportConfigurationServiceEndPoint extends AbstractConfigurationSer
@Path("/oneshot")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
- public Response processOneshotImportConfigurationCSV(@Multipart(value = "importConfigId") String importConfigId, @Multipart(value = "file") Attachment file) {
+ public Response processOneshotImportConfigurationCSV(@Multipart(value = "importConfigId") @NotNull @Pattern(regexp = "^[a-zA-Z0-9_.\\-]{1,255}$") String importConfigId,
+ @Multipart(value = "file") Attachment file) {
try {
java.nio.file.Path path = Paths.get(configSharingService.getProperty(RouterConstants.IMPORT_ONESHOT_UPLOAD_DIR) + importConfigId + ".csv");
Files.deleteIfExists(path);