diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/HammerHead.java b/webgoat-container/src/main/java/org/owasp/webgoat/HammerHead.java index 3e273d023..144899c78 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/HammerHead.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/HammerHead.java @@ -11,6 +11,7 @@ import org.owasp.webgoat.session.WebSession; import org.owasp.webgoat.session.WebgoatContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -249,7 +250,7 @@ public class HammerHead extends HttpServlet { logger.info("Initializing main webgoat servlet"); httpDateFormat = new SimpleDateFormat("EEE, dd MMM yyyyy HH:mm:ss z", Locale.US); httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - propertiesPath = getServletContext().getRealPath("/WEB-INF/webgoat.properties"); + propertiesPath = new ClassPathResource("/WEB-INF/webgoat.properties").getPath(); } /** diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/service/LabelDebugService.java b/webgoat-container/src/main/java/org/owasp/webgoat/service/LabelDebugService.java index 937e11a33..56ddd69e0 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/service/LabelDebugService.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/service/LabelDebugService.java @@ -29,9 +29,6 @@ */ package org.owasp.webgoat.service; -import java.util.HashMap; -import java.util.Map; - import org.owasp.webgoat.session.LabelDebugger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,6 +41,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.HashMap; +import java.util.Map; + /** *

LabelDebugService class.

* @@ -73,7 +73,7 @@ public class LabelDebugService extends BaseService { ResponseEntity> checkDebuggingStatus() { logger.debug("Checking label debugging, it is " + labelDebugger.isEnabled()); // FIXME parameterize Map result = createResponse(labelDebugger.isEnabled()); - return new ResponseEntity>(result, HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } /** @@ -88,7 +88,7 @@ public class LabelDebugService extends BaseService { logger.debug("Setting label debugging to " + labelDebugger.isEnabled()); // FIXME parameterize Map result = createResponse(enabled); labelDebugger.setEnabled(enabled); - return new ResponseEntity>(result, HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } /** diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/service/PluginReloadService.java b/webgoat-container/src/main/java/org/owasp/webgoat/service/PluginReloadService.java index b1643b157..f5b53eae8 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/service/PluginReloadService.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/service/PluginReloadService.java @@ -29,13 +29,6 @@ */ package org.owasp.webgoat.service; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpSession; - -import org.owasp.webgoat.plugins.PluginsLoader; import org.owasp.webgoat.session.WebSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +39,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import javax.servlet.http.HttpSession; +import java.util.HashMap; +import java.util.Map; + /** *

PluginReloadService class.

* @@ -71,12 +68,12 @@ public class PluginReloadService extends BaseService { logger.debug("Loading plugins into cache"); String pluginPath = session.getServletContext().getRealPath("plugin_lessons"); String targetPath = session.getServletContext().getRealPath("plugin_extracted"); - new PluginsLoader(Paths.get(pluginPath), Paths.get(targetPath)).copyJars(); + //new PluginsLoader(Paths.get(pluginPath), Paths.get(targetPath)).copyJars(); webSession.getCourse().loadLessonFromPlugin(session.getServletContext()); Map result = new HashMap(); result.put("success", true); result.put("message", "Plugins reloaded"); - return new ResponseEntity>(result, HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } } diff --git a/webgoat-container/src/main/resources/application.properties b/webgoat-container/src/main/resources/application.properties index edcc9ea01..ab0938190 100644 --- a/webgoat-container/src/main/resources/application.properties +++ b/webgoat-container/src/main/resources/application.properties @@ -5,7 +5,7 @@ #server.jsp-servlet.registered=true server.error.include-stacktrace=always -logging.level.org.springframework=DEBUG +logging.level.org.springframework=INFO logging.level.org.hibernate=ERROR spring.thymeleaf.cache=false security.enable-csrf=false diff --git a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js index 023a1ebec..17f77bbab 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js @@ -11,6 +11,7 @@ define(['jquery', 'goatApp/view/CookieView', 'goatApp/view/ParamView', 'goatApp/model/ParamModel', + 'goatApp/view/DeveloperControlsView', 'goatApp/support/GoatUtils', 'goatApp/view/UserAndInfoView', 'goatApp/view/MenuButtonView', @@ -32,6 +33,7 @@ define(['jquery', CookieView, ParamView, ParamModel, + DeveloperControlsView, GoatUtils, UserAndInfoView, MenuButtonView, @@ -49,6 +51,7 @@ define(['jquery', this.lessonProgressModel = new LessonProgressModel(); this.lessonProgressView = new LessonProgressView(this.lessonProgressModel); this.lessonView = options.lessonView; + this.developerControlsView = new DeveloperControlsView(); _.extend(Controller.prototype,Backbone.Events); @@ -103,6 +106,7 @@ define(['jquery', this.listenTo(this.helpControlsView,'hints:show',this.onShowHints) this.listenTo(this.helpControlsView,'source:show',this.hideShowHelps); this.listenTo(this.helpControlsView,'lesson:restart',this.restartLesson); + this.listenTo(this.developerControlsView, 'dev:labels', this.restartLesson); this.helpControlsView.render(); @@ -124,6 +128,7 @@ define(['jquery', this.lessonHintView = new HintView(); this.cookieView = new CookieView(); + //TODO: instantiate model with values (not sure why was not working before) var paramModel = new ParamModel({}); paramModel.set('scrParam',this.lessonContent.get('scrParam')); diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/DeveloperControlsView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/DeveloperControlsView.js index ddd8b9f2d..ffd66bc9d 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/DeveloperControlsView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/DeveloperControlsView.js @@ -24,7 +24,7 @@ function( onLabelsLoaded: function(model) { this.models[1] = model; this.render(); - Backbone.history.loadUrl(Backbone.history.getFragment()); + this.trigger('dev:labels') }, initialize: function(options) { diff --git a/webgoat-container/src/main/resources/templates/main_new.html b/webgoat-container/src/main/resources/templates/main_new.html index 6c0a661ac..b8cd94238 100644 --- a/webgoat-container/src/main/resources/templates/main_new.html +++ b/webgoat-container/src/main/resources/templates/main_new.html @@ -41,7 +41,7 @@