From d8e8275fbc9c8cbcffbf06297e2ec7a98989c865 Mon Sep 17 00:00:00 2001 From: bhou Date: Tue, 7 May 2024 10:44:49 -0700 Subject: [PATCH] Amend the check on IllegalAttachmentFileNameException --- .../services/impl/LocalFileSystemAttachmentServiceImpl.java | 4 ++-- .../impl/LocalFileSystemAttachmentServiceImplSpec.groovy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/genie-web/src/main/java/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImpl.java b/genie-web/src/main/java/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImpl.java index d6cf472412..1ff416a8b4 100644 --- a/genie-web/src/main/java/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImpl.java +++ b/genie-web/src/main/java/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImpl.java @@ -97,9 +97,9 @@ public Set saveAttachments( if (filename != null) { if ((filename.contains("/") || filename.contains("\\") - || filename.equals(".") || filename.equals(".."))) { + || filename.equals(".") || filename.contains(".."))) { throw new IllegalAttachmentFileNameException("Attachment filename " + filename + " is illegal. " - + "Filenames should not be . or .., or contain /, \\."); + + "Filenames should not be ., or contain .., /, \\."); } final String attachmentCanonicalPath = diff --git a/genie-web/src/test/groovy/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImplSpec.groovy b/genie-web/src/test/groovy/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImplSpec.groovy index 5cfdc0cd9e..16e855325e 100644 --- a/genie-web/src/test/groovy/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImplSpec.groovy +++ b/genie-web/src/test/groovy/com/netflix/genie/web/services/impl/LocalFileSystemAttachmentServiceImplSpec.groovy @@ -193,7 +193,7 @@ class LocalFileSystemAttachmentServiceImplSpec extends Specification { thrown(IllegalAttachmentFileNameException) } - def "reject attachments with illegal filename is .."() { + def "reject attachments with illegal filename containing .."() { Set attachments = new HashSet() Resource attachment = Mockito.mock(Resource.class) Mockito.doReturn("..").when(attachment).getFilename()