@@ -85,8 +85,8 @@ public void uploadFile3() throws IOException {
8585 // BAD: Upload file to user specified path without validation through request attribute
8686 public void uploadFile4 () throws IOException {
8787 String savePath = getPara ("dir" );
88- setAttr ("uploadDir " , savePath );
89- String requestUploadDir = getAttr ("uploadDir " );
88+ setAttr ("uploadDir2 " , savePath );
89+ String requestUploadDir = getAttr ("uploadDir2 " );
9090
9191 File file = getFile ("fileParam" ).getFile ();
9292 String finalFilePath = BASE_PATH + requestUploadDir ;
@@ -108,8 +108,8 @@ public void uploadFile4() throws IOException {
108108 // BAD: Upload file to user specified path without validation through session object (not detected)
109109 public void uploadFile5 () throws IOException {
110110 String savePath = getPara ("dir" );
111- getSession ().setAttribute ("uploadDir " , savePath );
112- String sessionUploadDir = getSessionAttr ("uploadDir " );
111+ getSession ().setAttribute ("uploadDir3 " , savePath );
112+ String sessionUploadDir = getSessionAttr ("uploadDir3 " );
113113
114114 File file = getFile ("fileParam" ).getFile ();
115115 String finalFilePath = BASE_PATH + sessionUploadDir ;
@@ -130,8 +130,8 @@ public void uploadFile5() throws IOException {
130130
131131 // GOOD: Upload file to a system path from a request object
132132 public void uploadFile6 () throws IOException {
133- setAttr ("uploadDir " , "/data/upload_dir/" );
134- String requestUploadDir = getAttr ("uploadDir " );
133+ setAttr ("uploadDir4 " , "/data/upload_dir/" );
134+ String requestUploadDir = getAttr ("uploadDir4 " );
135135
136136 File file = getFile ("fileParam" ).getFile ();
137137 String finalFilePath = BASE_PATH + requestUploadDir ;
@@ -153,9 +153,9 @@ public void uploadFile6() throws IOException {
153153 // GOOD: Upload file to a system path from a request object
154154 public void uploadFile7 () throws IOException {
155155 String savePath = getPara ("dir" );
156- setAttr ("uploadDir " , savePath );
156+ setAttr ("uploadDir5 " , savePath );
157157 setAttr ("realUploadDir" , "/data/upload_dir/" );
158- String requestUploadDir = getAttr ("realUploadDir " );
158+ String requestUploadDir = getAttr ("realUploadDir5 " );
159159
160160 File file = getFile ("fileParam" ).getFile ();
161161 String finalFilePath = BASE_PATH + requestUploadDir ;
0 commit comments