Skip to content

Commit

Permalink
SECURITY-1751: enable secure processing not to allow XXE exploit on X…
Browse files Browse the repository at this point in the history
…ML files
  • Loading branch information
fedepell authored and jaruzafa committed Feb 8, 2020
1 parent 54bf52e commit 7a913b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/fitnesse/ConvertReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.*;
import java.io.*;

/**
Expand All @@ -18,6 +19,8 @@ public static void generateJunitResult(FilePath inputFilePath, FilePath outputFi
Source stylesheetSource = new StreamSource(reader);

TransformerFactory factory = TransformerFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

Transformer transformer = factory.newTransformer(stylesheetSource);

Source inputSource = new StreamSource(inputFilePath.read());
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/hudson/plugins/fitnesse/FitnessePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.stream.StreamSource;
import javax.xml.*;

public class FitnessePlugin extends Plugin {
static Templates templates;
Expand All @@ -31,6 +32,7 @@ private static void initTemplate() throws TransformerFactoryConfigurationError,

StreamSource xslSource = new StreamSource(isDeBom);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
templates = transformerFactory.newTemplates(xslSource);
} finally {
if (is != null)
Expand Down

0 comments on commit 7a913b9

Please # to comment.