mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-10-16 07:03:04 +00:00
clarify and discourage access to compiled scripts
This commit is contained in:
parent
c106e0e02b
commit
c660a12ab3
|
@ -25,7 +25,6 @@ import org.apache.commons.collections4.map.LazyMap;
|
|||
|
||||
import docking.widgets.bundlemanager.BundlePath;
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.script.osgi.SourceBundleInfo;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -193,16 +192,6 @@ public class GhidraScriptUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output directory to which the given script file's generated .class file should
|
||||
* be written
|
||||
* @param scriptFile the script file
|
||||
* @return the directory
|
||||
*/
|
||||
public static ResourceFile getScriptCompileOutputDirectory(ResourceFile scriptFile) {
|
||||
return new ResourceFile(SourceBundleInfo.getBindirFromScriptFile(scriptFile).toFile());
|
||||
}
|
||||
|
||||
public static Path getOsgiDir() {
|
||||
Path usersettings = Application.getUserSettingsDirectory().toPath();
|
||||
return usersettings.resolve("osgi");
|
||||
|
@ -213,15 +202,13 @@ public class GhidraScriptUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the list of directories to which scripts are compiled.
|
||||
* Returns the list of exploded bundle directories
|
||||
* @return the list
|
||||
*
|
||||
* @see #getScriptCompileOutputDirectory(ResourceFile)
|
||||
*
|
||||
* @deprecated class files shouldn't be accessed directly
|
||||
* @deprecated accessing class file directly precludes OSGi wiring according to requirements and capabilities
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<ResourceFile> getScriptBinDirectories() {
|
||||
public static List<ResourceFile> getExplodedBundlePaths() {
|
||||
try {
|
||||
return Files.list(getOsgiDir()).filter(Files::isDirectory).map(
|
||||
x -> new ResourceFile(x.toFile())).collect(Collectors.toList());
|
||||
|
|
|
@ -138,7 +138,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||
systemState.path.append(Py.newString(resourceFile.getFile(false).getAbsolutePath()));
|
||||
}
|
||||
|
||||
for (ResourceFile resourceFile : GhidraScriptUtil.getScriptBinDirectories()) {
|
||||
for (ResourceFile resourceFile : GhidraScriptUtil.getExplodedBundlePaths()) {
|
||||
systemState.path.append(Py.newString(resourceFile.getFile(false).getAbsolutePath()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue