Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/com/marklogic/contentpump/AggregateXMLReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public void initialize(InputSplit inSplit, TaskAttemptContext context)
initAggConf(context);

f = XMLInputFactory.newInstance();
try {
f.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security property IS_SUPPORTING_EXTERNAL_ENTITIES on XMLInputFactory", e);
}
try {
f.setProperty(XMLInputFactory.SUPPORT_DTD, false);
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security property SUPPORT_DTD on XMLInputFactory", e);
}
Comment thread
vshaniga marked this conversation as resolved.
setFile(((FileSplit) inSplit).getPath());
fs = file.getFileSystem(context.getConfiguration());
FileStatus status = fs.getFileStatus(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public void initialize(InputSplit inSplit, TaskAttemptContext context)
initConfig(context);
initAggConf(context);
f = XMLInputFactory.newInstance();
try {
f.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security property IS_SUPPORTING_EXTERNAL_ENTITIES on XMLInputFactory", e);
}
try {
f.setProperty(XMLInputFactory.SUPPORT_DTD, false);
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security property SUPPORT_DTD on XMLInputFactory", e);
}
Comment thread
vshaniga marked this conversation as resolved.
setFile(((FileSplit) inSplit).getPath());
fs = file.getFileSystem(context.getConfiguration());

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/marklogic/mapreduce/DOMDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.xml.XMLConstants;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
Expand Down Expand Up @@ -68,6 +69,16 @@ public class DOMDocument extends ForestDocument {
private static synchronized TransformerFactory getTransformerFactory() {
if (transformerFactory == null) {
transformerFactory = TransformerFactory.newInstance();
try {
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security attribute ACCESS_EXTERNAL_DTD on TransformerFactory", e);
}
try {
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security attribute ACCESS_EXTERNAL_STYLESHEET on TransformerFactory", e);
}
Comment thread
vshaniga marked this conversation as resolved.
}

return transformerFactory;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/marklogic/mapreduce/JSONDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.xml.XMLConstants;
import javax.xml.transform.TransformerFactory;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -48,6 +49,16 @@ public class JSONDocument extends ForestDocument {
private static synchronized TransformerFactory getTransformerFactory() {
if (transformerFactory == null) {
transformerFactory = TransformerFactory.newInstance();
try {
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security attribute ACCESS_EXTERNAL_DTD on TransformerFactory", e);
}
try {
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
} catch (IllegalArgumentException e) {
LOG.warn("Failed configuring XXE-prevention security attribute ACCESS_EXTERNAL_STYLESHEET on TransformerFactory", e);
}
Comment thread
vshaniga marked this conversation as resolved.
}

return transformerFactory;
Expand Down
Loading