fix: remove implicit context path guessing (#1956)
Pass the context-path in the assignment overview so the frontend can easily match an assignment.
This commit is contained in:
parent
e60ca6ce72
commit
4880afa0e3
@ -30,6 +30,7 @@ import org.owasp.webgoat.container.assignments.AssignmentEndpoint;
|
|||||||
import org.owasp.webgoat.container.assignments.AssignmentHints;
|
import org.owasp.webgoat.container.assignments.AssignmentHints;
|
||||||
import org.owasp.webgoat.container.assignments.AttackResult;
|
import org.owasp.webgoat.container.assignments.AttackResult;
|
||||||
import org.owasp.webgoat.container.session.Course;
|
import org.owasp.webgoat.container.session.Course;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -42,10 +43,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
public class CourseConfiguration {
|
public class CourseConfiguration {
|
||||||
private final List<Lesson> lessons;
|
private final List<Lesson> lessons;
|
||||||
private final List<AssignmentEndpoint> assignments;
|
private final List<AssignmentEndpoint> assignments;
|
||||||
|
private final String contextPath;
|
||||||
|
|
||||||
public CourseConfiguration(List<Lesson> lessons, List<AssignmentEndpoint> assignments) {
|
public CourseConfiguration(
|
||||||
|
List<Lesson> lessons,
|
||||||
|
List<AssignmentEndpoint> assignments,
|
||||||
|
@Value("${server.servlet.context-path}") String contextPath) {
|
||||||
this.lessons = lessons;
|
this.lessons = lessons;
|
||||||
this.assignments = assignments;
|
this.assignments = assignments;
|
||||||
|
this.contextPath = contextPath.equals("/") ? "" : contextPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attachToLessonInParentPackage(
|
private void attachToLessonInParentPackage(
|
||||||
@ -124,7 +130,7 @@ public class CourseConfiguration {
|
|||||||
if (methodReturnTypeIsOfTypeAttackResult(m)) {
|
if (methodReturnTypeIsOfTypeAttackResult(m)) {
|
||||||
var mapping = getMapping(m);
|
var mapping = getMapping(m);
|
||||||
if (mapping != null) {
|
if (mapping != null) {
|
||||||
return mapping;
|
return contextPath + mapping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
package org.owasp.webgoat.lessons.sqlinjection.introduction;
|
package org.owasp.webgoat.lessons.sqlinjection.introduction;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import org.owasp.webgoat.container.LessonDataSource;
|
import org.owasp.webgoat.container.LessonDataSource;
|
||||||
@ -52,8 +51,7 @@ public class SqlInjectionLesson5b extends AssignmentEndpoint {
|
|||||||
|
|
||||||
@PostMapping("/SqlInjection/assignment5b")
|
@PostMapping("/SqlInjection/assignment5b")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AttackResult completed(
|
public AttackResult completed(@RequestParam String userid, @RequestParam String login_count)
|
||||||
@RequestParam String userid, @RequestParam String login_count, HttpServletRequest request)
|
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return injectableQuery(login_count, userid);
|
return injectableQuery(login_count, userid);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ define(['jquery',
|
|||||||
|
|
||||||
this.showHintsView = function() {
|
this.showHintsView = function() {
|
||||||
var self=this;
|
var self=this;
|
||||||
console.log(self.name);
|
|
||||||
if (!this.lessonHintView) {
|
if (!this.lessonHintView) {
|
||||||
this.createLessonHintView();
|
this.createLessonHintView();
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,6 @@ define(['jquery',
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentPage: function () {
|
|
||||||
return this.currentPage;
|
|
||||||
},
|
|
||||||
|
|
||||||
makeFormsAjax: function () {
|
makeFormsAjax: function () {
|
||||||
this.$form = $('form.attack-form');
|
this.$form = $('form.attack-form');
|
||||||
// turn off standard submit
|
// turn off standard submit
|
||||||
|
@ -47,7 +47,6 @@ define(['jquery',
|
|||||||
var pages = [];
|
var pages = [];
|
||||||
|
|
||||||
_.each(this.collection.models, function(model) {
|
_.each(this.collection.models, function(model) {
|
||||||
//alert (model.get('solved'));
|
|
||||||
if (model.get('solved')) {
|
if (model.get('solved')) {
|
||||||
var key = model.get('assignment').path.replace(/\//g,'');
|
var key = model.get('assignment').path.replace(/\//g,'');
|
||||||
solvedMap[key] = model.get('assignment').name;
|
solvedMap[key] = model.get('assignment').name;
|
||||||
@ -57,7 +56,6 @@ define(['jquery',
|
|||||||
|
|
||||||
isAttackSolved = function (path) {
|
isAttackSolved = function (path) {
|
||||||
//strip
|
//strip
|
||||||
//var newPath = path.replace(/^\/WebGoat/,'');
|
|
||||||
var newPath = path.replace(/\//g,'');
|
var newPath = path.replace(/\//g,'');
|
||||||
if (typeof solvedMap[newPath] !== 'undefined') {
|
if (typeof solvedMap[newPath] !== 'undefined') {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user