Fix other macros as well

This commit is contained in:
Nanne Baars
2021-04-25 17:36:14 +02:00
parent 81c551552b
commit a91d45dea5
3 changed files with 15 additions and 5 deletions
webgoat-container/src/main/java/org/owasp/webgoat/asciidoc

@ -17,6 +17,9 @@ public class OperatingSystemMacro extends InlineMacroProcessor {
@Override @Override
public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) { public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
return System.getProperty("os.name"); var osName = System.getProperty("os.name");
//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", osName);
} }
} }

@ -16,7 +16,11 @@ public class WebGoatTmpDirMacro extends InlineMacroProcessor {
} }
@Override @Override
public String process(ContentNode contentNode, String target, Map<String, Object> attributes) { public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
return EnvironmentExposure.getEnv().getProperty("webgoat.server.directory"); 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);
} }
} }

@ -16,7 +16,10 @@ public class WebGoatVersionMacro extends InlineMacroProcessor {
} }
@Override @Override
public String process(ContentNode contentNode, String target, Map<String, Object> attributes) { public Object process(ContentNode contentNode, String target, Map<String, Object> attributes) {
return EnvironmentExposure.getEnv().getProperty("webgoat.build.version"); var webgoatVersion = EnvironmentExposure.getEnv().getProperty("webgoat.build.version");
//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", webgoatVersion);
} }
} }