77import org .w3c .dom .Node ;
88import org .xml .sax .SAXException ;
99
10+ import javax .xml .XMLConstants ;
1011import javax .xml .parsers .DocumentBuilder ;
1112import javax .xml .parsers .DocumentBuilderFactory ;
1213import javax .xml .parsers .ParserConfigurationException ;
@@ -60,8 +61,8 @@ public String getPSU() {
6061 for (String patch_file : patch_files ){
6162 Document doc = readXmlFile (patch_file );
6263 String descrip = description (doc , "//@description" );
63- LOGGER .info ("Description {0}" , descrip );
64- if (descrip .startsWith ("WLS PATCH SET UPDATE" )) {
64+ LOGGER .fine ("Description {0}" , descrip );
65+ if (descrip != null && descrip .startsWith ("WLS PATCH SET UPDATE" )) {
6566 int idx = descrip .lastIndexOf ('.' );
6667 String psu = descrip .substring (idx +1 );
6768 LOGGER .info ("PSU Is {0}" , psu );
@@ -79,8 +80,7 @@ public String getPSU() {
7980 */
8081 public List <String > findPatchFiles () {
8182 List <String > patch_files = new ArrayList <String >();
82- try {
83- DirectoryStream <Path > stream = Files .newDirectoryStream (new File (patches_home ).toPath ());
83+ try (DirectoryStream <Path > stream = Files .newDirectoryStream (new File (patches_home ).toPath ())){
8484 for (Path path : stream ) {
8585 patch_files .add (path .toString ());
8686 }
@@ -97,6 +97,16 @@ public List<String> findPatchFiles() {
9797 */
9898 public Document readXmlFile (String path ) {
9999 DocumentBuilderFactory dbf = DocumentBuilderFactory .newInstance ();
100+ try {
101+ dbf .setXIncludeAware (false );
102+ dbf .setExpandEntityReferences (false );
103+ dbf .setFeature ("http://apache.org/xml/features/disallow-doctype-decl" , true );
104+ dbf .setAttribute (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
105+ dbf .setAttribute (XMLConstants .ACCESS_EXTERNAL_SCHEMA , "" );
106+ dbf .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
107+ } catch (ParserConfigurationException pce ) {
108+ LOGGER .warning ("Unable to set feature in DocumentBuilderFactory : {0}" );
109+ }
100110
101111 Document doc = null ;
102112 try {
0 commit comments