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); + } } }