aboutsummaryrefslogtreecommitdiffstats
path: root/feature-state-management
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-09-02 10:39:35 -0400
committerJim Hahn <jrh3@att.com>2021-09-03 10:40:45 -0400
commitbe601e6cbfe509d02741d33add13ff1774c86245 (patch)
tree5e178a1a749f897430669db824e5aab74c1ebcdf /feature-state-management
parenteeecf007158660b8e279467146fcee14e71dc804 (diff)
Fix sonar security issues in drools-pdp
Fixed sonar security issues: - set permissions of temporary files; modified to use utility from policy-common Issue-ID: POLICY-3289 Change-Id: I55b70175429052e0dfaf5939fa6b940f191d9267 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-state-management')
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java16
1 files changed, 3 insertions, 13 deletions
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index 6ff6a756..ecc4acc6 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -24,7 +24,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
@@ -37,6 +36,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.onap.policy.common.im.IntegrityMonitorException;
+import org.onap.policy.common.utils.resources.DirectoryUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -152,17 +152,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
/*
* 1) create temporary directory
*/
- data.dir = Files.createTempDirectory("auditRepo");
- logger.info("RepositoryAudit: temporary directory = {}", data.dir);
-
- // set its permissions
- var file = data.dir.toFile();
- if (!file.setReadable(true, true) || !file.setWritable(true, true) || !file.setExecutable(true, true)) {
- logger.warn("cannot set directory permissions for {}", file);
- }
-
- // ensure nothing has been written to it
- FileUtils.cleanDirectory(file);
+ data.dir = DirectoryUtils.createTempDirectory("auditRepo");
// nested 'pom.xml' file and 'repo' directory
final Path pom = data.dir.resolve("pom.xml");
@@ -213,7 +203,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
/*
* 7) Remove the temporary directory
*/
- FileUtils.forceDelete(file);
+ FileUtils.forceDelete(data.dir.toFile());
}