Skip to content

Commit 8117dd2

Browse files
committed
#43: ignore categories with no plugin results
1 parent c95cb73 commit 8117dd2

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

iped-engine/src/main/java/iped/engine/core/QueuesProcessingOrder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static Map<MediaType, Integer> installTypesToPostProcess() {
118118
mediaTypes.put(RFC822Parser.RFC822_PARTIAL1_MIME, 2);
119119

120120
mediaTypes.put(AleappTask.ALEAPP_CASE_MEDIATYPE, 5);
121-
mediaTypes.put(AleappTask.ALEAPP_PLUGIN_RESULTS_MEDIATYPE, 5);
121+
mediaTypes.put(AleappTask.ALEAPP_CATEGORY_MEDIATYPE, 6);
122122
mediaTypes.put(AleappTask.ALEAPP_DEVICE_INFO_MEDIATYPE, 6);
123123

124124
return mediaTypes;

iped-engine/src/main/java/iped/engine/task/aleapp/AleappTask.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class AleappTask extends AbstractTask {
5959
public static final MediaType ALEAPP_ACTIVITY_MEDIATYPE = MediaType.application(ALEAPP_APPLICATION_PREFIX + "activity");
6060
public static final MediaType ALEAPP_DEVICE_INFO_MEDIATYPE = MediaType.application(ALEAPP_APPLICATION_PREFIX + "deviceinfo");
6161

62+
public static final String ALEAPP_PLUGIN_CATEGORY_KEY = "aleapp_category";
63+
6264
private static final String DEVICE_INFO_HTML = "DeviceInfo.html";
6365

6466
private static final String CASE_EVIDENCE_NAME = "ALEAPP_Results";
@@ -245,6 +247,8 @@ public void process(IItem item) throws Exception {
245247
processExtractionRoot(item);
246248
} else if (isCaseEvidence(item)) {
247249
processCaseEvidence(item);
250+
} else if (isCategoryEvidence(item)) {
251+
processCategoryEvidence(item);
248252
} else if (isPluginEvidence(item)) {
249253
processPluginEvidence(item);
250254
} else if (isDeviceInfoEvidence(item)) {
@@ -274,6 +278,10 @@ private boolean isCaseEvidence(IItem evidence) {
274278
return ALEAPP_CASE_MEDIATYPE.equals(evidence.getMediaType());
275279
}
276280

281+
private boolean isCategoryEvidence(IItem evidence) {
282+
return ALEAPP_CATEGORY_MEDIATYPE.equals(evidence.getMediaType());
283+
}
284+
277285
private boolean isPluginEvidence(IItem evidence) {
278286
return ALEAPP_PLUGIN_RESULTS_MEDIATYPE.equals(evidence.getMediaType());
279287
}
@@ -349,7 +357,6 @@ private void processCaseEvidence(IItem caseEvidence) throws Exception {
349357
categoryEvidence.setPath(caseEvidence.getPath() + "/" + name);
350358
categoryEvidence.setIdInDataSource("");
351359
categoryEvidence.setExtraAttribute(ExtraProperties.DECODED_DATA, true);
352-
categoryEvidence.setHasChildren(true);
353360

354361
worker.processNewItem(categoryEvidence, ProcessTime.LATER);
355362

@@ -358,6 +365,7 @@ private void processCaseEvidence(IItem caseEvidence) throws Exception {
358365

359366
Item pluginEvidence = (Item) categoryItem.createChildItem();
360367
pluginEvidence.setMediaType(ALEAPP_PLUGIN_RESULTS_MEDIATYPE);
368+
pluginEvidence.setTempAttribute(ALEAPP_PLUGIN_CATEGORY_KEY, categoryItem);
361369

362370
String name = StringUtils.firstNonBlank((String) plugin.getArtifactInfo().get("name"), plugin.getName());
363371
pluginEvidence.setName(name);
@@ -386,7 +394,13 @@ private void processCaseEvidence(IItem caseEvidence) throws Exception {
386394
deviceInfoEvidence.setPath(caseEvidence.getPath() + "/" + DEVICE_INFO_HTML);
387395
deviceInfoEvidence.setIdInDataSource("");
388396
worker.processNewItem(deviceInfoEvidence, ProcessTime.LATER);
397+
}
389398

399+
private void processCategoryEvidence(IItem categoryEvidence) throws Exception {
400+
if (!categoryEvidence.hasChildren()) {
401+
logger.info("Ignoring Aleapp category {}: no children", categoryEvidence.getName());
402+
categoryEvidence.setToIgnore(true);
403+
}
390404
}
391405

392406
private void processPluginEvidence(IItem pluginEvidence) throws Exception {

iped-engine/src/main/java/iped/engine/task/aleapp/interceptors/IlapfuncsTsvInterceptor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.slf4j.Logger;
1616
import org.slf4j.LoggerFactory;
1717

18+
import iped.data.IItem;
1819
import iped.data.IItemReader;
1920
import iped.engine.core.Worker.ProcessTime;
2021
import iped.engine.data.Item;
@@ -55,7 +56,10 @@ public Object call(Object[] args, Map<String, Object> kwargs) throws Exception {
5556
State state = AleappTask.getState();
5657

5758
// set hasChildren, so plugin will not be ignored in AleappTask.processPluginEvidence()
59+
// and category will not be ignored in AleappTask.processCategoryEvidence()
5860
state.getPluginItem().setHasChildren(true);
61+
IItem categoryItem = (IItem) state.getPluginItem().getTempAttribute(AleappTask.ALEAPP_PLUGIN_CATEGORY_KEY);
62+
categoryItem.setHasChildren(true);
5963

6064
// linkedItems
6165
Set<String> globalIds = new HashSet<>();

0 commit comments

Comments
 (0)