Fix XXE_SAXPARSER SpotBugs violations (#6052)

This commit is contained in:
Basil Crow authored and GitHub committed 2021-12-14 10:49:51 -08:00
1 parent cd3b1f77c8
commit 485c9b0966
4 files changed
+12 -16

No files matched your search

+5 -1
View File
@@ -110,6 +110,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import jenkins.ClassLoaderReflectionToolkit;
@@ -2108,7 +2109,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
public Map<String,VersionNumber> parseRequestedPlugins(InputStream configXml) throws IOException {
final Map<String,VersionNumber> requestedPlugins = new TreeMap<>();
try {
SAXParserFactory.newInstance().newSAXParser().parse(configXml, new DefaultHandler() {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
spf.newSAXParser().parse(configXml, new DefaultHandler() {
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
String plugin = attributes.getValue("plugin");
if (plugin == null) {