2
2
3
3
import static com .sap .oss .phosphor .fosstars .model .Subject .cast ;
4
4
import static com .sap .oss .phosphor .fosstars .model .feature .oss .OssFeatures .VULNERABILITIES_IN_ARTIFACT ;
5
+ import static com .sap .oss .phosphor .fosstars .model .other .Utils .delete ;
5
6
import static com .sap .oss .phosphor .fosstars .model .other .Utils .setOf ;
6
7
7
8
import com .sap .oss .phosphor .fosstars .data .DataProvider ;
@@ -78,6 +79,16 @@ public class VulnerabilitiesFromOwaspDependencyCheck implements DataProvider {
78
79
*/
79
80
private static final String REPORT_DIR = String .format ("%s/reports" , DEFAULT_DOWNLOAD_DIRECTORY );
80
81
82
+ /**
83
+ * The directory to save OWASP Dependency-Check temporary files.
84
+ */
85
+ private static final String TEMP_DIR = String .format ("%s/tmp" , DEFAULT_DOWNLOAD_DIRECTORY );
86
+
87
+ /**
88
+ * The directory to save OWASP Dependency-Check DB file.
89
+ */
90
+ private static final String DB_DIR = String .format ("%s/db" , DEFAULT_DOWNLOAD_DIRECTORY );
91
+
81
92
/**
82
93
* The Dependency-Check report file type.
83
94
*/
@@ -100,6 +111,8 @@ public class VulnerabilitiesFromOwaspDependencyCheck implements DataProvider {
100
111
public VulnerabilitiesFromOwaspDependencyCheck () {
101
112
settings = new Settings ();
102
113
settings .setString (Settings .KEYS .DATA_DIRECTORY , DEFAULT_DOWNLOAD_DIRECTORY );
114
+ settings .setString (Settings .KEYS .TEMP_DIRECTORY , TEMP_DIR );
115
+ settings .setString (Settings .KEYS .H2_DATA_DIRECTORY , DB_DIR );
103
116
}
104
117
105
118
/**
@@ -245,6 +258,8 @@ Optional<OwaspDependencyCheckEntry> scan(MavenArtifact artifact) throws IOExcept
245
258
try (Engine engine = new Engine (settings )) {
246
259
analyze (engine , filePath .get ().toFile (), exceptionCollection );
247
260
return process (engine , filePath .get ().toFile ().getName (), exceptionCollection );
261
+ } finally {
262
+ delete (TEMP_DIR , JAR_DIR , REPORT_DIR );
248
263
}
249
264
}
250
265
return Optional .empty ();
0 commit comments