Update EncryptionDetectionFileIngestModule.java

make map static and address codacy issue
This commit is contained in:
Mark McKinnon 2019-09-20 16:54:54 -04:00
parent 7334e8b6b0
commit a3c34329fc

View File

@ -78,7 +78,7 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
private static final String[] FILE_IGNORE_LIST = {"hiberfile.sys", "pagefile.sys"}; private static final String[] FILE_IGNORE_LIST = {"hiberfile.sys", "pagefile.sys"};
private final Map<String, String> knownEncryptedLocationExtensions = createLocationExtensionMap(); private static final Map<String, String> knownEncryptedLocationExtensions = createLocationExtensionMap();
private final IngestServices services = IngestServices.getInstance(); private final IngestServices services = IngestServices.getInstance();
private final Logger logger = services.getLogger(EncryptionDetectionModuleFactory.getModuleName()); private final Logger logger = services.getLogger(EncryptionDetectionModuleFactory.getModuleName());
@ -427,20 +427,21 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter
*/ */
private boolean checkFileLocationExtension(AbstractFile file) { private boolean checkFileLocationExtension(AbstractFile file) {
String filePath = file.getParentPath().replace("/", ""); String filePath = file.getParentPath().replace("/", "");
if (knownEncryptedLocationExtensions.containsKey(filePath)) { if ((knownEncryptedLocationExtensions.containsKey(filePath))
if (knownEncryptedLocationExtensions.get(filePath).equals(file.getNameExtension())) { && (knownEncryptedLocationExtensions.get(filePath).equals(file.getNameExtension())))
{
return true; return true;
} }
}
return false; return false;
} }
/* /*
* This method creates the map of paths and extensions that are known to have encrypted files * This method creates the map of paths and extensions that are known to
* have encrypted files
* *
* @return Map of path and extension of files * @return Map of path and extension of files
*/ */
private Map<String, String> createLocationExtensionMap() { private static Map<String, String> createLocationExtensionMap() {
Map<String, String> locationExtensionMap = new HashMap<String, String>(); Map<String, String> locationExtensionMap = new HashMap<String, String>();
locationExtensionMap.put(".android_secure", "asec"); locationExtensionMap.put(".android_secure", "asec");
return locationExtensionMap; return locationExtensionMap;