Skip to content

Commit b5c4076

Browse files
committed
2nd crack at ajaxifying links and forms (made harder since some lessons produce a 2nd form and links based on earlier input
1 parent 019a148 commit b5c4076

File tree

3 files changed

+188
-187
lines changed

3 files changed

+188
-187
lines changed

src/main/java/org/owasp/webgoat/session/Screen.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
*
3636
* Getting Source ==============
3737
*
38-
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository
39-
* for free software projects.
38+
* Source for this application is maintained at
39+
* https://github.com/WebGoat/WebGoat, a repository for free software projects.
4040
*
4141
* For details, please see http://webgoat.github.io
4242
*
@@ -202,12 +202,11 @@ public void output(PrintWriter out) {
202202

203203
}
204204

205-
// TODO we could hook all forms here with javascript call to ajax forms plugin
205+
// hook all the links
206206
public String getContent() {
207-
String makeFormsAjax = "<script> $(document).ready(function() { makeFormsAjax(); });</script>";
208-
// handle this on the page with js
209-
makeFormsAjax = "";
210-
return (content == null) ? "" : content.toString() + makeFormsAjax;
207+
String makeAllAjax = "<script>goat.utils.makeFormsAjax();goat.utils.ajaxifyAttackHref();</script>";
208+
// need to do this here as some of the lessons render forms after submission of an ajax form
209+
return (content == null) ? "" : content.toString() + makeAllAjax;
211210
}
212211

213212
/**

src/main/webapp/WEB-INF/pages/main_new.jsp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<![endif]-->
4242

4343
<!--Global JS-->
44-
44+
4545
<script src="js/jquery_form/jquery.form.js"></script>
4646
<script src="plugins/bootstrap/js/bootstrap.min.js"></script>
4747

@@ -115,9 +115,9 @@
115115
<a ng-click="accordionMenu(item.id)" href=""><i class="fa {{item.class}}"></i><span>{{item.name}}</span></a><!-- expanded = !expanded-->
116116
<ul class="slideDown lessonsAndStages {{item.displayClass}}" id="{{item.id}}" isOpen=0>
117117
<li ng-repeat="lesson in item.children" class="{{lesson.selectedClass}}">
118-
<a ng-click="renderLesson(lesson.id,lesson.link,{showSource:lesson.showSource,showHints:lesson.showHints})" id="{{lesson.id}}" class="{{lesson.selectedClass}}" title="link to {{lesson.name}}" href="">{{lesson.name}}</a><span class="{{lesson.completeClass}}"></span>
118+
<a ng-click="renderLesson(lesson.id, lesson.link, {showSource: lesson.showSource, showHints: lesson.showHints})" id="{{lesson.id}}" class="{{lesson.selectedClass}}" title="link to {{lesson.name}}" href="">{{lesson.name}}</a><span class="{{lesson.completeClass}}"></span>
119119
<span ng-repeat="stage in lesson.children">
120-
<a ng-click="renderLesson(stage.id,stage.link,{showSource:stage.showSource,showHints:stage.showHints})" class="selectedClass" id="{{stage.id}}" title="link to {{stage.name}}" href="">{{stage.name}}</a><span class="{{stage.completeClass}}"></span>
120+
<a ng-click="renderLesson(stage.id, stage.link, {showSource: stage.showSource, showHints: stage.showHints})" class="selectedClass" id="{{stage.id}}" title="link to {{stage.name}}" href="">{{stage.name}}</a><span class="{{stage.completeClass}}"></span>
121121
</span>
122122
</li>
123123
</ul>
@@ -177,19 +177,19 @@
177177
<div class="cookiesView">
178178
<h4>Cookies</h4>
179179
<div class="cookieContainer" ng-repeat="cookie in cookies">
180-
<table class="cookieTable table-striped table-nonfluid" >
181-
<thead>
182-
<tr><th class="col-sm-1"></th><th class="col-sm-1"></th></tr> <!-- Field / Value -->
183-
</thead>
184-
<tbody>
185-
<tr ng-repeat="(key, value) in cookie">
186-
<td>{{key}}</td>
187-
<td>{{value}}</td>
188-
</tr>
189-
</tbody>
190-
<!--<li ng-repeat="(key, value) in cookie">{{key}} :: {{ value}} </td>-->
191-
<!--</ul>-->
192-
</table>
180+
<table class="cookieTable table-striped table-nonfluid" >
181+
<thead>
182+
<tr><th class="col-sm-1"></th><th class="col-sm-1"></th></tr> <!-- Field / Value -->
183+
</thead>
184+
<tbody>
185+
<tr ng-repeat="(key, value) in cookie">
186+
<td>{{key}}</td>
187+
<td>{{value}}</td>
188+
</tr>
189+
</tbody>
190+
<!--<li ng-repeat="(key, value) in cookie">{{key}} :: {{ value}} </td>-->
191+
<!--</ul>-->
192+
</table>
193193
</div>
194194
</div>
195195
<div id="paramsView"> <!--class="paramsView"-->
@@ -296,7 +296,7 @@
296296
297297
$(document).ready(function() {
298298
//TODO merge appliction.js code into other js files
299-
app.init();
299+
app.init();
300300
});
301301
// make all forms ajax forms
302302
var options = {
@@ -354,7 +354,8 @@
354354
// make any embedded forms ajaxy
355355
goat.utils.showLessonCookiesAndParams();
356356
goat.utils.makeFormsAjax();
357-
goat.utils.ajaxifyAttackHref(); //TODO find some way to hook scope for current menu. Likely needs larger refactor which is already started/stashed
357+
// links are hooked with each lesson now (see Java class Screen.getContent())
358+
//goat.utils.ajaxifyAttackHref(); //TODO find some way to hook scope for current menu. Likely needs larger refactor which is already started/stashed
358359
//refresh menu
359360
angular.element($('#leftside-navigation')).scope().renderMenu();
360361
}

0 commit comments

Comments
 (0)