chore: bump org.asciidoctor:asciidoctorj from 2.5.13 to 3.0.0 (#1897)

This commit is contained in:
dependabot[bot] 2024-10-26 22:53:43 +02:00 committed by GitHub
parent 3f049ba53a
commit cf5101a633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 41 additions and 31 deletions

View File

@ -62,7 +62,7 @@
<properties>
<!-- 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>
<cglib.version>3.3.0</cglib.version>
<!-- do not update necessary for lesson -->

View File

@ -37,12 +37,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Attributes;
import org.asciidoctor.Options;
import org.asciidoctor.extension.JavaExtensionRegistry;
import org.owasp.webgoat.container.asciidoc.*;
import org.owasp.webgoat.container.i18n.Language;
@ -135,17 +136,17 @@ public class AsciiDoctorTemplateResolver extends FileTemplateResolver {
return computedResourceName;
}
private Map<String, Object> 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);
private Options createAttributes() {
Map<String, Object> options = new HashMap<>();
options.put("attributes", attributes);
return options;
return Options.builder()
.attributes(
Attributes.builder()
.attribute("source-highlighter", "coderay")
.attribute("backend", "xhtml")
.attribute("lang", determineLanguage())
.attribute("icons", org.asciidoctor.Attributes.FONT_ICONS)
.build())
.build();
}
private String determineLanguage() {

View File

@ -1,7 +1,8 @@
package org.owasp.webgoat.container.asciidoc;
import java.util.Map;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.PhraseNode;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.extension.InlineMacroProcessor;
public class OperatingSystemMacro extends InlineMacroProcessor {
@ -15,7 +16,8 @@ public class OperatingSystemMacro extends InlineMacroProcessor {
}
@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");
// see

View File

@ -1,7 +1,8 @@
package org.owasp.webgoat.container.asciidoc;
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.owasp.webgoat.container.users.WebGoatUser;
import org.springframework.security.core.context.SecurityContextHolder;
@ -17,7 +18,8 @@ public class UsernameMacro extends InlineMacroProcessor {
}
@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 username = "unknown";
if (auth.getPrincipal() instanceof WebGoatUser webGoatUser) {

View File

@ -1,7 +1,8 @@
package org.owasp.webgoat.container.asciidoc;
import java.util.Map;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.PhraseNode;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.extension.InlineMacroProcessor;
public class WebGoatTmpDirMacro extends InlineMacroProcessor {
@ -15,11 +16,12 @@ public class WebGoatTmpDirMacro extends InlineMacroProcessor {
}
@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");
// see
// 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);
}
}

View File

@ -1,7 +1,8 @@
package org.owasp.webgoat.container.asciidoc;
import java.util.Map;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.PhraseNode;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.extension.InlineMacroProcessor;
public class WebGoatVersionMacro extends InlineMacroProcessor {
@ -15,7 +16,8 @@ public class WebGoatVersionMacro extends InlineMacroProcessor {
}
@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");
// see

View File

@ -2,7 +2,8 @@ package org.owasp.webgoat.container.asciidoc;
import java.util.HashMap;
import java.util.Map;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.PhraseNode;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.extension.InlineMacroProcessor;
/**
@ -21,7 +22,8 @@ public class WebWolfMacro extends InlineMacroProcessor {
}
@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 hostname = env.getProperty("webwolf.url");
var target = (String) attributes.getOrDefault("target", "home");
@ -36,7 +38,7 @@ public class WebWolfMacro extends InlineMacroProcessor {
options.put("type", ":link");
options.put("target", href);
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) {

View File

@ -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.setup.MockMvcBuilders.standaloneSetup;
import com.beust.jcommander.internal.Lists;
import java.util.List;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
@ -28,7 +27,7 @@ public class HintServiceTest {
void setup() {
Lesson lesson = new HttpBasics();
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));
this.mockMvc = standaloneSetup(new HintService(course)).build();
}

View File

@ -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.setup.MockMvcBuilders.standaloneSetup;
import com.beust.jcommander.internal.Lists;
import java.util.Arrays;
import java.util.List;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -74,8 +74,8 @@ public class LessonMenuServiceTest {
when(l1.getTitle()).thenReturn("ZA");
when(l2.getTitle()).thenReturn("AA");
when(lessonTracker.isLessonSolved()).thenReturn(false);
when(course.getLessons(any())).thenReturn(Lists.newArrayList(l1, l2));
when(course.getCategories()).thenReturn(Lists.newArrayList(Category.A1));
when(course.getLessons(any())).thenReturn(List.of(l1, l2));
when(course.getCategories()).thenReturn(List.of(Category.A1));
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);
@ -91,8 +91,8 @@ public class LessonMenuServiceTest {
Lesson l1 = Mockito.mock(Lesson.class);
when(l1.getTitle()).thenReturn("ZA");
when(lessonTracker.isLessonSolved()).thenReturn(true);
when(course.getLessons(any())).thenReturn(Lists.newArrayList(l1));
when(course.getCategories()).thenReturn(Lists.newArrayList(Category.A1));
when(course.getLessons(any())).thenReturn(List.of(l1));
when(course.getCategories()).thenReturn(List.of(Category.A1));
when(userTracker.getLessonProgress(any(Lesson.class))).thenReturn(lessonTracker);
when(userTrackerRepository.findByUser(any())).thenReturn(userTracker);