Skip to content

Commit

Permalink
hawkbit-ddi-resource: do not log range requests
Browse files Browse the repository at this point in the history
Range requests can be extremely numerous, and logging them is counter
productive. The large number of messages can overflow the action history,
making it nearly useless. Worse this can trigger denial-of-service protection
limits, even on moderate artifact sizes.

Signed-off-by: Zygmunt Krynicki <[email protected]>
  • Loading branch information
zyga committed Sep 26, 2023
1 parent 7d76a5a commit 2f658eb
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public ResponseEntity<InputStream> downloadArtifact(@PathVariable("tenant") fina
final ActionStatus action = checkAndLogDownload(requestResponseContextHolder.getHttpServletRequest(),
target, module.getId());

final Long statusId = action.getId();
final Long statusId = action != null ? action.getId() : Long.valueOf(0);

This comment has been minimized.

Copy link
@avgustinmm

avgustinmm Sep 26, 2023

Contributor

this could lead to incorrect event with action id 0


result = FileStreamingUtil.writeFileResponse(file, artifact.getFilename(), artifact.getCreatedAt(),
requestResponseContextHolder.getHttpServletResponse(),
Expand All @@ -226,13 +226,11 @@ private ActionStatus checkAndLogDownload(final HttpServletRequest request, final
final String range = request.getHeader("Range");

final String message;
if (range != null) {
message = RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target downloads range " + range + " of: "
+ request.getRequestURI();
} else {
message = RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target downloads " + request.getRequestURI();
if (range == null) {

This comment has been minimized.

Copy link
@avgustinmm

avgustinmm Sep 26, 2023

Contributor

shouldn't here be range != null? isn't the purpose to skip range - not the one without range

return null;
}

message = RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target downloads " + request.getRequestURI();
return controllerManagement.addInformationalActionStatus(
entityFactory.actionStatus().create(action.getId()).status(Status.DOWNLOAD).message(message));
}
Expand Down

0 comments on commit 2f658eb

Please sign in to comment.