plugins Package

plugins Package

class FingerPrint.plugins.PluginManager[source]

Bases: object

Super class of the various plugins. All plugins should inherit from this class.

To implement a new Plugin you should subclass this class and provide the following attributes/methods:

  • pluginName: this must be a unique string representing the plugin name

  • getPathToLibrary(): a class method which return a file name pointing to the

    file which can provide the given dependency

  • getSwirl(): a class method that given a path to a file it return None if the

    file can not be handled by the given plugin or a SwirlFile with the dependency set if the plugin can handle the file

classmethod addSystemPaths(paths)[source]

add an additional paths to the search for dependency

Parameters:paths (list) – a list of string with the extra path to be added
classmethod getPathToLibrary(dependency, useCache=True, rpath=[])[source]

Given a dependency it find the path of the library which provides that dependency

Parameters:
  • dependency (FingerPrint.swirl.Dependency) – the Dependency that we need to satisfy with the returned library
  • useCache (bool) – if true it will use a cache that will speed up a lot searching for libraries
  • rpath (list) – a list of string which contains extra paths that we want to add during the search for the dependency Generally used to add RPATH to the search path.
Return type:

string

Returns:

the path to the library which satisfy the given dependency

classmethod getSwirl(fileName, swirl, env=None)[source]

helper function given a filename it return a SwirlFile. This should be re-implemented by the various plugins. If none of the plugins return a SwirlFile this method will return a ‘data’ SwirlFile.

ATT: only one plugin should return a SwirlFile for a given file

ATT2: this is a class method

Parameters:
  • fileName (string) – a path to the new file we want to add
  • swirl (FingerPrint.swirl.Swirl) – the current Swirl object. Static dependencies of the new SwirlFile are resolved first inside the Swirl and if not found then they are resolved recursively invoking this function and recursively added to the Swirl
  • env (list) – a list of string with all the environment variable available to this file when it was executing. This field is used only when doing dynamic tracing.
Return type:

FingerPrint.swirl.SwirlFile

Returns:

a SwirlFile representing the given fileName. The SwirlFile should have all the static dependencies resolved (if they could be find on the system)

plugins = {'ELF': <class 'FingerPrint.plugins.elf.ElfPlugin'>}
systemPath = []

list of string containing the paths we should look for dependencies

class FingerPrint.plugins.PluginMount(name, bases, attrs)[source]

Bases: type

this is a singleton object which can return a list of all available plugins. All plugin available inside the FingerPrint.plugins are loaded inside the PluginMount when this module is loaded.

Insipired by (or totaly copied from) Marty Alchin: http://martyalchin.com/2008/jan/10/simple-plugin-framework/

get_plugins()[source]

return the list of currently registered plugins

Return type:list
Returns:a list of PluginManager registered

elf Module

class FingerPrint.plugins.elf.ElfPlugin[source]

Bases: FingerPrint.plugins.PluginManager

This plugin manages all ELF file format. This class requires the find-provides and find-requires script present in this folder which require: objdump, awk, sed, grep.

For nicer documentation on this functions see FingerPrint.plugins.PluginManager

classmethod getPathToLibrary(dependency, useCache=True, rpath=[])[source]

given a dependency it find the path of the library which provides that dependency

classmethod getSwirl(fileName, swirl, env=None)[source]

helper function given a filename it return a SwirlFile if the given plugin does not support the given fileName should just return None

ATT: only one plugin should return a SwirlFile for a given file

pluginName = 'ELF'