-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-31192: Fixed injection abilities (#299)
- Loading branch information
1 parent
f1d208e
commit 0d59269
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
sawmill-core/src/test/java/io/logz/sawmill/utilities/DocumentBuilderProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.logz.sawmill.utilities; | ||
|
||
import java.io.InputStream; | ||
import javax.xml.parsers.DocumentBuilder; | ||
import org.junit.Test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
public class DocumentBuilderProviderTest { | ||
|
||
private static final String XML_FILE = "/test_xml_injection.xml"; | ||
|
||
@Test | ||
public void testDocumentBuilderProviderReturnsNonNullEntity() { | ||
DocumentBuilderProvider documentBuilderProvider = new DocumentBuilderProvider(); | ||
DocumentBuilder documentBuilder = documentBuilderProvider.provide(); | ||
assertThat(documentBuilder).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void testParseXml() { | ||
InputStream xmlFile = DocumentBuilderProviderTest.class.getResourceAsStream(XML_FILE); | ||
assertThatThrownBy(() -> new DocumentBuilderProvider().provide().parse(xmlFile)) | ||
.hasMessageStartingWith("DOCTYPE is disallowed"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///"> ]> | ||
<stockCheck><productId>&xxe;</productId></stockCheck> |