Hi everyone,
the java:S2755 has wrong solution for TransformerFactory in " How can I fix it in Java SE?" Section, point 3:
// `setAttribute` variant, applicable to:
// - DocumentBuilderFactory
// - TransformerFactory
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
TransformerFactory cannot recognize XMLConstants.ACCESS_EXTERNAL_SCHEMA and fails with the following exception: java.lang.IllegalArgumentException: TransformerFactory does not recognize attribute “http://javax.xml.XMLConstants/property/accessExternalSchema”
Proper solution can be found here: XML External Entity Prevention - OWASP Cheat Sheet Series
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- SonarQube Version: Community Edition Version 10.3 (build 82913)
- SonarQube is deployed via Docker