Skip to content

Commit fc72a14

Browse files
committed
Fix #35523: validate app instance name on server
1 parent b98f27a commit fc72a14

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/eu/openanalytics/shinyproxy/AppRequestInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class AppRequestInfo {
2929

3030
private static final Pattern APP_INSTANCE_PATTERN = Pattern.compile(".*?/(app_i|app_direct_i)/([^/]*)/([^/]*)(/?.*)");
3131
private static final Pattern APP_PATTERN = Pattern.compile(".*?/(app|app_direct)/([^/]*)(/?.*)");
32-
private static final Pattern INSTANCE_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_.-]*$");
32+
public static final Pattern INSTANCE_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_.-]*$");
3333

3434
private final String appName;
3535
private final String appInstance;

src/main/java/eu/openanalytics/shinyproxy/controllers/AppController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import java.util.Optional;
8686
import java.util.UUID;
8787

88+
import static eu.openanalytics.shinyproxy.AppRequestInfo.INSTANCE_NAME_PATTERN;
8889
import static org.springframework.web.bind.annotation.RequestMethod.GET;
8990

9091
@Controller
@@ -255,6 +256,11 @@ public ResponseEntity<ApiResponse<Proxy>> startApp(@PathVariable String specId,
255256
if (!userService.canAccess(spec)) {
256257
return ApiResponse.failForbidden();
257258
}
259+
260+
if (appInstanceName.length() > 64 || !INSTANCE_NAME_PATTERN.matcher(appInstanceName).matches()) {
261+
return ApiResponse.fail("Invalid app instance name");
262+
}
263+
258264
Proxy proxy = findUserProxy(specId, appInstanceName);
259265
if (proxy != null) {
260266
return ApiResponse.fail("You already have an instance of this app with the given name");

0 commit comments

Comments
 (0)