Ignore:
Timestamp:
2016-06-16T19:10:53+02:00 (3 years ago)
Author:
Don-vip
Message:

findbugs security - XML Parsing Vulnerable to XXE - enable FEATURE_SECURE_PROCESSING for DOM builders

Location:
trunk/src/org/openstreetmap/josm/io
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java

    r10212 r10404  
    99import java.util.List;
    1010
    11 import javax.xml.parsers.DocumentBuilderFactory;
    1211import javax.xml.parsers.ParserConfigurationException;
    1312import javax.xml.xpath.XPath;
     
    2019import org.openstreetmap.josm.data.osm.UserInfo;
    2120import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     21import org.openstreetmap.josm.tools.Utils;
    2222import org.openstreetmap.josm.tools.XmlParsingException;
    2323import org.openstreetmap.josm.tools.date.DateUtils;
     
    175175            monitor.indeterminateSubTask(tr("Reading user info ..."));
    176176            try (InputStream in = getInputStream("user/details", monitor.createSubTaskMonitor(1, true), reason)) {
    177                 return buildFromXML(
    178                         DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in)
    179                 );
     177                return buildFromXML(Utils.parseSafeDOM(in));
    180178            }
    181179        } catch (OsmTransferException e) {
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r10216 r10404  
    1818import javax.imageio.ImageIO;
    1919import javax.xml.parsers.DocumentBuilder;
    20 import javax.xml.parsers.DocumentBuilderFactory;
    2120import javax.xml.parsers.ParserConfigurationException;
    2221
     
    152151
    153152        try {
    154             DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    155             builderFactory.setValidating(false);
    156             builderFactory.setNamespaceAware(true);
    157             DocumentBuilder builder = builderFactory.newDocumentBuilder();
     153            DocumentBuilder builder = Utils.newSafeDOMBuilder();
    158154            builder.setEntityResolver(new EntityResolver() {
    159155                @Override
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r10208 r10404  
    2929import javax.swing.JOptionPane;
    3030import javax.swing.SwingUtilities;
    31 import javax.xml.parsers.DocumentBuilder;
    32 import javax.xml.parsers.DocumentBuilderFactory;
    3331import javax.xml.parsers.ParserConfigurationException;
    3432
     
    633631
    634632        try {
    635             DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    636             builderFactory.setValidating(false);
    637             builderFactory.setNamespaceAware(true);
    638             DocumentBuilder builder = builderFactory.newDocumentBuilder();
    639             Document document = builder.parse(josIS);
    640             parseJos(document, progressMonitor);
     633            parseJos(Utils.parseSafeDOM(josIS), progressMonitor);
    641634        } catch (SAXException e) {
    642635            throw new IllegalDataException(e);
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r10212 r10404  
    1919
    2020import javax.xml.parsers.DocumentBuilder;
    21 import javax.xml.parsers.DocumentBuilderFactory;
    2221import javax.xml.parsers.ParserConfigurationException;
    2322import javax.xml.transform.OutputKeys;
     
    201200     */
    202201    public Document createJosDocument() throws IOException {
    203         DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    204         builderFactory.setValidating(false);
    205         builderFactory.setNamespaceAware(true);
    206202        DocumentBuilder builder = null;
    207203        try {
    208             builder = builderFactory.newDocumentBuilder();
     204            builder = Utils.newSafeDOMBuilder();
    209205        } catch (ParserConfigurationException e) {
    210             throw new RuntimeException(e);
     206            throw new IOException(e);
    211207        }
    212208        Document doc = builder.newDocument();
Note: See TracChangeset for help on using the changeset viewer.