diff --git a/pom.xml b/pom.xml index 7fcf57bf..2e98b600 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.symphonyoss.symphony messageml - 0.11.1 + 0.11.2 MessageML Utils https://github.com/finos/messageml-utils A set of utilities for parsing, processing and rendering of MessageML messages diff --git a/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java b/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java index 46c6495f..e7544c5b 100644 --- a/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java +++ b/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java @@ -370,6 +370,13 @@ private MessageML parseMessageML(String messageML, String version) throws Invali /** * Parse the message string into a DOM element tree. + *
+ * CWE-611 on dBuilder.parse(ris) : There are ambiguities between what was + * recommended + * https://sg.run/gLbR and the documentation + * XML External Entity Prevention Cheat Sheet, + * so for now we prefer keeping the old code and ignore the rule to pass the workflow checklist + *
*/ org.w3c.dom.Element parseDocument(String messageML) throws InvalidInputException, ProcessingException { try { @@ -380,7 +387,7 @@ org.w3c.dom.Element parseDocument(String messageML) throws InvalidInputException StringReader sr = new StringReader(messageML); ReaderInputStream ris = new ReaderInputStream(sr, StandardCharsets.UTF_8); - Document doc = dBuilder.parse(ris); + Document doc = dBuilder.parse(ris); // nosemgrep owasp.java.xxe.javax.xml.parsers.DocumentBuilderFactory doc.getDocumentElement().normalize(); diff --git a/src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java b/src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java index 5b383bf5..a0d1df26 100644 --- a/src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java +++ b/src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java @@ -138,7 +138,7 @@ public void visit(Link a) { ObjectNode node = new ObjectNode(JsonNodeFactory.instance); node.put(ID, href); node.put(TYPE, "URL"); - node.put(INDEX_END, writer.length() + title.length()); + node.put(INDEX_END, writer.length() + markdown.length()); node.put(INDEX_START, writer.length()); node.put(TEXT, title); node.put(EXPANDED_URL, href); diff --git a/src/test/resources/payloads/expanded_single_jira_ticket.entities b/src/test/resources/payloads/expanded_single_jira_ticket.entities index fa576d57..a891f568 100644 --- a/src/test/resources/payloads/expanded_single_jira_ticket.entities +++ b/src/test/resources/payloads/expanded_single_jira_ticket.entities @@ -3,7 +3,7 @@ { "id": "https://whiteam1.atlassian.net/browse/SAM-24", "type": "URL", - "indexEnd": 81, + "indexEnd": 131, "indexStart": 54, "text": "\nSAM-24,Sample Bug Blocker\n", "expandedUrl": "https://whiteam1.atlassian.net/browse/SAM-24"