chore: bump org.asciidoctor:asciidoctorj from 2.5.13 to 3.0.0 (#1897)
This commit is contained in:
parent
3f049ba53a
commit
cf5101a633
2
pom.xml
2
pom.xml
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Shared properties with plugins and version numbers across submodules-->
|
<!-- Shared properties with plugins and version numbers across submodules-->
|
||||||
<asciidoctorj.version>2.5.13</asciidoctorj.version>
|
<asciidoctorj.version>3.0.0</asciidoctorj.version>
|
||||||
<bootstrap.version>5.3.3</bootstrap.version>
|
<bootstrap.version>5.3.3</bootstrap.version>
|
||||||
<cglib.version>3.3.0</cglib.version>
|
<cglib.version>3.3.0</cglib.version>
|
||||||
<!-- do not update necessary for lesson -->
|
<!-- do not update necessary for lesson -->
|
||||||
|
@ -37,12 +37,13 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.asciidoctor.Asciidoctor;
|
import org.asciidoctor.Asciidoctor;
|
||||||
|
import org.asciidoctor.Attributes;
|
||||||
|
import org.asciidoctor.Options;
|
||||||
import org.asciidoctor.extension.JavaExtensionRegistry;
|
import org.asciidoctor.extension.JavaExtensionRegistry;
|
||||||
import org.owasp.webgoat.container.asciidoc.*;
|
import org.owasp.webgoat.container.asciidoc.*;
|
||||||
import org.owasp.webgoat.container.i18n.Language;
|
import org.owasp.webgoat.container.i18n.Language;
|
||||||
@ -135,17 +136,17 @@ public class AsciiDoctorTemplateResolver extends FileTemplateResolver {
|
|||||||
return computedResourceName;
|
return computedResourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> createAttributes() {
|
private Options createAttributes() {
|
||||||
Map<String, Object> attributes = new HashMap<>();
|
|
||||||
attributes.put("source-highlighter", "coderay");
|
|
||||||
attributes.put("backend", "xhtml");
|
|
||||||
attributes.put("lang", determineLanguage());
|
|
||||||
attributes.put("icons", org.asciidoctor.Attributes.FONT_ICONS);
|
|
||||||
|
|
||||||
Map<String, Object> options = new HashMap<>();
|
return Options.builder()
|
||||||
options.put("attributes", attributes);
|
.attributes(
|
||||||
|
Attributes.builder()
|
||||||
return options;
|
.attribute("source-highlighter", "coderay")
|
||||||
|
.attribute("backend", "xhtml")
|
||||||
|
.attribute("lang", determineLanguage())
|
||||||
|
.attribute("icons", org.asciidoctor.Attributes.FONT_ICONS)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String determineLanguage() {
|
private String determineLanguage() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package org.owasp.webgoat.container.asciidoc;
|
package org.owasp.webgoat.container.asciidoc;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.asciidoctor.ast.ContentNode;
|
import org.asciidoctor.ast.PhraseNode;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
import org.asciidoctor.extension.InlineMacroProcessor;
|
import org.asciidoctor.extension.InlineMacroProcessor;
|
||||||
|
|
||||||
public class OperatingSystemMacro extends InlineMacroProcessor {
|
public class OperatingSystemMacro extends InlineMacroProcessor {
|
||||||
@ -15,7 +16,8 @@ public class OperatingSystemMacro extends InlineMacroProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
|
public PhraseNode process(
|
||||||
|
StructuralNode contentNode, String target, Map<String, Object> attributes) {
|
||||||
var osName = System.getProperty("os.name");
|
var osName = System.getProperty("os.name");
|
||||||
|
|
||||||
// see
|
// see
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package org.owasp.webgoat.container.asciidoc;
|
package org.owasp.webgoat.container.asciidoc;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.asciidoctor.ast.ContentNode;
|
import org.asciidoctor.ast.PhraseNode;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
import org.asciidoctor.extension.InlineMacroProcessor;
|
import org.asciidoctor.extension.InlineMacroProcessor;
|
||||||
import org.owasp.webgoat.container.users.WebGoatUser;
|
import org.owasp.webgoat.container.users.WebGoatUser;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
@ -17,7 +18,8 @@ public class UsernameMacro extends InlineMacroProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
|
public PhraseNode process(
|
||||||
|
StructuralNode contentNode, String target, Map<String, Object> attributes) {
|
||||||
var auth = SecurityContextHolder.getContext().getAuthentication();
|
var auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
var username = "unknown";
|
var username = "unknown";
|
||||||
if (auth.getPrincipal() instanceof WebGoatUser webGoatUser) {
|
if (auth.getPrincipal() instanceof WebGoatUser webGoatUser) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package org.owasp.webgoat.container.asciidoc;
|
package org.owasp.webgoat.container.asciidoc;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.asciidoctor.ast.ContentNode;
|
import org.asciidoctor.ast.PhraseNode;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
import org.asciidoctor.extension.InlineMacroProcessor;
|
import org.asciidoctor.extension.InlineMacroProcessor;
|
||||||
|
|
||||||
public class WebGoatTmpDirMacro extends InlineMacroProcessor {
|
public class WebGoatTmpDirMacro extends InlineMacroProcessor {
|
||||||
@ -15,11 +16,12 @@ public class WebGoatTmpDirMacro extends InlineMacroProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
|
public PhraseNode process(
|
||||||
|
StructuralNode structuralNode, String target, Map<String, Object> attributes) {
|
||||||
var env = EnvironmentExposure.getEnv().getProperty("webgoat.server.directory");
|
var env = EnvironmentExposure.getEnv().getProperty("webgoat.server.directory");
|
||||||
|
|
||||||
// see
|
// see
|
||||||
// https://discuss.asciidoctor.org/How-to-create-inline-macro-producing-HTML-In-AsciidoctorJ-td8313.html for why quoted is used
|
// https://discuss.asciidoctor.org/How-to-create-inline-macro-producing-HTML-In-AsciidoctorJ-td8313.html for why quoted is used
|
||||||
return createPhraseNode(contentNode, "quoted", env);
|
return createPhraseNode(structuralNode, "quoted", env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package org.owasp.webgoat.container.asciidoc;
|
package org.owasp.webgoat.container.asciidoc;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.asciidoctor.ast.ContentNode;
|
import org.asciidoctor.ast.PhraseNode;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
import org.asciidoctor.extension.InlineMacroProcessor;
|
import org.asciidoctor.extension.InlineMacroProcessor;
|
||||||
|
|
||||||
public class WebGoatVersionMacro extends InlineMacroProcessor {
|
public class WebGoatVersionMacro extends InlineMacroProcessor {
|
||||||
@ -15,7 +16,8 @@ public class WebGoatVersionMacro extends InlineMacroProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
|
public PhraseNode process(
|
||||||
|
StructuralNode contentNode, String target, Map<String, Object> attributes) {
|
||||||
var webgoatVersion = EnvironmentExposure.getEnv().getProperty("webgoat.build.version");
|
var webgoatVersion = EnvironmentExposure.getEnv().getProperty("webgoat.build.version");
|
||||||
|
|
||||||
// see
|
// see
|
||||||
|
@ -2,7 +2,8 @@ package org.owasp.webgoat.container.asciidoc;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.asciidoctor.ast.ContentNode;
|
import org.asciidoctor.ast.PhraseNode;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
import org.asciidoctor.extension.InlineMacroProcessor;
|
import org.asciidoctor.extension.InlineMacroProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,7 +22,8 @@ public class WebWolfMacro extends InlineMacroProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process(ContentNode contentNode, String linkText, Map<String, Object> attributes) {
|
public PhraseNode process(
|
||||||
|
StructuralNode contentNode, String linkText, Map<String, Object> attributes) {
|
||||||
var env = EnvironmentExposure.getEnv();
|
var env = EnvironmentExposure.getEnv();
|
||||||
var hostname = env.getProperty("webwolf.url");
|
var hostname = env.getProperty("webwolf.url");
|
||||||
var target = (String) attributes.getOrDefault("target", "home");
|
var target = (String) attributes.getOrDefault("target", "home");
|
||||||
@ -36,7 +38,7 @@ public class WebWolfMacro extends InlineMacroProcessor {
|
|||||||
options.put("type", ":link");
|
options.put("type", ":link");
|
||||||
options.put("target", href);
|
options.put("target", href);
|
||||||
attributes.put("window", "_blank");
|
attributes.put("window", "_blank");
|
||||||
return createPhraseNode(contentNode, "anchor", linkText, attributes, options).convert();
|
return createPhraseNode(contentNode, "anchor", linkText, attributes, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean displayCompleteLinkNoFormatting(Map<String, Object> attributes) {
|
private boolean displayCompleteLinkNoFormatting(Map<String, Object> attributes) {
|
||||||
|
@ -5,7 +5,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
|
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
|
||||||
|
|
||||||
import com.beust.jcommander.internal.Lists;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -28,7 +27,7 @@ public class HintServiceTest {
|
|||||||
void setup() {
|
void setup() {
|
||||||
Lesson lesson = new HttpBasics();
|
Lesson lesson = new HttpBasics();
|
||||||
lesson.addAssignment(
|
lesson.addAssignment(
|
||||||
new Assignment("test", "/HttpBasics/attack1", Lists.newArrayList("hint 1", "hint 2")));
|
new Assignment("test", "/HttpBasics/attack1", List.of("hint 1", "hint 2")));
|
||||||
Course course = new Course(List.of(lesson));
|
Course course = new Course(List.of(lesson));
|
||||||
this.mockMvc = standaloneSetup(new HintService(course)).build();
|
this.mockMvc = standaloneSetup(new HintService(course)).build();
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
|
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
|
||||||
|
|
||||||
import com.beust.jcommander.internal.Lists;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -74,8 +74,8 @@ public class LessonMenuServiceTest {
|
|||||||
when(l1.getTitle()).thenReturn("ZA");
|
when(l1.getTitle()).thenReturn("ZA");
|
||||||
when(l2.getTitle()).thenReturn("AA");
|
when(l2.getTitle()).thenReturn("AA");
|
||||||
when(lessonTracker.isLessonSolved()).thenReturn(false);
|
when(lessonTracker.isLessonSolved()).thenReturn(false);
|
||||||
when(course.getLessons(any())).thenReturn(Lists.newArrayList(l1, l2));
|
when(course.getLessons(any())).thenReturn(List.of(l1, l2));
|
||||||
when(course.getCategories()).thenReturn(Lists.newArrayList(Category.A1));
|
when(course.getCategories()).thenReturn(List.of(Category.A1));
|
||||||
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
|
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
|
||||||
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);
|
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ public class LessonMenuServiceTest {
|
|||||||
Lesson l1 = Mockito.mock(Lesson.class);
|
Lesson l1 = Mockito.mock(Lesson.class);
|
||||||
when(l1.getTitle()).thenReturn("ZA");
|
when(l1.getTitle()).thenReturn("ZA");
|
||||||
when(lessonTracker.isLessonSolved()).thenReturn(true);
|
when(lessonTracker.isLessonSolved()).thenReturn(true);
|
||||||
when(course.getLessons(any())).thenReturn(Lists.newArrayList(l1));
|
when(course.getLessons(any())).thenReturn(List.of(l1));
|
||||||
when(course.getCategories()).thenReturn(Lists.newArrayList(Category.A1));
|
when(course.getCategories()).thenReturn(List.of(Category.A1));
|
||||||
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
|
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
|
||||||
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);
|
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user