Skip to content

Commit

Permalink
[SECURITY-2394] Prevent XXE (#205)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Straube <alexander.straube@gmail.com>
  • Loading branch information
Alexander Straube and a-st committed Apr 7, 2022
1 parent 13371ad commit b0b4e74
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
Expand Up @@ -90,6 +90,7 @@ public static boolean isXmlFile(File file) throws IOException {
*/
PerformanceReport parseXml(File reportFile) throws Exception {
final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setValidating(false);
factory.setNamespaceAware(false);

Expand Down
Expand Up @@ -51,6 +51,7 @@ public String getDefaultGlobPattern() {
PerformanceReport parse(File reportFile) throws Exception {

final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setValidating(false);
factory.setNamespaceAware(false);

Expand Down
Expand Up @@ -144,6 +144,7 @@ private static String detectXMLFileType(String reportPath) throws IOException {
@VisibleForTesting
protected static String detectXMLFileType(final InputStream in) throws XMLStreamException {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
XMLEventReader eventReader = inputFactory.createXMLEventReader(in);

while (eventReader.hasNext()) {
Expand Down
Expand Up @@ -56,6 +56,7 @@ private PerformanceReport readFromXML(File reportFile) throws Exception {

DocumentBuilderFactory dbFactory
= DocumentBuilderFactory.newInstance();
dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(reportFile);
doc.getDocumentElement().normalize();
Expand Down

8 comments on commit b0b4e74

@aag1i
Copy link

@aag1i aag1i commented on b0b4e74 May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dears,

When these updates will be committed on Jenkins.io?

Thanks

@parhedberg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dears,

When these updates will be committed on Jenkins.io?

Thanks

+1 on this

@dv-morais
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dears,

When these updates will be committed on Jenkins.io?

Thanks

I'm VERY interested as well.
+1 as well.

@peterwalkley
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interested in this being available officially on jenkins.io too.

@AndrewsTDA
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news on when this might be officially available on jenkins.io?

@jhabriel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@planesweep
Copy link

@planesweep planesweep commented on b0b4e74 Oct 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 - please create a release and make it officially available via jenkins.io

@malki-akamai
Copy link

@malki-akamai malki-akamai commented on b0b4e74 Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, any updates on a new release?

Please sign in to comment.