angr.misc.plugins

class angr.misc.plugins.PluginHub

Bases: Generic

A 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')
Return type:

None

Parameters:
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:

None

Parameters:
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:

None

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:

None

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.

Return type:

TypeVar(P)

Parameters:

name (str)

has_plugin(name)

Return whether or not a plugin with the name name is currently active.

Return type:

bool

Parameters:

name (str)

register_plugin(name, plugin)

Add a new plugin plugin with name name to the active plugins.

Return type:

TypeVar(P)

Parameters:
  • name (str)

  • plugin (P)

release_plugin(name)

Deactivate and remove the plugin with name name.

Return type:

None

Parameters:

name (str)

class angr.misc.plugins.PluginPreset

Bases: Generic

A 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.

Return type:

None

Parameters:

hub (PluginHub[P])

deactivate(hub)

This method is called when the preset is discarded from the hub.

Return type:

None

Parameters:

hub (PluginHub[P])

add_default_plugin(name, plugin_cls)

Add a plugin to the preset.

Return type:

None

Parameters:
list_default_plugins()

Return a list of the names of available default plugins.

Return type:

list[str]

request_plugin(name)

Return the plugin class which is registered under the name name, or raise NoPlugin if the name isn’t available.

Return type:

type[TypeVar(P)]

Parameters:

name (str)

copy()

Return a copy of self.

Return type:

PluginPreset[TypeVar(P)]

class angr.misc.plugins.PluginVendor

Bases: PluginHub, Generic

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.

Return type:

None

Parameters:

name (str)

register_plugin(name, plugin)

This hub doesn’t actually have any active plugins, so this is a no-op. We just return the plugin that was passed in to satisfy the return type of PluginHub.register_plugin.

Return type:

TypeVar(P)

Parameters:
  • name (str)

  • plugin (P)

class angr.misc.plugins.VendorPreset

Bases: PluginPreset, Generic

A specialized preset class for use with the PluginVendor.