From e5d5a370f966d034a8efb4dc4e08819882477fdb Mon Sep 17 00:00:00 2001 From: Nanne Baars Date: Sun, 27 Oct 2024 07:49:37 +0100 Subject: [PATCH] fix: use banners correctly --- .../owasp/webgoat/server/ParentConfig.java | 2 -- .../owasp/webgoat/server/StartWebGoat.java | 20 +++++++++++++------ .../resources/application-webgoat.properties | 1 - src/main/resources/banner-webgoat.txt | 5 +++++ src/main/resources/banner-webwolf.txt | 5 +++++ src/main/resources/banner.txt | 6 ------ 6 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 src/main/resources/banner-webgoat.txt create mode 100644 src/main/resources/banner-webwolf.txt delete mode 100644 src/main/resources/banner.txt diff --git a/src/main/java/org/owasp/webgoat/server/ParentConfig.java b/src/main/java/org/owasp/webgoat/server/ParentConfig.java index b4a62db4d..b089df1cc 100644 --- a/src/main/java/org/owasp/webgoat/server/ParentConfig.java +++ b/src/main/java/org/owasp/webgoat/server/ParentConfig.java @@ -1,8 +1,6 @@ package org.owasp.webgoat.server; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.owasp.webgoat.server") public class ParentConfig {} diff --git a/src/main/java/org/owasp/webgoat/server/StartWebGoat.java b/src/main/java/org/owasp/webgoat/server/StartWebGoat.java index 2e87ef20e..070eb936a 100644 --- a/src/main/java/org/owasp/webgoat/server/StartWebGoat.java +++ b/src/main/java/org/owasp/webgoat/server/StartWebGoat.java @@ -29,22 +29,30 @@ import lombok.extern.slf4j.Slf4j; import org.owasp.webgoat.container.WebGoat; import org.owasp.webgoat.webwolf.WebWolf; import org.springframework.boot.Banner; +import org.springframework.boot.ResourceBanner; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ApplicationContext; +import org.springframework.core.io.ClassPathResource; @Slf4j public class StartWebGoat { public static void main(String[] args) { var parentBuilder = - new SpringApplicationBuilder() - .parent(ParentConfig.class) - .web(WebApplicationType.NONE) - .bannerMode(Banner.Mode.OFF); - parentBuilder.child(WebWolf.class).web(WebApplicationType.SERVLET).run(args); + new SpringApplicationBuilder().parent(ParentConfig.class).web(WebApplicationType.NONE); + parentBuilder + .child(WebWolf.class) + .banner(new ResourceBanner(new ClassPathResource("banner-webwolf.txt"))) + .web(WebApplicationType.SERVLET) + .run(args); + ApplicationContext webGoatContext = - parentBuilder.child(WebGoat.class).web(WebApplicationType.SERVLET).run(args); + parentBuilder + .child(WebGoat.class) + .banner(new ResourceBanner(new ClassPathResource("banner-webgoat.txt"))) + .web(WebApplicationType.SERVLET) + .run(args); printStartUpMessage(webGoatContext); } diff --git a/src/main/resources/application-webgoat.properties b/src/main/resources/application-webgoat.properties index 75882caef..3f0cc004a 100644 --- a/src/main/resources/application-webgoat.properties +++ b/src/main/resources/application-webgoat.properties @@ -15,7 +15,6 @@ server.ssl.key-store-password=${WEBGOAT_KEYSTORE_PASSWORD:password} server.ssl.key-alias=${WEBGOAT_KEY_ALIAS:goat} server.ssl.enabled=${WEBGOAT_SSLENABLED:false} -spring.banner.location=classpath:banner.txt spring.datasource.url=jdbc:hsqldb:file:${webgoat.server.directory}/webgoat spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver spring.jpa.open-in-view=false diff --git a/src/main/resources/banner-webgoat.txt b/src/main/resources/banner-webgoat.txt new file mode 100644 index 000000000..f9bf062cc --- /dev/null +++ b/src/main/resources/banner-webgoat.txt @@ -0,0 +1,5 @@ + __ __ _ ____ _ + \ \ / /__| |__ / ___| ___ __ _| |_ + \ \ /\ / / _ \ '_ \| | _ / _ \ / _` | __| + \ V V / __/ |_) | |_| | (_) | (_| | |_ + \_/\_/ \___|_.__/ \____|\___/ \__,_|\__| diff --git a/src/main/resources/banner-webwolf.txt b/src/main/resources/banner-webwolf.txt new file mode 100644 index 000000000..52dbf768c --- /dev/null +++ b/src/main/resources/banner-webwolf.txt @@ -0,0 +1,5 @@ + __ __ _ __ __ _ __ + \ \ / /__| |_\ \ / /__ | |/ _| + \ \ /\ / / _ \ '_ \ \ /\ / / _ \| | |_ + \ V V / __/ |_) \ V V / (_) | | _| + \_/\_/ \___|_.__/ \_/\_/ \___/|_|_| diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt deleted file mode 100644 index 4afc67dea..000000000 --- a/src/main/resources/banner.txt +++ /dev/null @@ -1,6 +0,0 @@ - __ __ _ _____ _ - \ \ / / | | / ____| | | - \ \ /\ / / ___ | |__ | | __ ___ __ _ | |_ - \ \/ \/ / / _ \ | '_ \ | | |_ | / _ \ / _' | | __| - \ /\ / | __/ | |_) | | |__| | | (_) | | (_| | | |_ - \/ \/ \___| |_.__/ \_____| \___/ \__,_| \__|