Merge pull request #515 from mrtizmo/scalpelCarver

Pulled static strings into Bundle - ScalpelCarver module
This commit is contained in:
Richard Cordovano 2014-03-07 14:47:01 -05:00
commit 65658a1cc0
8 changed files with 41 additions and 10 deletions

View File

@ -6,6 +6,14 @@
<code-name-base>org.sleuthkit.autopsy.scalpel</code-name-base> <code-name-base>org.sleuthkit.autopsy.scalpel</code-name-base>
<suite-component/> <suite-component/>
<module-dependencies> <module-dependencies>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.25.1</specification-version>
</run-dependency>
</dependency>
<dependency> <dependency>
<code-name-base>org.sleuthkit.autopsy.core</code-name-base> <code-name-base>org.sleuthkit.autopsy.core</code-name-base>
<build-prerequisite/> <build-prerequisite/>

View File

@ -4,3 +4,6 @@ OpenIDE-Module-Long-Description=\
Carves files from unallocated space at ingest time.\n\ Carves files from unallocated space at ingest time.\n\
Carved files are reanalyzed and displayed in the directory tree. Carved files are reanalyzed and displayed in the directory tree.
OpenIDE-Module-Short-Description=Carves files from unallocated space OpenIDE-Module-Short-Description=Carves files from unallocated space
ScalpelCarverIngestModule.moduleName=Scalpel Carver
ScalpelCarverIngestModule.moduleDesc.text=Carves files from unallocated space at ingest time.\
Carved files are reanalyzed and displayed in the directory tree.

View File

@ -23,6 +23,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
@ -55,8 +57,8 @@ class ScalpelCarverIngestModule { // extends IngestModuleAbstractFile { // disab
private static final Logger logger = Logger.getLogger(ScalpelCarverIngestModule.class.getName()); private static final Logger logger = Logger.getLogger(ScalpelCarverIngestModule.class.getName());
private static ScalpelCarverIngestModule instance; private static ScalpelCarverIngestModule instance;
private final String MODULE_NAME = "Scalpel Carver"; private final String MODULE_NAME = NbBundle.getMessage(ScalpelCarverIngestModule.class, "ScalpelCarverIngestModule.moduleName");
private final String MODULE_DESCRIPTION = "Carves files from unallocated space at ingest time.\nCarved files are reanalyzed and displayed in the directory tree."; private final String MODULE_DESCRIPTION = NbBundle.getMessage(ScalpelCarverIngestModule.class, "ScalpelCarverIngestModule.moduleDesc.text");
private final String MODULE_VERSION = Version.getVersion(); private final String MODULE_VERSION = Version.getVersion();
private final String MODULE_OUTPUT_DIR_NAME = "ScalpelCarver"; private final String MODULE_OUTPUT_DIR_NAME = "ScalpelCarver";
private String moduleOutputDirPath; private String moduleOutputDirPath;

View File

@ -0,0 +1,8 @@
ScalpelCarver.loadLib.errMsg.cannotLoadLib=Could not load library {0} for your environment
ScalpelCarver.loadLib.errMsg.cannotLoadLib2=Could not load library {0} for your environment
ScalpelCarver.carve.exception.libNotInit=Scalpel library is not fully initialized.
ScalpelCarver.carve.exception.invalidArgs=Invalid arguments for scalpel carving.
ScalpelCarver.carve.exception.cannotReadConfig=Cannot read libscalpel config file\: {0}
ScalpelCarver.carve.exception.cannotWriteConfig=Cannot write to libscalpel output dir\: {0}
ScalpelOutputParser.outputStart.text=The following files were carved\:
ScalpelOutputParser.toString.text=CarvedFileMeta'{'fileName\={0}, start\: {1}, size\: {2}'}'

View File

@ -25,6 +25,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.scalpel.jni.ScalpelOutputParser.CarvedFileMeta; import org.sleuthkit.autopsy.scalpel.jni.ScalpelOutputParser.CarvedFileMeta;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
@ -76,11 +78,11 @@ public class ScalpelCarver {
System.loadLibrary(id); System.loadLibrary(id);
success = true; success = true;
} catch (UnsatisfiedLinkError ex) { } catch (UnsatisfiedLinkError ex) {
String msg = "Could not load library " + id + " for your environment "; String msg = NbBundle.getMessage(ScalpelCarver.class, "ScalpelCarver.loadLib.errMsg.cannotLoadLib", id);
System.out.println(msg + ex.toString()); System.out.println(msg + ex.toString());
logger.log(Level.SEVERE, msg, ex); logger.log(Level.SEVERE, msg, ex);
} catch (Exception ex) { } catch (Exception ex) {
String msg = "Could not load library " + id + " for your environment "; String msg = NbBundle.getMessage(ScalpelCarver.class, "ScalpelCarver.loadLib.errMsg.cannotLoadLib2", id);
System.out.println(msg + ex.toString()); System.out.println(msg + ex.toString());
logger.log(Level.SEVERE, msg, ex); logger.log(Level.SEVERE, msg, ex);
} }
@ -113,24 +115,28 @@ public class ScalpelCarver {
*/ */
public List<CarvedFileMeta> carve(AbstractFile file, String configFilePath, String outputFolderPath) throws ScalpelException { public List<CarvedFileMeta> carve(AbstractFile file, String configFilePath, String outputFolderPath) throws ScalpelException {
if (!initialized) { if (!initialized) {
throw new ScalpelException("Scalpel library is not fully initialized. "); throw new ScalpelException(NbBundle.getMessage(this.getClass(), "ScalpelCarver.carve.exception.libNotInit"));
} }
//basic check of arguments before going to jni land //basic check of arguments before going to jni land
if (file == null || configFilePath == null || configFilePath.isEmpty() if (file == null || configFilePath == null || configFilePath.isEmpty()
|| outputFolderPath == null || outputFolderPath.isEmpty()) { || outputFolderPath == null || outputFolderPath.isEmpty()) {
throw new ScalpelException("Invalid arguments for scalpel carving. "); throw new ScalpelException(NbBundle.getMessage(this.getClass(), "ScalpelCarver.carve.exception.invalidArgs"));
} }
//validate the paths passed in //validate the paths passed in
File config = new File(configFilePath); File config = new File(configFilePath);
if (! config.exists() || ! config.canRead()) { if (! config.exists() || ! config.canRead()) {
throw new ScalpelException("Cannot read libscalpel config file: " + configFilePath); throw new ScalpelException(
NbBundle.getMessage(this.getClass(), "ScalpelCarver.carve.exception.cannotReadConfig",
configFilePath));
} }
File outDir = new File(outputFolderPath); File outDir = new File(outputFolderPath);
if (! outDir.exists() || ! outDir.canWrite()) { if (! outDir.exists() || ! outDir.canWrite()) {
throw new ScalpelException("Cannot write to libscalpel output dir: " + outputFolderPath); throw new ScalpelException(
NbBundle.getMessage(this.getClass(), "ScalpelCarver.carve.exception.cannotWriteConfig",
outputFolderPath));
} }
final String carverInputId = file.getId() + ": " + file.getName(); final String carverInputId = file.getId() + ": " + file.getName();

View File

@ -25,6 +25,8 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.openide.util.NbBundle;
import org.sleuthkit.datamodel.TskFileRange; import org.sleuthkit.datamodel.TskFileRange;
/** /**
@ -32,7 +34,8 @@ import org.sleuthkit.datamodel.TskFileRange;
*/ */
public class ScalpelOutputParser { public class ScalpelOutputParser {
private static final String OUTPUT_START = "The following files were carved:"; private static final String OUTPUT_START = NbBundle.getMessage(ScalpelOutputParser.class,
"ScalpelOutputParser.outputStart.text");
public static class CarvedFileMeta { public static class CarvedFileMeta {
@ -62,7 +65,8 @@ public class ScalpelOutputParser {
@Override @Override
public String toString() { public String toString() {
return "CarvedFileMeta{" + "fileName=" + fileName + ", start: " + byteRange.getByteStart() + ", size: " + byteRange.getByteLen() + '}'; return NbBundle.getMessage(this.getClass(), "ScalpelOutputParser.toString.text",
fileName, byteRange.getByteStart(), byteRange.getByteLen());
} }
} }