Skip to content

Commit

Permalink
[AGNT-264] fix link entity indexEnd (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-rojbeni authored Sep 13, 2023
1 parent 67348ac commit 99bc7dd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.symphonyoss.symphony</groupId>
<artifactId>messageml</artifactId>
<version>0.11.1</version>
<version>0.11.2</version>
<name>MessageML Utils</name>
<url>https://github.com/finos/messageml-utils</url>
<description>A set of utilities for parsing, processing and rendering of MessageML messages</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ private MessageML parseMessageML(String messageML, String version) throws Invali

/**
* Parse the message string into a DOM element tree.
* <br>
* CWE-611 on <code> dBuilder.parse(ris) </code> : There are ambiguities between what was
* recommended
* <a href="https://sg.run/gLbR">https://sg.run/gLbR</a> and the documentation
* <a href="https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html">XML External Entity Prevention Cheat Sheet</a>,
* so for now we prefer keeping the old code and ignore the rule to pass the workflow checklist
* </br>
*/
org.w3c.dom.Element parseDocument(String messageML) throws InvalidInputException, ProcessingException {
try {
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 99bc7dd

Please sign in to comment.