XXE lesson not showing correct link for WebWolf
This commit is contained in:
@ -10,6 +10,12 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Usage in asciidoc:
|
||||
* <p>
|
||||
* webWolfLink:here[] will display a href with here as text
|
||||
* webWolfLink:landing[noLink] will display the complete url, for example: http://WW_HOST:WW_PORT/landing
|
||||
*/
|
||||
public class WebWolfMacro extends InlineMacroProcessor {
|
||||
|
||||
public WebWolfMacro(String macroName, Map<String, Object> config) {
|
||||
@ -20,9 +26,17 @@ public class WebWolfMacro extends InlineMacroProcessor {
|
||||
protected String process(AbstractBlock parent, String target, Map<String, Object> attributes) {
|
||||
Environment env = EnvironmentExposure.getEnv();
|
||||
String hostname = determineHost(env.getProperty("webwolf.host"), env.getProperty("webwolf.port"));
|
||||
|
||||
if (displayCompleteLinkNoFormatting(attributes)) {
|
||||
return hostname + (hostname.endsWith("/") ? "" : "/") + target;
|
||||
}
|
||||
return "<a href=\"" + hostname + "\" target=\"_blank\">" + target + "</a>";
|
||||
}
|
||||
|
||||
private boolean displayCompleteLinkNoFormatting(Map<String, Object> attributes) {
|
||||
return attributes.values().stream().filter(a -> a.equals("noLink")).findFirst().isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Look at the remote address from received from the browser first. This way it will also work if you run
|
||||
* the browser in a Docker container and WebGoat on your local machine.
|
||||
|
@ -52,6 +52,7 @@ public class UserTracker {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@Column(name = "username")
|
||||
private String user;
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
private Set<LessonTracker> lessonTrackers = Sets.newHashSet();
|
||||
|
Reference in New Issue
Block a user