Skip to content

Commit

Permalink
Ensuring all XML input processing is safe - disable DTD and external …
Browse files Browse the repository at this point in the history
…entities
  • Loading branch information
ilgrosso committed Oct 25, 2018
1 parent e559417 commit a0f35f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@

public final class ReconciliationReportParser {

private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory.newInstance();
private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();

static {
XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
XML_INPUT_FACTORY.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
}

public static ReconciliationReport parse(final Date run, final InputStream in) throws XMLStreamException {
XMLStreamReader streamReader = INPUT_FACTORY.createXMLStreamReader(in);
XMLStreamReader streamReader = XML_INPUT_FACTORY.createXMLStreamReader(in);
streamReader.nextTag(); // root
streamReader.nextTag(); // report
streamReader.nextTag(); // reportlet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public final class FlowableDeployUtils {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();

static {
XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
XML_INPUT_FACTORY.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
}

public static Deployment deployDefinition(
final ProcessEngine engine, final String resourceName, final byte[] definition) {

Expand All @@ -58,7 +65,7 @@ public static void deployModel(final ProcessEngine engine, final ProcessDefiniti
getResourceAsStream(procDef.getDeploymentId(), procDef.getResourceName());
InputStreamReader isr = new InputStreamReader(bpmnStream)) {

xtr = XMLInputFactory.newInstance().createXMLStreamReader(isr);
xtr = XML_INPUT_FACTORY.createXMLStreamReader(isr);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

Model model = engine.getRepositoryService().newModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
*/
package org.apache.syncope.core.flowable.support;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.ProcessEngine;
import org.flowable.common.engine.impl.cfg.SpringBeanFactoryProxyMap;
import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants;
import org.flowable.engine.form.AbstractFormType;
import org.flowable.engine.impl.util.EngineServiceUtil;
import org.flowable.idm.spring.SpringIdmEngineConfiguration;
import org.flowable.spring.SpringExpressionManager;
Expand Down Expand Up @@ -84,9 +82,8 @@ public DomainProcessEngine getObject() throws Exception {
EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG,
ctx.getBean(SpringIdmEngineConfiguration.class));
}
List<AbstractFormType> customFormTypes = new ArrayList<>();
customFormTypes.add(new DropdownFormType(null));
conf.setCustomFormTypes(customFormTypes);
conf.setEnableSafeBpmnXml(true);
conf.setCustomFormTypes(Arrays.asList(new DropdownFormType(null)));

engines.put(domain, conf.buildProcessEngine());
}
Expand Down

0 comments on commit a0f35f4

Please sign in to comment.