From 5368f84853e92e99b3df1a569af6eff6d29714af Mon Sep 17 00:00:00 2001
From: Greg DiCristofaro <gregd@basistech.com>
Date: Tue, 1 Aug 2023 21:04:30 -0400
Subject: [PATCH] change for package scope

---
 .../autopsy/ctapi/CTCloudHttpClient.java      |  2 +-
 .../cybertriage/autopsy/ctapi/Constants.java  |  2 +-
 .../autopsy/ctapi/ProxySettings.java          |  2 +-
 .../ctoptions/ctcloud/CTLicenseDialog.java    |  2 +-
 .../ctcloud/CTLicensePersistence.java         |  1 -
 .../autopsy/ctoptions/ctcloud/EULADialog.java |  2 +-
 .../autopsy/malwarescan/BatchProcessor.java   |  6 +-
 .../autopsy/malwarescan/FileUpload.java       | 93 -------------------
 .../malwarescan/MalwareScanIngestModule.java  |  2 +-
 .../malwarescan/UsernameAnonymizer.java       |  2 +-
 10 files changed, 8 insertions(+), 106 deletions(-)
 delete mode 100644 Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/FileUpload.java

diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/CTCloudHttpClient.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/CTCloudHttpClient.java
index 06e5fb7fcd..0374fd2b2b 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/CTCloudHttpClient.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/CTCloudHttpClient.java
@@ -67,7 +67,7 @@
 /**
  * Makes the http requests to CT cloud.
  */
-public class CTCloudHttpClient {
+class CTCloudHttpClient {
 
     private static final CTCloudHttpClient instance = new CTCloudHttpClient();
     private static final Logger LOGGER = Logger.getLogger(CTCloudHttpClient.class.getName());
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/Constants.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/Constants.java
index 9587b3cd44..8290d6621d 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/Constants.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/Constants.java
@@ -23,7 +23,7 @@
 /**
  * Constants regarding connections to cyber triage cloud.
  */
-final public class Constants {
+final class Constants {
 
     public static final String CYBER_TRIAGE = "CyberTriage";
 
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/ProxySettings.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/ProxySettings.java
index f710a6ab1b..cbd538d01b 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/ProxySettings.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctapi/ProxySettings.java
@@ -32,7 +32,7 @@
  * Taken from https://raw.githubusercontent.com/apache/netbeans/master/platform/o.n.core/src/org/netbeans/core/ProxySettings.java
  * @author Jiri Rechtacek
  */
-public class ProxySettings {
+class ProxySettings {
     
     public static final String PROXY_HTTP_HOST = "proxyHttpHost";   // NOI18N
     public static final String PROXY_HTTP_PORT = "proxyHttpPort";   // NOI18N
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicenseDialog.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicenseDialog.java
index 608ea63040..3bff998901 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicenseDialog.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicenseDialog.java
@@ -27,7 +27,7 @@
 /**
  * License dialog
  */
-public class CTLicenseDialog extends javax.swing.JDialog {
+class CTLicenseDialog extends javax.swing.JDialog {
 
     private static final Pattern LICENSE_PATTERN = Pattern.compile("^\\s*[a-zA-Z0-9\\-]+?\\s*$");
     private String licenseString = null;
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicensePersistence.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicensePersistence.java
index e95d9e7279..717c4f4321 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicensePersistence.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTLicensePersistence.java
@@ -26,7 +26,6 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.File;
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Optional;
 import java.util.logging.Level;
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/EULADialog.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/EULADialog.java
index 31056e1f2a..0279cafb9b 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/EULADialog.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/EULADialog.java
@@ -36,7 +36,7 @@
 /**
  * Dialog for displaying the Cyber Triage EULA before the license is saved.
  */
-public class EULADialog extends javax.swing.JDialog {
+class EULADialog extends javax.swing.JDialog {
 
     private static final Logger LOGGER = Logger.getLogger(EULADialog.class.getName());
     private static final String EULA_RESOURCE = "EULA.htm";
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/BatchProcessor.java b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/BatchProcessor.java
index eab025a641..a65d319dc2 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/BatchProcessor.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/BatchProcessor.java
@@ -21,14 +21,10 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.function.Consumer;
 
 /**
@@ -36,7 +32,7 @@
  * blocks (and subsequently add and flush operations) until previous batch
  * finishes.
  */
-public class BatchProcessor<T> {
+class BatchProcessor<T> {
 
     private ExecutorService processingExecutorService = Executors.newSingleThreadExecutor();
 
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/FileUpload.java b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/FileUpload.java
deleted file mode 100644
index 4803793514..0000000000
--- a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/FileUpload.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Autopsy Forensic Browser
- *
- * Copyright 2023 Basis Technology Corp.
- * Contact: carrier <at> sleuthkit <dot> org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.basistech.df.cybertriage.autopsy.malwarescan;
-
-import com.basistech.df.cybertriage.autopsy.ctapi.CTApiDAO;
-import com.basistech.df.cybertriage.autopsy.ctapi.CTCloudException;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.AuthTokenResponse;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.AuthenticatedRequestData;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.CTCloudBean;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.DecryptedLicenseResponse;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.MalwareResultBean.Status;
-import com.basistech.df.cybertriage.autopsy.ctapi.json.MetadataUploadRequest;
-import org.apache.commons.lang3.StringUtils;
-import org.sleuthkit.datamodel.AbstractFile;
-import org.sleuthkit.datamodel.ReadContentInputStream;
-import org.sleuthkit.datamodel.SleuthkitCase;
-import org.sleuthkit.datamodel.TskCoreException;
-
-/**
- * Handles uploading of files that are unknown.
- */
-public class FileUpload {
-    private static final long MIN_UPLOAD_SIZE = 1;
-    private static final long MAX_UPLOAD_SIZE = 1_000_000_000;
-
-    private final CTApiDAO ctApiDAO = CTApiDAO.getInstance();
-
-    private boolean isUnknown(CTCloudBean cloudBean) {
-        return cloudBean != null
-                && cloudBean.getMalwareResult() != null
-                && cloudBean.getMalwareResult().getStatus() == Status.NOT_FOUND;
-    }
-
-    private boolean isUploadable(AbstractFile af) {
-        long size = af.getSize();
-        return size >= MIN_UPLOAD_SIZE && size <= MAX_UPLOAD_SIZE;
-    }
-
-    private boolean upload(SleuthkitCase skCase, DecryptedLicenseResponse decrypted, CTCloudBean cloudBean, long objId) throws CTCloudException, TskCoreException {
-        if (!isUnknown(cloudBean)) {
-            return false;
-        } 
-        
-        AbstractFile af = skCase.getAbstractFileById(objId);
-                if (af == null) {
-            return false;
-        }
-                
-        if (!isUploadable(af)) {
-            return false;
-        }
-        
-        // get auth token / file upload url
-        AuthTokenResponse authTokenResponse = ctApiDAO.getAuthToken(decrypted, true);
-        if (StringUtils.isBlank(authTokenResponse.getFileUploadUrl())) {
-            throw new CTCloudException(CTCloudException.ErrorCode.NETWORK_ERROR);
-        }
-
-        // upload bytes
-        ReadContentInputStream fileInputStream = new ReadContentInputStream(af);
-        ctApiDAO.uploadFile(authTokenResponse.getFileUploadUrl(), af.getName(), fileInputStream);
-
-        // upload metadata
-        MetadataUploadRequest metaRequest = new MetadataUploadRequest()
-                .setCreatedDate(af.getCrtime())
-                .setFilePath(af.getUniquePath())
-                .setFileSizeBytes(af.getSize())
-                .setFileUploadUrl(authTokenResponse.getFileUploadUrl())
-                .setMd5(af.getMd5Hash())
-                .setSha1(af.getSha1Hash())
-                .setSha256(af.getSha256Hash());
-
-        ctApiDAO.uploadMeta(new AuthenticatedRequestData(decrypted, authTokenResponse), metaRequest);
-        return true;
-    }
-
-}
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/MalwareScanIngestModule.java b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/MalwareScanIngestModule.java
index f15236cd1d..2d73effa5c 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/MalwareScanIngestModule.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/MalwareScanIngestModule.java
@@ -69,7 +69,7 @@
 /**
  * Uses CT cloud API to determine if file is malware
  */
-public class MalwareScanIngestModule implements FileIngestModule {
+class MalwareScanIngestModule implements FileIngestModule {
 
     private static final SharedProcessing sharedProcessing = new SharedProcessing();
 
diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/UsernameAnonymizer.java b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/UsernameAnonymizer.java
index 2b00ece4ab..75261ae43f 100644
--- a/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/UsernameAnonymizer.java
+++ b/Core/src/com/basistech/df/cybertriage/autopsy/malwarescan/UsernameAnonymizer.java
@@ -33,7 +33,7 @@
  * Utility class to anonymize username in paths also anonymizes hostname / ip
  * from UNC paths
  */
-public class UsernameAnonymizer {
+class UsernameAnonymizer {
 
     private static final Logger LOGGER = Logger.getLogger(UsernameAnonymizer.class.getName());
 
-- 
GitLab