mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 01:39:21 +02:00
Merge remote-tracking branch
'origin/GP-781_jpleasu_scriptPath_parser--SQUASHED' into patch
This commit is contained in:
commit
0429e754c8
2 changed files with 27 additions and 12 deletions
|
@ -293,9 +293,10 @@ public class HeadlessAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
GhidraScriptUtil.initialize(new BundleHost(), options.scriptPaths);
|
||||
List<String> parsedScriptPaths = parseScriptPaths(options.scriptPaths);
|
||||
GhidraScriptUtil.initialize(new BundleHost(), parsedScriptPaths);
|
||||
try {
|
||||
initializeScriptPaths();
|
||||
showConfiguredScriptPaths();
|
||||
compileScripts();
|
||||
|
||||
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
||||
|
@ -400,9 +401,10 @@ public class HeadlessAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
GhidraScriptUtil.initialize(new BundleHost(), options.scriptPaths);
|
||||
List<String> parsedScriptPaths = parseScriptPaths(options.scriptPaths);
|
||||
GhidraScriptUtil.initialize(new BundleHost(), parsedScriptPaths);
|
||||
try {
|
||||
initializeScriptPaths();
|
||||
showConfiguredScriptPaths();
|
||||
compileScripts();
|
||||
|
||||
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
||||
|
@ -668,10 +670,23 @@ public class HeadlessAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gather paths where scripts may be found.
|
||||
*/
|
||||
private void initializeScriptPaths() {
|
||||
private List<String> parseScriptPaths(List<String> scriptPaths) {
|
||||
List<String> parsedScriptPaths = new ArrayList<>();
|
||||
for (String path : scriptPaths) {
|
||||
ResourceFile pathFile = Path.fromPathString(path);
|
||||
String absPath = pathFile.getAbsolutePath();
|
||||
if (pathFile.exists()) {
|
||||
parsedScriptPaths.add(absPath);
|
||||
}
|
||||
else {
|
||||
|
||||
Msg.warn(this, "REPORT: Could not find -scriptPath entry, skipping: " + absPath);
|
||||
}
|
||||
}
|
||||
return parsedScriptPaths;
|
||||
}
|
||||
|
||||
private void showConfiguredScriptPaths() {
|
||||
StringBuffer buf = new StringBuffer("HEADLESS Script Paths:");
|
||||
for (ResourceFile dir : GhidraScriptUtil.getScriptSourceDirectories()) {
|
||||
buf.append("\n ");
|
||||
|
@ -856,8 +871,8 @@ public class HeadlessAnalyzer {
|
|||
Class<?> c = Class.forName(className, true, classLoaderForDotClassScripts);
|
||||
|
||||
// Get parent folder to pass to GhidraScript
|
||||
File parentFile = new File(
|
||||
c.getResource(c.getSimpleName() + ".class").toURI()).getParentFile();
|
||||
File parentFile = new File(c.getResource(c.getSimpleName() + ".class").toURI())
|
||||
.getParentFile();
|
||||
|
||||
currScript = (GhidraScript) c.getConstructor().newInstance();
|
||||
currScript.setScriptArgs(scriptArgs);
|
||||
|
|
|
@ -313,7 +313,7 @@ The Headless Analyzer uses the command-line parameters discussed below. See <a h
|
|||
<LI>
|
||||
<a name="scriptPath"><typewriter>-scriptPath "<path1>[;<path2>...]"</typewriter></a>
|
||||
<br>Specifies the search path(s) for scripts, including secondary scripts (a script invoked from
|
||||
another script). A path may start with <typewriter>$GHIDRA_SCRIPT</typewriter>, which corresponds
|
||||
another script). A path may start with <typewriter>$GHIDRA_HOME</typewriter>, which corresponds
|
||||
to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which corresponds
|
||||
to the user's home directory. On Unix systems, these home variables must be escaped using a
|
||||
'<typewriter>\</typewriter>' (backslash) character.
|
||||
|
@ -344,7 +344,7 @@ The Headless Analyzer uses the command-line parameters discussed below. See <a h
|
|||
<LI>
|
||||
<a name="propertiesPath"><typewriter>-propertiesPath "<path1>[;<path2>…]"</typewriter></a>
|
||||
<br>Specifies path(s) that contain <typewriter>.properties</typewriter> files used by scripts or
|
||||
secondary/subscripts. A path may start with <typewriter>$GHIDRA_SCRIPT</typewriter>, which
|
||||
secondary/subscripts. A path may start with <typewriter>$GHIDRA_HOME</typewriter>, which
|
||||
corresponds to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which
|
||||
corresponds to the user's home directory. On Unix systems these home variables must be
|
||||
escaped with a '\' character.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue