7
7
import org .w3c .dom .Node ;
8
8
import org .xml .sax .SAXException ;
9
9
10
+ import javax .xml .XMLConstants ;
10
11
import javax .xml .parsers .DocumentBuilder ;
11
12
import javax .xml .parsers .DocumentBuilderFactory ;
12
13
import javax .xml .parsers .ParserConfigurationException ;
@@ -60,8 +61,8 @@ public String getPSU() {
60
61
for (String patch_file : patch_files ){
61
62
Document doc = readXmlFile (patch_file );
62
63
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" )) {
65
66
int idx = descrip .lastIndexOf ('.' );
66
67
String psu = descrip .substring (idx +1 );
67
68
LOGGER .info ("PSU Is {0}" , psu );
@@ -79,8 +80,7 @@ public String getPSU() {
79
80
*/
80
81
public List <String > findPatchFiles () {
81
82
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 ())){
84
84
for (Path path : stream ) {
85
85
patch_files .add (path .toString ());
86
86
}
@@ -97,6 +97,16 @@ public List<String> findPatchFiles() {
97
97
*/
98
98
public Document readXmlFile (String path ) {
99
99
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
+ }
100
110
101
111
Document doc = null ;
102
112
try {
0 commit comments