Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 4880afa

Browse files
authored
fix: remove implicit context path guessing (#1956)
Pass the context-path in the assignment overview so the frontend can easily match an assignment.
1 parent e60ca6c commit 4880afa

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

src/main/java/org/owasp/webgoat/container/lessons/CourseConfiguration.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.owasp.webgoat.container.assignments.AssignmentHints;
3131
import org.owasp.webgoat.container.assignments.AttackResult;
3232
import org.owasp.webgoat.container.session.Course;
33+
import org.springframework.beans.factory.annotation.Value;
3334
import org.springframework.context.annotation.Bean;
3435
import org.springframework.context.annotation.Configuration;
3536
import org.springframework.util.Assert;
@@ -42,10 +43,15 @@
4243
public class CourseConfiguration {
4344
private final List<Lesson> lessons;
4445
private final List<AssignmentEndpoint> assignments;
46+
private final String contextPath;
4547

46-
public CourseConfiguration(List<Lesson> lessons, List<AssignmentEndpoint> assignments) {
48+
public CourseConfiguration(
49+
List<Lesson> lessons,
50+
List<AssignmentEndpoint> assignments,
51+
@Value("${server.servlet.context-path}") String contextPath) {
4752
this.lessons = lessons;
4853
this.assignments = assignments;
54+
this.contextPath = contextPath.equals("/") ? "" : contextPath;
4955
}
5056

5157
private void attachToLessonInParentPackage(
@@ -124,7 +130,7 @@ private String getPath(Class<? extends AssignmentEndpoint> e) {
124130
if (methodReturnTypeIsOfTypeAttackResult(m)) {
125131
var mapping = getMapping(m);
126132
if (mapping != null) {
127-
return mapping;
133+
return contextPath + mapping;
128134
}
129135
}
130136
}

src/main/java/org/owasp/webgoat/lessons/sqlinjection/introduction/SqlInjectionLesson5b.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
package org.owasp.webgoat.lessons.sqlinjection.introduction;
2424

25-
import jakarta.servlet.http.HttpServletRequest;
2625
import java.io.IOException;
2726
import java.sql.*;
2827
import org.owasp.webgoat.container.LessonDataSource;
@@ -52,8 +51,7 @@ public SqlInjectionLesson5b(LessonDataSource dataSource) {
5251

5352
@PostMapping("/SqlInjection/assignment5b")
5453
@ResponseBody
55-
public AttackResult completed(
56-
@RequestParam String userid, @RequestParam String login_count, HttpServletRequest request)
54+
public AttackResult completed(@RequestParam String userid, @RequestParam String login_count)
5755
throws IOException {
5856
return injectableQuery(login_count, userid);
5957
}

src/main/resources/webgoat/static/js/goatApp/controller/LessonController.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ define(['jquery',
121121

122122
this.showHintsView = function() {
123123
var self=this;
124-
console.log(self.name);
125124
if (!this.lessonHintView) {
126125
this.createLessonHintView();
127126
}

src/main/resources/webgoat/static/js/goatApp/view/LessonContentView.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ define(['jquery',
6868
}
6969
},
7070

71-
getCurrentPage: function () {
72-
return this.currentPage;
73-
},
74-
7571
makeFormsAjax: function () {
7672
this.$form = $('form.attack-form');
7773
// turn off standard submit

src/main/resources/webgoat/static/js/goatApp/view/PaginationControlView.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ define(['jquery',
4747
var pages = [];
4848

4949
_.each(this.collection.models, function(model) {
50-
//alert (model.get('solved'));
5150
if (model.get('solved')) {
5251
var key = model.get('assignment').path.replace(/\//g,'');
5352
solvedMap[key] = model.get('assignment').name;
@@ -57,7 +56,6 @@ define(['jquery',
5756

5857
isAttackSolved = function (path) {
5958
//strip
60-
//var newPath = path.replace(/^\/WebGoat/,'');
6159
var newPath = path.replace(/\//g,'');
6260
if (typeof solvedMap[newPath] !== 'undefined') {
6361
return true;

0 commit comments

Comments
 (0)