mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Addition try/catch modifications to hide more log messages.
This commit is contained in:
parent
42d81be8dc
commit
e23e48cda5
@ -122,7 +122,7 @@ class ImageExtractor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
logger.log(Level.WARNING, "Error executing FileTypeDetector.getFileType()", ex); // NON-NLS
|
logger.log(Level.SEVERE, "Error executing FileTypeDetector.getFileType()", ex); // NON-NLS
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ class ImageExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (TskCoreException e) {
|
} catch (TskCoreException e) {
|
||||||
logger.log(Level.WARNING, String.format("Error checking if file already has been processed, skipping: %s", parentFileName), e); //NON-NLS
|
logger.log(Level.SEVERE, String.format("Error checking if file already has been processed, skipping: %s", parentFileName), e); //NON-NLS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (abstractFileExtractionFormat) {
|
switch (abstractFileExtractionFormat) {
|
||||||
@ -191,7 +191,7 @@ class ImageExtractor {
|
|||||||
extractedImage.getCtime(), extractedImage.getCrtime(), extractedImage.getAtime(), extractedImage.getAtime(),
|
extractedImage.getCtime(), extractedImage.getCrtime(), extractedImage.getAtime(), extractedImage.getAtime(),
|
||||||
true, abstractFile, null, EmbeddedFileExtractorModuleFactory.getModuleName(), null, null, TskData.EncodingType.XOR1));
|
true, abstractFile, null, EmbeddedFileExtractorModuleFactory.getModuleName(), null, null, TskData.EncodingType.XOR1));
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.extractImage.addToDB.exception.msg"), ex); //NON-NLS
|
logger.log(Level.SEVERE, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.extractImage.addToDB.exception.msg"), ex); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!listOfExtractedImages.isEmpty()) {
|
if (!listOfExtractedImages.isEmpty()) {
|
||||||
@ -209,16 +209,20 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromDoc(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromDoc(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
List<org.apache.poi.hwpf.usermodel.Picture> listOfAllPictures;
|
||||||
HWPFDocument doc = null;
|
|
||||||
try {
|
try {
|
||||||
doc = new HWPFDocument(new ReadContentInputStream(af));
|
HWPFDocument doc = new HWPFDocument(new ReadContentInputStream(af));
|
||||||
} catch (OldFileFormatException ex) {
|
PicturesTable pictureTable = doc.getPicturesTable();
|
||||||
|
listOfAllPictures = pictureTable.getAllPictures();
|
||||||
|
} catch (OldFileFormatException | IOException ex) {
|
||||||
|
// OldFileFormatException:
|
||||||
// Thrown when the document version is unsupported (Word 95 and
|
// Thrown when the document version is unsupported (Word 95 and
|
||||||
// older)
|
// older)
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read.
|
// Thrown when the document has issues being read.
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
@ -226,17 +230,6 @@ class ImageExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PicturesTable pictureTable = null;
|
|
||||||
List<org.apache.poi.hwpf.usermodel.Picture> listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
pictureTable = doc.getPicturesTable();
|
|
||||||
listOfAllPictures = pictureTable.getAllPictures();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String outputFolderPath;
|
String outputFolderPath;
|
||||||
if (listOfAllPictures.isEmpty()) {
|
if (listOfAllPictures.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@ -246,7 +239,7 @@ class ImageExtractor {
|
|||||||
if (outputFolderPath == null) {
|
if (outputFolderPath == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (org.apache.poi.hwpf.usermodel.Picture picture : listOfAllPictures) {
|
for (org.apache.poi.hwpf.usermodel.Picture picture : listOfAllPictures) {
|
||||||
String fileName = picture.suggestFullFileName();
|
String fileName = picture.suggestFullFileName();
|
||||||
@ -274,29 +267,24 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromDocx(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromDocx(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
List<XWPFPictureData> listOfAllPictures = null;
|
||||||
XWPFDocument docx = null;
|
|
||||||
try {
|
try {
|
||||||
docx = new XWPFDocument(new ReadContentInputStream(af));
|
XWPFDocument docx = new XWPFDocument(new ReadContentInputStream(af));
|
||||||
} catch (POIXMLException ex) {
|
listOfAllPictures = docx.getAllPictures();
|
||||||
|
} catch (POIXMLException | IOException ex) {
|
||||||
|
// POIXMLException:
|
||||||
// Thrown when document fails to load
|
// Thrown when document fails to load
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read.
|
// Thrown when the document has issues being read.
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.docxContainer.init.err", af.getName()), ex); //NON-NLS
|
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.docxContainer.init.err", af.getName()), ex); //NON-NLS
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<XWPFPictureData> listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
listOfAllPictures = docx.getAllPictures();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no images are extracted from the PPT, return null, else initialize
|
// if no images are extracted from the PPT, return null, else initialize
|
||||||
// the output folder for image extraction.
|
// the output folder for image extraction.
|
||||||
@ -310,7 +298,7 @@ class ImageExtractor {
|
|||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.extractImageFrom.outputPath.exception.msg", af.getName())); //NON-NLS
|
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.extractImageFrom.outputPath.exception.msg", af.getName())); //NON-NLS
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (XWPFPictureData xwpfPicture : listOfAllPictures) {
|
for (XWPFPictureData xwpfPicture : listOfAllPictures) {
|
||||||
String fileName = xwpfPicture.getFileName();
|
String fileName = xwpfPicture.getFileName();
|
||||||
@ -336,15 +324,18 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromPpt(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromPpt(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
PictureData[] listOfAllPictures = null;
|
||||||
SlideShow ppt = null;
|
|
||||||
try {
|
try {
|
||||||
ppt = new SlideShow(new ReadContentInputStream(af));
|
SlideShow ppt = new SlideShow(new ReadContentInputStream(af));
|
||||||
} catch (OldFileFormatException ex) {
|
listOfAllPictures = ppt.getPictureData();
|
||||||
|
} catch (OldFileFormatException | IOException ex) {
|
||||||
|
// OldFileFormatException:
|
||||||
// Thrown when the document version is unsupported
|
// Thrown when the document version is unsupported
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read
|
// Thrown when the document has issues being read
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
@ -352,16 +343,6 @@ class ImageExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//extract all pictures contained in the presentation
|
|
||||||
PictureData[] listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
listOfAllPictures = ppt.getPictureData();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no images are extracted from the PPT, return null, else initialize
|
// if no images are extracted from the PPT, return null, else initialize
|
||||||
// the output folder for image extraction.
|
// the output folder for image extraction.
|
||||||
String outputFolderPath;
|
String outputFolderPath;
|
||||||
@ -378,7 +359,7 @@ class ImageExtractor {
|
|||||||
// extract the images to the above initialized outputFolder.
|
// extract the images to the above initialized outputFolder.
|
||||||
// extraction path - outputFolder/image_number.ext
|
// extraction path - outputFolder/image_number.ext
|
||||||
int i = 0;
|
int i = 0;
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (PictureData pictureData : listOfAllPictures) {
|
for (PictureData pictureData : listOfAllPictures) {
|
||||||
|
|
||||||
@ -429,29 +410,24 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromPptx(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromPptx(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
List<XSLFPictureData> listOfAllPictures = null;
|
||||||
XMLSlideShow pptx;
|
|
||||||
try {
|
try {
|
||||||
pptx = new XMLSlideShow(new ReadContentInputStream(af));
|
XMLSlideShow pptx = new XMLSlideShow(new ReadContentInputStream(af));
|
||||||
} catch (POIXMLException ex) {
|
listOfAllPictures = pptx.getAllPictures();
|
||||||
|
} catch (POIXMLException | IOException ex) {
|
||||||
|
// POIXMLException:
|
||||||
// Thrown when document fails to load.
|
// Thrown when document fails to load.
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read
|
// Thrown when the document has issues being read
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.pptxContainer.init.err", af.getName()), ex); //NON-NLS
|
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.pptxContainer.init.err", af.getName()), ex); //NON-NLS
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<XSLFPictureData> listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
listOfAllPictures = pptx.getAllPictures();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no images are extracted from the PPT, return null, else initialize
|
// if no images are extracted from the PPT, return null, else initialize
|
||||||
// the output folder for image extraction.
|
// the output folder for image extraction.
|
||||||
@ -466,7 +442,7 @@ class ImageExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (XSLFPictureData xslsPicture : listOfAllPictures) {
|
for (XSLFPictureData xslsPicture : listOfAllPictures) {
|
||||||
|
|
||||||
@ -498,16 +474,18 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromXls(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromXls(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
List<? extends org.apache.poi.ss.usermodel.PictureData> listOfAllPictures = null;
|
||||||
|
|
||||||
Workbook xls;
|
|
||||||
try {
|
try {
|
||||||
xls = new HSSFWorkbook(new ReadContentInputStream(af));
|
Workbook xls = new HSSFWorkbook(new ReadContentInputStream(af));
|
||||||
} catch (OldFileFormatException ex) {
|
listOfAllPictures = xls.getAllPictures();
|
||||||
|
} catch (OldFileFormatException | IOException ex) {
|
||||||
|
// OldFileFormatException:
|
||||||
// Thrown when the document version is unsupported
|
// Thrown when the document version is unsupported
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read
|
// Thrown when the document has issues being read
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
@ -515,15 +493,6 @@ class ImageExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<? extends org.apache.poi.ss.usermodel.PictureData> listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
listOfAllPictures = xls.getAllPictures();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no images are extracted from the PPT, return null, else initialize
|
// if no images are extracted from the PPT, return null, else initialize
|
||||||
// the output folder for image extraction.
|
// the output folder for image extraction.
|
||||||
String outputFolderPath;
|
String outputFolderPath;
|
||||||
@ -538,7 +507,7 @@ class ImageExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (org.apache.poi.ss.usermodel.PictureData pictureData : listOfAllPictures) {
|
for (org.apache.poi.ss.usermodel.PictureData pictureData : listOfAllPictures) {
|
||||||
String imageName = UNKNOWN_NAME_PREFIX + i + "." + pictureData.suggestFileExtension(); //NON-NLS
|
String imageName = UNKNOWN_NAME_PREFIX + i + "." + pictureData.suggestFileExtension(); //NON-NLS
|
||||||
@ -566,15 +535,18 @@ class ImageExtractor {
|
|||||||
* extracted.
|
* extracted.
|
||||||
*/
|
*/
|
||||||
private List<ExtractedImage> extractImagesFromXlsx(AbstractFile af) {
|
private List<ExtractedImage> extractImagesFromXlsx(AbstractFile af) {
|
||||||
List<ExtractedImage> listOfExtractedImages;
|
List<? extends org.apache.poi.ss.usermodel.PictureData> listOfAllPictures = null;
|
||||||
Workbook xlsx;
|
|
||||||
try {
|
try {
|
||||||
xlsx = new XSSFWorkbook(new ReadContentInputStream(af));
|
Workbook xlsx = new XSSFWorkbook(new ReadContentInputStream(af));
|
||||||
} catch (POIXMLException ex) {
|
listOfAllPictures = xlsx.getAllPictures();
|
||||||
|
} catch (POIXMLException | IOException ex) {
|
||||||
|
// POIXMLException:
|
||||||
// Thrown when document fails to load.
|
// Thrown when document fails to load.
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
// IOException:
|
||||||
// Thrown when the document has issues being read
|
// Thrown when the document has issues being read
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// instantiating POI containers throw RuntimeExceptions
|
// instantiating POI containers throw RuntimeExceptions
|
||||||
@ -582,15 +554,6 @@ class ImageExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<? extends org.apache.poi.ss.usermodel.PictureData> listOfAllPictures = null;
|
|
||||||
try {
|
|
||||||
listOfAllPictures = xlsx.getAllPictures();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// log internal Java and Apache errors as WARNING
|
|
||||||
logger.log(Level.WARNING, NbBundle.getMessage(this.getClass(), "EmbeddedFileExtractorIngestModule.ImageExtractor.processing.err", af.getName()), ex); //NON-NLS
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no images are extracted from the PPT, return null, else initialize
|
// if no images are extracted from the PPT, return null, else initialize
|
||||||
// the output folder for image extraction.
|
// the output folder for image extraction.
|
||||||
String outputFolderPath;
|
String outputFolderPath;
|
||||||
@ -605,7 +568,7 @@ class ImageExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
listOfExtractedImages = new ArrayList<>();
|
List<ExtractedImage> listOfExtractedImages = new ArrayList<>();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
for (org.apache.poi.ss.usermodel.PictureData pictureData : listOfAllPictures) {
|
for (org.apache.poi.ss.usermodel.PictureData pictureData : listOfAllPictures) {
|
||||||
String imageName = UNKNOWN_NAME_PREFIX + i + "." + pictureData.suggestFileExtension();
|
String imageName = UNKNOWN_NAME_PREFIX + i + "." + pictureData.suggestFileExtension();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user