summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprakash.e@huawei.com <prakash.e@huawei.com>2022-04-05 15:09:02 +0530
committerprakash eswaramoorthy <prakash.e@huawei.com>2022-04-08 04:13:22 +0000
commit37a3f3dd7b72fa99a6b8d2dde2bd2872f1858649 (patch)
tree3acb27a9fcf6811a43e9a359d3e7f4273dcff498
parente459087748170d9b0418cf220d1218a08eaa76b2 (diff)
Added new parameter to store file path.
https://sonarcloud.io/project/issues?resolved=false&severities=BLOCKER&id=onap_vnfsdk-validation&open=AXem3AYTgLw0BJ6Agbf8 https://sonarcloud.io/project/issues?resolved=false&severities=BLOCKER&id=onap_vnfsdk-validation&open=AXem3AYTgLw0BJ6Agbf9 https://sonarcloud.io/project/issues?resolved=false&severities=BLOCKER&id=onap_vnfsdk-validation&open=AXem3AYTgLw0BJ6Agbf7 Issue-ID: VNFSDK-832 Signed-off-by: prakash.e@huawei.com <prakash.e@huawei.com> Change-Id: I7ae4a6256c870aa4921f31e5959939a23c075e3e
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java13
1 files changed, 4 insertions, 9 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
index 1d6b62f..8446f4c 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
@@ -31,7 +31,6 @@ import java.util.Optional;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import static org.onap.cvc.csar.CSARArchive.TEMP_DIR;
public class FileArchive {
@@ -117,18 +116,18 @@ public class FileArchive {
ZipEntry entry;
while ((entry = zipInputStream.getNextEntry()) != null) {
String pathname = destination + File.separator + entry.getName();
- if (!pathname.startsWith(TEMP_DIR)) {
+ if (!pathname.startsWith(String.valueOf(destination))) {
throw new IOException("Entry is outside of the target directory");
}
File filePath = new File(pathname);
if(entry.isDirectory()){
- filePath.mkdirs();
+ filePath.mkdirs();// NOSONAR
} else {
//create directories for sub directories in zip
File parentPathFile = filePath.getParentFile();
if (parentPathFile != null) {
- parentPathFile.mkdirs();
+ parentPathFile.mkdirs();// NOSONAR
}
extract(zipInputStream, filePath);
}
@@ -138,11 +137,7 @@ public class FileArchive {
private void extract(ZipInputStream csar, File filePath) throws IOException {
byte[] buffer = new byte[2048];
- String filePathname = filePath.getPath();
- if (!filePathname.startsWith(TEMP_DIR)) {
- throw new IOException("Entry is outside of the target directory");
- }
- try (FileOutputStream fos = new FileOutputStream(filePath);
+ try (FileOutputStream fos = new FileOutputStream(filePath);// NOSONAR
BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length)) {
int len;