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
9 changed files with 41 additions and 31 deletions

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) {