Skip to content

Commit

Permalink
errorprone :: MemberName - JDOMUtil (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdahlke authored Jul 24, 2024
1 parent 8ad24c1 commit 95275db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/emissary/util/xml/AbstractJDOMUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class AbstractJDOMUtil {

public static final String ERR_MSG = "Could not parse document: ";

@SuppressWarnings("MemberName")
protected static SAXBuilder createSAXBuilder(final boolean validate) {
SAXBuilder builder;
if (validate) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/emissary/util/xml/SaferJDOMUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
public class SaferJDOMUtil extends AbstractJDOMUtil {

@SuppressWarnings("MemberName")
protected static SAXBuilder createSAXBuilder() {
SAXBuilder builder = createSAXBuilder(false);
// This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/emissary/util/xml/JDOMUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class JDOMUtilTest extends UnitTest {

static final String plist_xml =
static final String PLIST_XML =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n" + "<dict>\n" + " <key>Label</key>\n" + " <string>com.apple.AOSNotification</string>\n"
Expand All @@ -25,7 +25,7 @@ class JDOMUtilTest extends UnitTest {
@Test
void testNonValidatingDTDRetrievalSuppression() {
try {
final Document doc = JDOMUtil.createDocument(plist_xml, null, false);
final Document doc = JDOMUtil.createDocument(PLIST_XML, null, false);
assertNotNull(doc, "Document should be created");
} catch (Throwable t) {
fail("An exception should not be thrown here, perhaps the DTD validation is not fully disabled.", t);
Expand All @@ -34,6 +34,6 @@ void testNonValidatingDTDRetrievalSuppression() {

@Test
void testValidationFailedDTDRetrieval() {
assertThrows(JDOMParseException.class, () -> JDOMUtil.createDocument(plist_xml, null, true));
assertThrows(JDOMParseException.class, () -> JDOMUtil.createDocument(PLIST_XML, null, true));
}
}

0 comments on commit 95275db

Please sign in to comment.