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 authored and Luke-Sikina committed Jan 18, 2024
1 parent 4eca259 commit 269dea3
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 269dea3

Please sign in to comment.