Skip to content

Commit 375615d

Browse files
committed
Fix alert-156
1 parent 36933bb commit 375615d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/JobsController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public ResponseEntity<StreamingResponseBody> retrieveJobAttachment(
337337
} catch (AuthorizationDeniedException e) {
338338
state = LogEntryState.UNAUTHORIZED;
339339
throw new RESTException(e);
340-
} catch (NotFoundException e) {
340+
} catch (NotFoundException | GenericException e) {
341341
state = LogEntryState.FAILURE;
342342
throw new RESTException(e);
343343
} finally {

roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/JobService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,13 @@ public JobUserDetails buildJobUserDetails(User user) {
243243
return jobUserDetails;
244244
}
245245

246-
public StreamResponse retrieveJobAttachment(String jobId, String attachmentId) throws NotFoundException {
246+
public StreamResponse retrieveJobAttachment(String jobId, String attachmentId) throws NotFoundException, GenericException {
247247
Path filePath = RodaCoreFactory.getJobAttachmentsDirectoryPath().resolve(jobId).resolve(attachmentId);
248+
249+
if (!RodaCoreFactory.getJobAttachmentsDirectoryPath().startsWith(filePath)) {
250+
throw new GenericException("Attempt to retrieve files outside the permitted scope");
251+
}
252+
248253
if (!Files.exists(filePath)) {
249254
throw new NotFoundException();
250255
}

0 commit comments

Comments
 (0)