Skip to content

Commit

Permalink
Restrict User Input
Browse files Browse the repository at this point in the history
  • Loading branch information
knoppiks committed Jul 11, 2024
1 parent 6420955 commit b13a447
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public TransferProcessController(
this.processes = processes;
}

@PostMapping(value = "/{project:\\w+}/start")
@PostMapping(value = "/{project:[\\w-]+}/start")
Mono<ResponseEntity<Object>> start(
@PathVariable("project") String project, UriComponentsBuilder uriBuilder) {
var process = findProcess(project);
Expand All @@ -48,7 +48,7 @@ Mono<ResponseEntity<Object>> start(
} else {
log.warn("Project '{}' not found", project);

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1).
return internalServerError(
new IllegalStateException("Project %s could not be found".formatted(project)));
new IllegalStateException("Project '%s' could not be found".formatted(project)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void startNonExistingProjectErrors() {
ResponseEntity.of(
ProblemDetail.forStatusAndDetail(
HttpStatus.INTERNAL_SERVER_ERROR,
"Project non-existent could not be found"))
"Project 'non-existent' could not be found"))
.build())
.verifyComplete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void invalidProject() {
c.bodyToMono(ProblemDetail.class)
.flatMap(p -> Mono.error(new IllegalStateException(p.getDetail()))))
.toBodilessEntity())
.expectErrorMessage("Project non-existent could not be found")
.expectErrorMessage("Project 'non-existent' could not be found")
.verifyThenAssertThat()
.hasOperatorErrors();
}
Expand Down

0 comments on commit b13a447

Please sign in to comment.