When I do scan using fortify tool, I got some issues under "XML External Entity Injection".
TransformerFactory trfactory = TransformerFactory.newInstance();
This is the place where it is showing error. I have given the below fix as suggested by fortify
trfactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
trfactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
but still the issues are not fixed. How to fix this issue?
TransformerFactory trfactory = TransformerFactory.newInstance();
trfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
This would be sufficient.