Added the ability to remove all *.progress files when starting the server (for development). This is sometimes necessary when the internal structure of the lessons change but we still use old progress files.
This commit is contained in:
parent
eb13ebc26f
commit
6f633a0f78
@ -0,0 +1,36 @@
|
|||||||
|
package org.owasp.webgoat;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author nbaars
|
||||||
|
* @since 4/15/17.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnExpression("'${webgoat.clean}' == 'true'")
|
||||||
|
public class CleanupLocalProgressFiles {
|
||||||
|
|
||||||
|
@Value("${webgoat.server.directory}")
|
||||||
|
private String webgoatHome;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void clean() {
|
||||||
|
File dir = new File(webgoatHome);
|
||||||
|
if (dir.exists()) {
|
||||||
|
File[] progressFiles = dir.listFiles(f -> f.getName().endsWith(".progress"));
|
||||||
|
if (progressFiles != null) {
|
||||||
|
log.info("Removing stored user preferences...");
|
||||||
|
for (File f : progressFiles) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ security.enable-csrf=false
|
|||||||
spring.resources.cache-period=0
|
spring.resources.cache-period=0
|
||||||
spring.thymeleaf.cache=false
|
spring.thymeleaf.cache=false
|
||||||
|
|
||||||
|
webgoat.clean=true
|
||||||
webgoat.server.directory=${user.home}/.webgoat/
|
webgoat.server.directory=${user.home}/.webgoat/
|
||||||
webgoat.user.directory=${user.home}/.webgoat/
|
webgoat.user.directory=${user.home}/.webgoat/
|
||||||
webgoat.build.version=@project.version@
|
webgoat.build.version=@project.version@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user