Skip to content

Commit

Permalink
'#43 extends ALeappConfig with excludePlugins and includePlugins
Browse files Browse the repository at this point in the history
parameters.
  • Loading branch information
patrickdalla committed Feb 5, 2024
1 parent 4564c5c commit 0a6ab17
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 28 deletions.
3 changes: 3 additions & 0 deletions iped-app/resources/config/conf/ALeappConfig.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#aleapFolder specifies the folder where ALEAPP scripts are installed. It defaults to tools dir, in case ommited.
#aleapFolder=/home/patrick.pdb/multicase/indices/ALEAPP

#List of ALeapp plugins names not to be called (because there may already exist a correspondent IPED parser)
excludePlugins=WhatsApp
48 changes: 48 additions & 0 deletions iped-engine/src/main/java/iped/engine/config/ALeappConfig.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package iped.engine.config;

import java.util.ArrayList;

import org.apache.commons.lang3.StringUtils;

import iped.utils.UTF8Properties;

public class ALeappConfig extends AbstractTaskPropertiesConfig {

String aleapScriptsDir;
ArrayList<String> excludedPlugins = new ArrayList();
ArrayList<String> includedPlugins = new ArrayList();

/**
*
Expand All @@ -19,6 +25,22 @@ void processProperties(UTF8Properties properties) {
if (value != null) {
aleapScriptsDir = value.trim();
}

String excludePlugins = properties.getProperty("excludePlugins"); //$NON-NLS-1$
if (excludePlugins != null) {
String[] aExcludedPlugins = StringUtils.split(excludePlugins, ",");
for (String excludedPlugin : aExcludedPlugins) {
excludedPlugins.add(excludePlugins);
}
}

String includePlugins = properties.getProperty("includePlugins"); //$NON-NLS-1$
if (includePlugins != null) {
String[] aIncludedPlugins = StringUtils.split(includePlugins, ",");
for (String includedPlugin : aIncludedPlugins) {
includedPlugins.add(includedPlugin);
}
}
}

@Override
Expand All @@ -39,4 +61,30 @@ public void setAleapScriptsDir(String aleapScriptsDir) {
this.aleapScriptsDir = aleapScriptsDir;
}

public ArrayList<String> getExcludedPlugins() {
return excludedPlugins;
}

public void setExcludedPlugins(ArrayList<String> excludedPlugins) {
this.excludedPlugins = excludedPlugins;
}

public ArrayList<String> getIncludedPlugins() {
return includedPlugins;
}

public void setIncludedPlugins(ArrayList<String> includedPlugins) {
this.includedPlugins = includedPlugins;
}

public boolean isPluginIncluded(String moduleName) {
if (!excludedPlugins.isEmpty()) {
return !excludedPlugins.contains(moduleName);
}
if (!includedPlugins.isEmpty()) {
return includedPlugins.contains(moduleName);
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
/**
* @author Patrick Dalla Bernardina <patrick.dalla@gmail.com>
*
* Class that implement a IPED task that will call ALeapp python plugins
* to be executed against IPED processed found evidences. The artifacts
* found by ALeapp will be extracted.
* Class that implement an IPED task that will call ALeapp python
* plugins to be executed against IPED processed found evidences. The
* artifacts found by ALeapp will be extracted.
*/
public class LeappBridgeTask extends AbstractPythonTask {

Expand Down Expand Up @@ -99,6 +99,8 @@ public LeappBridgeTask() {
//map between filesFound paths and correspondent Lucene Documents
private HashMap<String, Document> filesFoundDocuments;

private ALeappConfig config;

static private File aleappDir;

static private File tmp;
Expand Down Expand Up @@ -149,6 +151,8 @@ public static Object open(Collection args, Map kargs) {
public void init(ConfigurationManager configurationManager) throws Exception {
int incremented = taskCount.incrementAndGet();

config = (ALeappConfig) configurationManager.findObject(ALeappConfig.class);

moduleName = "JLeapp";
if (incremented == 1) {
super.init(configurationManager);
Expand Down Expand Up @@ -288,22 +292,19 @@ public void executePlugin(IItem evidence, LeapArtifactsPlugin p, List<String> fi
}

private File getAleappScriptsDir() {
if (aleappDir == null) {
ALeappConfig config = (ALeappConfig) getConfigurables().get(0);

if (config.getAleapScriptsDir() != null) {
aleappDir = new File(config.getAleapScriptsDir());
} else {
File pythonDir = new File(Configuration.getInstance().appRoot, "tools");
aleappDir = new File(pythonDir, "ALEAPP");
}
if (config.getAleapScriptsDir() != null) {
aleappDir = new File(config.getAleapScriptsDir());
} else {
File pythonDir = new File(Configuration.getInstance().appRoot, "tools");
aleappDir = new File(pythonDir, "ALEAPP");
}

try {
logger.info("ALeapp scripts dir:" + aleappDir.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
try {
logger.info("ALeapp scripts dir:" + aleappDir.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}

return aleappDir;
}

Expand Down Expand Up @@ -357,17 +358,19 @@ public void process(IItem evidence) throws Exception {

// creates one subitem for each plugin execution
for (LeapArtifactsPlugin p : pluginsManager.getPlugins()) {
Item psubItem = (Item) evidence.createChildItem();

String moduleName = p.moduleName;
psubItem.setName(moduleName);
psubItem.setPath(parentInfo.getPath() + "/" + moduleName);
psubItem.setSubItem(true);
psubItem.setSubitemId(1);
psubItem.getMetadata().set(ALEAPP_PLUGIN, moduleName);
psubItem.getMetadata().set(ALEAPP_ISPLUGIN, "true");
psubItem.setExtraAttribute(ExtraProperties.DECODED_DATA, true);
worker.processNewItem(psubItem);
if (config.isPluginIncluded(p.getModuleName())) {
Item psubItem = (Item) evidence.createChildItem();

String moduleName = p.moduleName;
psubItem.setName(moduleName);
psubItem.setPath(parentInfo.getPath() + "/" + moduleName);
psubItem.setSubItem(true);
psubItem.setSubitemId(1);
psubItem.getMetadata().set(ALEAPP_PLUGIN, moduleName);
psubItem.getMetadata().set(ALEAPP_ISPLUGIN, "true");
psubItem.setExtraAttribute(ExtraProperties.DECODED_DATA, true);
worker.processNewItem(psubItem);
}
}

// creates subitem to hold device info collected
Expand Down

0 comments on commit 0a6ab17

Please # to comment.