mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-5415: Python scripts that do not declare a @runtime metadata comment
now default to PyGhidra instead of Jython. (Closes #7856)
This commit is contained in:
parent
b7602e9d41
commit
6f0cb9a77c
3 changed files with 16 additions and 16 deletions
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -30,7 +30,7 @@ import ghidra.app.plugin.core.script.GhidraScriptMgrPlugin;
|
|||
import ghidra.app.util.headless.HeadlessAnalyzer;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.classfinder.ClassSearcher;
|
||||
import ghidra.util.classfinder.*;
|
||||
import utilities.util.FileUtilities;
|
||||
|
||||
/**
|
||||
|
@ -276,18 +276,18 @@ public class GhidraScriptUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all supported Ghidra script providers
|
||||
* Returns a list of all supported Ghidra script providers.
|
||||
* <p>
|
||||
* NOTE: The list is {@link ExtensionPointProperties#priority() priority-sorted}
|
||||
*
|
||||
* @return a list of all supported Ghidra script providers
|
||||
* @apiNote this method is synchronized so that two threads do not try to create the list when
|
||||
* null
|
||||
*/
|
||||
// Note: this method is synchronized so that two threads do not try to create the list when null
|
||||
public static synchronized List<GhidraScriptProvider> getProviders() {
|
||||
if (providers == null) {
|
||||
providers = ClassSearcher.getInstances(GhidraScriptProvider.class)
|
||||
.stream()
|
||||
.filter(p -> !(p instanceof UnsupportedScriptProvider))
|
||||
.sorted()
|
||||
.toList();
|
||||
providers = ClassSearcher.getInstances(GhidraScriptProvider.class,
|
||||
new ClassExclusionFilter(UnsupportedScriptProvider.class));
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -19,12 +19,10 @@ import java.io.PrintWriter;
|
|||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.script.*;
|
||||
import ghidra.util.classfinder.ExtensionPointProperties;
|
||||
|
||||
/**
|
||||
* A {@link GhidraScriptProvider} used to run Jython scripts
|
||||
*/
|
||||
@ExtensionPointProperties(priority = 1000) // Enforce high priority so Jython is the default Python provider
|
||||
public class JythonScriptProvider extends AbstractPythonScriptProvider {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,12 +29,14 @@ import ghidra.program.util.ProgramLocation;
|
|||
import ghidra.program.util.ProgramSelection;
|
||||
import ghidra.pyghidra.PythonFieldExposer.ExposedFields;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import ghidra.util.classfinder.ExtensionPointProperties;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* {@link GhidraScript} provider for native python3 scripts
|
||||
*/
|
||||
@ExtensionPointProperties(priority = 1000) // Enforce high priority so PyGhidra is the default Python provider
|
||||
public final class PyGhidraScriptProvider extends AbstractPythonScriptProvider {
|
||||
|
||||
private static Consumer<GhidraScript> scriptRunner = null;
|
||||
|
@ -102,7 +104,7 @@ public final class PyGhidraScriptProvider extends AbstractPythonScriptProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper inner class that can create a {@link MethodHandles.Lookup}
|
||||
* Helper inner class that can create a {@link java.lang.invoke.MethodHandles.Lookup}
|
||||
* that can access the protected fields of the {@link GhidraScript}
|
||||
*/
|
||||
private static class ExposedField extends PythonFieldExposer.ExposedField {
|
||||
|
@ -136,7 +138,7 @@ public final class PyGhidraScriptProvider extends AbstractPythonScriptProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper inner class that can create a {@link MethodHandles.Lookup}
|
||||
* Helper inner class that can create a {@link java.lang.invoke.MethodHandles.Lookup}
|
||||
* that can access the protected fields of the {@link GhidraScript}
|
||||
*/
|
||||
private static class ExposedField extends PythonFieldExposer.ExposedField {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue