Skip to content

Commit

Permalink
[SECURITY-1899]
Browse files Browse the repository at this point in the history
  • Loading branch information
mythsunwind committed Mar 25, 2022
1 parent 1cac8aa commit c4ab38f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import hudson.tasks.junit.CaseResult;
import hudson.tasks.test.TestObject;
import hudson.util.io.ParserConfigurator;
import org.xml.sax.SAXException;

/**
* Result of one test suite augmented with flaky information.
Expand Down Expand Up @@ -101,11 +102,14 @@ public static class SuiteResultParserConfigurationContext {
* This method returns a collection, as a single XML may have multiple <testsuite>
* elements wrapped into the top-level <testsuites>.
*/
static List<FlakySuiteResult> parse(File xmlReport, boolean keepLongStdio) throws DocumentException, IOException, InterruptedException {
static List<FlakySuiteResult> parse(File xmlReport, boolean keepLongStdio) throws DocumentException, IOException, InterruptedException, SAXException {
List<FlakySuiteResult> r = new ArrayList<FlakySuiteResult>();

// parse into DOM
SAXReader saxReader = new SAXReader();
saxReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
saxReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
saxReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
ParserConfigurator.applyConfiguration(saxReader,new SuiteResultParserConfigurationContext(xmlReport));

Document result = saxReader.read(xmlReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.MetaTabulatedResult;
import hudson.tasks.test.TestObject;
import org.xml.sax.SAXException;

/**
* Root of all the test results for one build, including flaky runs information.
Expand Down Expand Up @@ -119,13 +120,7 @@ public FlakyTestResult(TestResult testResult) {
try {
suites.addAll(FlakySuiteResult.parse(new File(suiteResult.getFile()), true));
testResultInstance = testResult;
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (NullPointerException e) {
} catch (DocumentException | IOException | InterruptedException | NullPointerException | SAXException e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -294,9 +289,7 @@ public void parse(File reportFile) throws IOException {
try {
for (FlakySuiteResult suiteResult : FlakySuiteResult.parse(reportFile, keepLongStdio))
add(suiteResult);
} catch (InterruptedException e) {
throw new IOException("Failed to read "+reportFile,e);
} catch (RuntimeException e) {
} catch (InterruptedException | SAXException | RuntimeException e) {
throw new IOException("Failed to read "+reportFile,e);
} catch (DocumentException e) {
if (!reportFile.getPath().endsWith(".xml")) {
Expand Down

0 comments on commit c4ab38f

Please # to comment.