diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java b/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java index 514492360..1c949c85e 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java @@ -71,6 +71,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter { registry.addViewController("/login").setViewName("login"); registry.addViewController("/lesson_content").setViewName("lesson_content"); registry.addViewController("/start.mvc").setViewName("main_new"); + registry.addViewController("/scoreboard").setViewName("scoreboard"); } diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/users/Scoreboard.java b/webgoat-container/src/main/java/org/owasp/webgoat/users/Scoreboard.java index 4df198dcb..1b08e35bc 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/users/Scoreboard.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/users/Scoreboard.java @@ -33,7 +33,7 @@ public class Scoreboard { private List flagsCaptured; } - @GetMapping("/scoreboard") + @GetMapping("/scoreboard-data") public List getRankings() { List allUsers = userRepository.findAll(); List rankings = Lists.newArrayList(); 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 a4b93ff18..47682a354 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 @@ -8,7 +8,6 @@ define(['jquery', 'goatApp/view/SolutionView', 'goatApp/view/HintView', 'goatApp/view/HelpControlsView', - 'goatApp/view/CookieView', 'goatApp/view/ParamView', 'goatApp/model/ParamModel', 'goatApp/view/DeveloperControlsView', @@ -32,7 +31,6 @@ define(['jquery', SolutionView, HintView, HelpControlsView, - CookieView, ParamView, ParamModel, DeveloperControlsView, @@ -130,7 +128,6 @@ define(['jquery', this.solutionView = new SolutionView(); this.sourceView = new SourceView(); this.lessonHintView = new HintView(); - this.cookieView = new CookieView(); //TODO: instantiate model with values (not sure why was not working before) var paramModel = new ParamModel({}); diff --git a/webgoat-container/src/main/resources/static/js/goatApp/model/CookieModel.js b/webgoat-container/src/main/resources/static/js/goatApp/model/FlagModel.js similarity index 100% rename from webgoat-container/src/main/resources/static/js/goatApp/model/CookieModel.js rename to webgoat-container/src/main/resources/static/js/goatApp/model/FlagModel.js diff --git a/webgoat-container/src/main/resources/static/js/goatApp/model/CookieCollection.js b/webgoat-container/src/main/resources/static/js/goatApp/model/FlagsCollection.js similarity index 55% rename from webgoat-container/src/main/resources/static/js/goatApp/model/CookieCollection.js rename to webgoat-container/src/main/resources/static/js/goatApp/model/FlagsCollection.js index ae3ed023a..8832310a3 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/model/CookieCollection.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/model/FlagsCollection.js @@ -1,13 +1,13 @@ define(['jquery', 'underscore', 'backbone', - 'goatApp/model/CookieModel'], + 'goatApp/model/FlagModel'], function($, _, Backbone, - CookieModel) { + FlagModel) { return Backbone.Collection.extend({ - url:'service/cookie.mvc', - model:CookieModel + url:'/WebGoat/scoreboard-data', + model:FlagModel }); }); \ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/goatApp/scoreboardApp.js b/webgoat-container/src/main/resources/static/js/goatApp/scoreboardApp.js new file mode 100644 index 000000000..d47bd0b60 --- /dev/null +++ b/webgoat-container/src/main/resources/static/js/goatApp/scoreboardApp.js @@ -0,0 +1,17 @@ +define(['jquery', + 'underscore', + 'backbone', + 'goatApp/support/goatAsyncErrorHandler', + 'goatApp/view/ScoreboardView'], + function ($, + _, + Backbone, + asyncErrorHandler, + ScoreboardView) { + 'use strict' + return { + initApp: function () { + scoreboard = new ScoreboardView(); + } + }; + }); \ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/CookieView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/CookieView.js deleted file mode 100644 index 106b6f952..000000000 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/CookieView.js +++ /dev/null @@ -1,34 +0,0 @@ -define(['jquery', - 'underscore', - 'backbone', - 'goatApp/model/CookieCollection'], -function($, - _, - Backbone, - CookieCollection) { - return Backbone.View.extend({ - el:'#cookies-view', - - initialize: function() { - this.collection = new CookieCollection(); - this.listenTo(this.collection,'reset',this.render) - this.collection.fetch({reset:true}); - }, - - render: function() { - this.$el.html('') - var cookieTable; - this.collection.each(function(model) { - cookieTable = $('',{'class':'cookie-table table-striped table-nonfluid'}); - _.each(model.keys(), function(attribute) { - var newRow = $(''); - newRow.append($('
',{text:_.escape(attribute)})) - newRow.append($('',{text:_.escape(model.get(attribute))})); - cookieTable.append(newRow); - }); - }); - this.$el.append($('

',{text:'Cookie/s'})); - this.$el.append(cookieTable); - } - }); -}); \ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js new file mode 100644 index 000000000..f7f607a8e --- /dev/null +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js @@ -0,0 +1,25 @@ +define(['jquery', + 'underscore', + 'backbone', + 'goatApp/model/FlagsCollection'], +function($, + _, + Backbone, + FlagsCollection) { + return Backbone.View.extend({ + el:'#scoreboard', + + initialize: function() { + this.collection = new FlagsCollection(); + this.listenTo(this.collection,'reset',this.render) + this.collection.fetch({reset:true}); + }, + + render: function() { + this.$el.html('test') + //TODO: add template (table) to iterate over ... + //this.collection.toJSON(); << put that in the template data + //TODO: set up next poll here with listenToOnce + } + }); +}); \ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/scoreboard.js b/webgoat-container/src/main/resources/static/js/scoreboard.js new file mode 100644 index 000000000..f561853f2 --- /dev/null +++ b/webgoat-container/src/main/resources/static/js/scoreboard.js @@ -0,0 +1,47 @@ +//main.js +/* +/js +js/main.js << main file for require.js +--/libs/(jquery,backbone,etc.) << base libs +--/goatApp/ << base dir for goat application, js-wise +--/goatApp/model +--/goatApp/view +--/goatApp/support +--/goatApp/controller +*/ + +require.config({ + baseUrl: "js/", + paths: { + jquery: 'libs/jquery-2.2.4.min', + jqueryui: 'libs/jquery-ui-1.10.4', + underscore: 'libs/underscore-min', + backbone: 'libs/backbone-min', + text: 'libs/text', + templates: 'goatApp/templates', + polyglot: 'libs/polyglot.min' + }, + + map: { + 'libs/jquery-base' : {'jquery':'libs/jquery-2.2.4.min'}, + 'libs/jquery-vuln' : {'jquery':'libs/jquery-2.1.4.min'} + }, + + shim: { + "jqueryui": { + exports:"$", + deps: ['jquery'] + }, + underscore: { + exports: "_" + }, + backbone: { + deps: ['underscore', 'jquery'], + exports: 'Backbone' + } + } +}); + +require(['jquery','libs/jquery-base','libs/jquery-vuln','jqueryui', 'underscore','backbone','goatApp/scoreboardApp'], function($,jqueryBase,jqueryVuln,jqueryui,_,Backbone,ScoreboardApp){ + ScoreboardApp.initApp(); +}); \ No newline at end of file diff --git a/webgoat-container/src/main/resources/templates/scoreboard.html b/webgoat-container/src/main/resources/templates/scoreboard.html new file mode 100644 index 000000000..856f56c5f --- /dev/null +++ b/webgoat-container/src/main/resources/templates/scoreboard.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + +