From c49154140822676ed3dbe2ced5b88f2c7ffd6dd8 Mon Sep 17 00:00:00 2001 From: "patrick.pdb" Date: Thu, 1 Feb 2024 10:23:57 -0300 Subject: [PATCH] '#43 reverses method creation as it breaks logic when evidence processed is a file system folder. --- .../task/leappbridge/LeappBridgeTask.java | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/task/leappbridge/LeappBridgeTask.java b/iped-engine/src/main/java/iped/engine/task/leappbridge/LeappBridgeTask.java index 95006eeb59..7abfa21e3b 100644 --- a/iped-engine/src/main/java/iped/engine/task/leappbridge/LeappBridgeTask.java +++ b/iped-engine/src/main/java/iped/engine/task/leappbridge/LeappBridgeTask.java @@ -517,20 +517,23 @@ private boolean isInsideRealDump(IItem reportEvidence) { } /** - * Find the evidence files that matches the plugin's patterns. - *

- * Find the evidence files that matches the plugin's patterns and export them - * to temp folder if needed so plugin execution can find them. - *

- * - * @param p Plugin for which the related patterns will be searched. - * @param dumpEvidence Dump evidence root, so the query will apply only to its children. - * @param dumpPath Complete path to the dump folder. - * @param reportDumpPath Complete path to the dump report folder. - * @return Description text text text. - */ - protected List findAndExportTemporaryPluginRelatedFiles(LeapArtifactsPlugin p, IItem dumpEvidence, String dumpPath, - File reportDumpPath) { + * Find the evidence files that matches the plugin's patterns and calls plugin + * execution. + * + * @param p + * Plugin to execute + * @param evidence + * Plugin evidence item. + * @param dumpEvidence + * Dump evidence root, so the query will apply only to its children. + * @param reportDumpPath + * Complete path to the effective source report dump folder. If IPED + * processing is against a Folder the path will be this folder. + * Otherwise, if IPED processing is against a ZIP, E01, or any + * container, this parameter must contain a path to + */ + private void processPlugin(LeapArtifactsPlugin p, IItem evidence, IItem dumpEvidence, File reportDumpPath) + throws IOException { List filesFound = new ArrayList(); try { @@ -538,6 +541,8 @@ protected List findAndExportTemporaryPluginRelatedFiles(LeapArtifactsPlu filesFoundDocuments = new HashMap(); + String dumpPath = dumpEvidence.getPath(); + // find files on dump that is needed by the plugin and exports them // to tmp folder if needed. ALeapp plugins will work on // these tmp copies of the files. @@ -617,34 +622,26 @@ protected List findAndExportTemporaryPluginRelatedFiles(LeapArtifactsPlu } } } + + if (filesFound.size() <= 0) { + evidence.setToIgnore(true); + return; + } else { + Metadata m = evidence.getMetadata(); + for (String file : filesFound) { + String filel = file.substring(preparePythonLiteralPath(reportDumpPath.getCanonicalPath()).length()); + filel = prepareIPEDLiteralPath(filel); + String filename = filel.substring(filel.lastIndexOf("/") + 1); + m.add(ExtraProperties.LINKED_ITEMS, "path:\"*" + filel + "\" && name:\"" + filename + "\""); + + } + executePlugin(evidence, p, filesFound, reportDumpPath); + } } catch (Exception e) { e.printStackTrace(); } finally { } - - - return filesFound; - } - - private void processPlugin(LeapArtifactsPlugin p, IItem evidence, IItem dumpEvidence, String dumpPath, - File reportDumpPath) throws IOException { - List filesFound = findAndExportTemporaryPluginRelatedFiles(p, dumpEvidence, dumpPath, reportDumpPath); - - if (filesFound.size() <= 0) { - evidence.setToIgnore(true); - return; - } else { - Metadata m = evidence.getMetadata(); - for (String file : filesFound) { - String filel = file.substring(preparePythonLiteralPath(reportDumpPath.getCanonicalPath()).length()); - filel = prepareIPEDLiteralPath(filel); - String filename = filel.substring(filel.lastIndexOf("/") + 1); - m.add(ExtraProperties.LINKED_ITEMS, "path:\"*" + filel + "\" && name:\"" + filename + "\""); - - } - executePlugin(evidence, p, filesFound, reportDumpPath); - } } private String prepareIPEDLiteralPath(String filel) { @@ -696,9 +693,8 @@ private void processEvidence(IItem evidence, LeapArtifactsPlugin p) { IItem leappRepEvidence = ipedCase.getItemByID(evidence.getParentId()); IItem dumpEvidence = ipedCase.getItemByID(leappRepEvidence.getParentId()); - String dumpPath = dumpEvidence.getPath(); - processPlugin(p, evidence, dumpEvidence, dumpPath, reportDumpPath); + processPlugin(p, evidence, dumpEvidence, reportDumpPath); if (!evidence.hasChildren()) { evidence.setToIgnore(true);