angr.misc.plugins¶
- class angr.misc.plugins.PluginHub¶
Bases:
GenericA plugin hub is an object which contains many plugins, as well as the notion of a “preset”, or a backer that can provide default implementations of plugins which cater to a certain circumstance.
Objects in angr like the SimState, the Analyses hub, the SimEngine selector, etc all use this model to unify their mechanisms for automatically collecting and selecting components to use. If you’re familiar with design patterns this is a configurable Strategy Pattern.
Each PluginHub subclass should have a corresponding Plugin subclass, and perhaps a PluginPreset subclass if it wants its presets to be able to specify anything more interesting than a list of defaults.
- __init__()¶
- Return type:
None
- classmethod register_default(name, plugin_cls, preset='default')¶
- classmethod register_preset(name, preset)¶
Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to automatically register themselves with a preset by using a classmethod of their own with only the name of the preset to register with.
- Return type:
- Parameters:
name (str)
preset (PluginPreset[P])
- property plugin_preset: PluginPreset[P] | None¶
Get the current active plugin preset
- property has_plugin_preset: bool¶
Check whether or not there is a plugin preset in use on this hub right now
- use_plugin_preset(preset)¶
Apply a preset to the hub. If there was a previously active preset, discard it.
Preset can be either the string name of a preset or a PluginPreset instance.
- Return type:
- Parameters:
preset (str | PluginPreset[P])
- discard_plugin_preset()¶
Discard the current active preset. Will release any active plugins that could have come from the old preset.
- Return type:
- get_plugin(name)¶
Get the plugin named
name. If no such plugin is currently active, try to activate a new one using the current preset.
- has_plugin(name)¶
Return whether or not a plugin with the name
nameis currently active.
- register_plugin(name, plugin)¶
Add a new plugin
pluginwith namenameto the active plugins.
- class angr.misc.plugins.PluginPreset¶
Bases:
GenericA plugin preset object contains a mapping from name to a plugin class. A preset can be active on a hub, which will cause it to handle requests for plugins which are not already present on the hub.
Unlike Plugins and PluginHubs, instances of PluginPresets are defined on the module level for individual presets. You should register the preset instance with a hub to allow plugins to easily add themselves to the preset without an explicit reference to the preset itself.
- __init__()¶
- Return type:
None
- activate(hub)¶
This method is called when the preset becomes active on a hub.
- deactivate(hub)¶
This method is called when the preset is discarded from the hub.
- add_default_plugin(name, plugin_cls)¶
Add a plugin to the preset.
- list_default_plugins()¶
Return a list of the names of available default plugins.
- request_plugin(name)¶
Return the plugin class which is registered under the name
name, or raise NoPlugin if the name isn’t available.
- copy()¶
Return a copy of self.
- Return type:
PluginPreset[TypeVar(P)]
- class angr.misc.plugins.PluginVendor¶
-
A specialized hub which serves only as a plugin vendor, never having any “active” plugins. It will directly return the plugins provided by the preset instead of instantiating them.
- release_plugin(name)¶
This hub doesn’t actually have any active plugins, so this is a no-op.
- class angr.misc.plugins.VendorPreset¶
Bases:
PluginPreset,GenericA specialized preset class for use with the PluginVendor.