Skip to content

Commit f8ab6c7

Browse files
committed
Merge pull request #3 from ydubreuil/fix-subdirectory-validation
fix subdirectory validation
2 parents 5feb3bf + 84958cc commit f8ab6c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
232232
}
233233

234234
private FilePath getSourceDirectory(FilePath basePath) throws IOException, InterruptedException {
235-
String subdirectory = this.subdirectory.trim().length() > 0 ? this.subdirectory.trim() : "";
235+
String subdirectory = StringUtils.trimToEmpty(this.subdirectory);
236236
if (!subdirectory.isEmpty() && !subdirectory.startsWith("/")) {
237237
subdirectory = "/" + subdirectory;
238238
}
239239
FilePath sourcePath = basePath.withSuffix(subdirectory).absolutize();
240-
File sourceDirectory = new File(sourcePath.getRemote());
241-
if (!sourceDirectory.isDirectory() || !isSubDirectory(basePath, sourcePath)) {
242-
throw new IllegalArgumentException("Provided path is not a subdirectory of the workspace: " + sourcePath );
240+
if (!sourcePath.isDirectory() || !isSubDirectory(basePath, sourcePath)) {
241+
throw new IllegalArgumentException("Provided path (resolved as '" + sourcePath
242+
+"') is not a subdirectory of the workspace (resolved as '" + basePath + "')");
243243
}
244244
return sourcePath;
245245
}

0 commit comments

Comments
 (0)