From e9ad20cb30fee68c93ef3146c68a72dbeee06e5e Mon Sep 17 00:00:00 2001 From: Nanne Baars Date: Thu, 15 Jun 2017 19:06:50 +0200 Subject: [PATCH] Make sure we clean all the files below the .webgoat dir --- .../java/org/owasp/webgoat/CleanupLocalProgressFiles.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/CleanupLocalProgressFiles.java b/webgoat-container/src/main/java/org/owasp/webgoat/CleanupLocalProgressFiles.java index 6e9e89985..d0667fd9f 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/CleanupLocalProgressFiles.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/CleanupLocalProgressFiles.java @@ -24,6 +24,10 @@ public class CleanupLocalProgressFiles { @PostConstruct public void clean() { File dir = new File(webgoatHome); - FileSystemUtils.deleteRecursively(dir); + //do it safe, check whether the subdir mongodb is available as subdirectory + File[] mongoDir = dir.listFiles(f -> f.isDirectory() && f.getName().contains("mongodb")); + if (mongoDir != null && mongoDir.length == 1) { + FileSystemUtils.deleteRecursively(dir); + } } }