Skip to content

Commit

Permalink
Fix path traversal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Jan 16, 2024
1 parent 4eca259 commit 86e3439
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,24 @@ public Response queryResult(@PathParam("resourceQueryId") UUID queryId, QueryReq
}
}

private Optional<String> roundTripUUID(String uuid) {
try {
return Optional.ofNullable(UUID.fromString(uuid).toString());
} catch (IllegalArgumentException ignored) {
return Optional.empty();
}
}

@POST
@Path("/write/{dataType}")
public Response writeQueryResult(
@RequestBody() Query query, @PathParam("dataType") String datatype
) {
if (roundTripUUID(query.getPicSureId()).map(id -> id.equalsIgnoreCase(query.getPicSureId())).orElse(false)) {
return Response
.status(400, "The query pic-sure ID is not a UUID")
.build();
}
if (query.getExpectedResultType() != ResultType.DATAFRAME_TIMESERIES) {
return Response
.status(400, "The write endpoint only writes time series dataframes. Fix result type.")
Expand Down

0 comments on commit 86e3439

Please sign in to comment.