This commit is contained in:
Greg DiCristofaro 2023-07-27 19:41:29 -04:00
parent e3353b2916
commit dc9c212db5
2 changed files with 38 additions and 2 deletions

View File

@ -33,6 +33,11 @@ MalwareScanIngestModule_ShareProcessing_noLookupsRemaining_desc=There are no mor
MalwareScanIngestModule_ShareProcessing_noLookupsRemaining_title=No remaining lookups
MalwareScanIngestModule_ShareProcessing_noUploadsRemaining_desc=There are no more remaining file uploads for this license at this time. File uploading will be disabled.
MalwareScanIngestModule_ShareProcessing_noUploadsRemaining_title=No remaining file uploads
MalwareScanIngestModule_uploadFile_noRemainingFileUploads_desc=There are no more file uploads on this license at this time. File uploads will be disabled for remaining uploads.
MalwareScanIngestModule_uploadFile_noRemainingFileUploads_title=No Remaining File Uploads
# {0} - objectId
MalwareScanIngestModule_uploadFile_notUploadable_desc=A file did not meet requirements for upload (object id: {0}).
MalwareScanIngestModule_uploadFile_notUploadable_title=Not Able to Upload
MalwareScanIngestModuleFactory_description=The malware scan ingest module queries the Cyber Triage cloud API for any possible malicious executables.
MalwareScanIngestModuleFactory_displayName=Cyber Triage Malware Scanner
MalwareScanIngestModuleFactory_version=1.0.0

View File

@ -27,7 +27,6 @@ import com.basistech.df.cybertriage.autopsy.ctapi.json.LicenseInfo;
import com.basistech.df.cybertriage.autopsy.ctapi.json.MalwareResultBean.Status;
import com.basistech.df.cybertriage.autopsy.ctapi.json.MetadataUploadRequest;
import com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud.CTLicensePersistence;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.MessageFormat;
@ -560,6 +559,18 @@ public class MalwareScanIngestModule implements FileIngestModule {
return Collections.emptyList();
}
// while we have a valid auth token, also check file uploads.
if (ingestJobState.isUploadUnknownFiles()) {
long remainingUploads = remaining(authTokenResponse.getFileUploadLimit(), authTokenResponse.getHashLookupCount());
if (remainingUploads <= 0) {
ingestJobState.disableUploadUnknownFiles();
notifyWarning(
Bundle.MalwareScanIngestModule_uploadFile_noRemainingFileUploads_title(),
Bundle.MalwareScanIngestModule_uploadFile_noRemainingFileUploads_desc(),
null);
}
}
// using auth token, get results
return ctApiDAO.getReputationResults(
new AuthenticatedRequestData(ingestJobState.getLicenseInfo().getDecryptedLicense(), authTokenResponse),
@ -598,13 +609,27 @@ public class MalwareScanIngestModule implements FileIngestModule {
* @throws CTCloudException
* @throws TskCoreException
*/
@Messages({
"MalwareScanIngestModule_uploadFile_notUploadable_title=Not Able to Upload",
"# {0} - objectId",
"MalwareScanIngestModule_uploadFile_notUploadable_desc=A file did not meet requirements for upload (object id: {0}).",
"MalwareScanIngestModule_uploadFile_noRemainingFileUploads_title=No Remaining File Uploads",
"MalwareScanIngestModule_uploadFile_noRemainingFileUploads_desc=There are no more file uploads on this license at this time. File uploads will be disabled for remaining uploads.",})
private boolean uploadFile(IngestJobState ingestJobState, String md5, long objId) throws CTCloudException, TskCoreException, NoSuchAlgorithmException, ReadContentInputStream.ReadContentInputStreamException {
if (!ingestJobState.isUploadUnknownFiles() || ingestJobState.getIngestJobContext().fileIngestIsCancelled()) {
return false;
}
AbstractFile af = ingestJobState.getTskCase().getAbstractFileById(objId);
if (af == null || !isUploadable(af)) {
if (af == null) {
return false;
}
if (!isUploadable(af)) {
notifyWarning(
Bundle.MalwareScanIngestModule_uploadFile_notUploadable_title(),
Bundle.MalwareScanIngestModule_uploadFile_notUploadable_desc(objId),
null);
return false;
}
@ -615,6 +640,11 @@ public class MalwareScanIngestModule implements FileIngestModule {
} else if (remaining(authTokenResponse.getFileUploadLimit(), authTokenResponse.getFileUploadCount()) <= 0) {
// don't proceed with upload if reached limit
ingestJobState.disableUploadUnknownFiles();
notifyWarning(
Bundle.MalwareScanIngestModule_uploadFile_noRemainingFileUploads_title(),
Bundle.MalwareScanIngestModule_uploadFile_noRemainingFileUploads_desc(),
null);
return false;
} else if (ingestJobState.getIngestJobContext().fileIngestIsCancelled()) {
return false;
@ -640,6 +670,7 @@ public class MalwareScanIngestModule implements FileIngestModule {
/**
* Does long polling for any pending results.
*
* @param ingestJobState The state of the ingest job.
* @throws InterruptedException
* @throws CTCloudException