Module: Dradis::Plugins

Defined in:
lib/dradis/plugins.rb,
lib/dradis/plugins/base.rb,
lib/dradis/plugins/thor.rb,
lib/dradis/plugins/engine.rb,
lib/dradis/plugins/upload.rb,
lib/dradis/plugins/version.rb,
lib/dradis/plugins/mappings.rb,
lib/dradis/plugins/settings.rb,
lib/dradis/plugins/export/base.rb,
lib/dradis/plugins/gem_version.rb,
lib/dradis/plugins/thor_helper.rb,
lib/dradis/plugins/configurable.rb,
lib/dradis/plugins/import/filters.rb,
lib/dradis/plugins/mapping_service.rb,
lib/dradis/plugins/upload/importer.rb,
lib/dradis/plugins/templates/samples.rb,
lib/dradis/plugins/import/filters/base.rb,
lib/dradis/plugins/upload/field_processor.rb,
lib/dradis/plugins/templates/migrate_templates.rb,
app/controllers/dradis/plugins/export/base_controller.rb,
app/controllers/concerns/dradis/plugins/persistent_permissions.rb

Defined Under Namespace

Modules: Base, Configurable, ContentService, Export, Import, Mappings, PersistentPermissions, Templates, Thor, ThorHelper, Upload, VERSION Classes: Engine, MappingService, Settings

Constant Summary collapse

@@extensions =
[]

Class Method Summary collapse

Class Method Details

.clear_enabled_listObject



19
20
21
# File 'lib/dradis/plugins.rb', line 19

def clear_enabled_list
  @@enabled_list = nil
end

.enabled_listObject

Returns an array of modules representing currently enabled engines



15
16
17
# File 'lib/dradis/plugins.rb', line 15

def enabled_list
  @@enabled_list ||= @@extensions.select(&:enabled?)
end

.gem_versionObject

Returns the version of the currently loaded Frontend as a Gem::Version



4
5
6
# File 'lib/dradis/plugins/gem_version.rb', line 4

def self.gem_version
  Gem::Version.new VERSION::STRING
end

.listObject

Returns an array of modules representing currently registered Dradis Plugins / engines

Example:

Dradis::Core::Plugins.list  =>  [Dradis::Core, Dradis::Frontend]


10
11
12
# File 'lib/dradis/plugins.rb', line 10

def list
  @@extensions
end

.register(const) ⇒ Object

Register a plugin with the framework

Example:

Dradis::Core::Plugins.register(Dradis::Core)


36
37
38
39
40
41
42
# File 'lib/dradis/plugins.rb', line 36

def register(const)
  return if registered?(const)

  validate_plugin!(const)

  @@extensions << const
end

.registered?(const) ⇒ Boolean

Returns true if a plugin is currently registered with the framework

Example:

Dradis::Core::Plugins.registered?(Dradis::Core)

Returns:

  • (Boolean)


56
57
58
# File 'lib/dradis/plugins.rb', line 56

def registered?(const)
  @@extensions.include?(const)
end

.unregister(const) ⇒ Object

Unregister a plugin from the framework

Example:

Dradis::Core::Plugins.unregister(Dradis::Core)


48
49
50
# File 'lib/dradis/plugins.rb', line 48

def unregister(const)
  @@extensions.delete(const)
end

.upload_integration_names_and_modulesObject



60
61
62
63
64
65
66
67
# File 'lib/dradis/plugins.rb', line 60

def upload_integration_names_and_modules
  with_feature(:upload).each_with_object({}) do |integration, integrations_hash|
    integration_name = integration.plugin_name.to_s
    integration_module = integration.module_parent

    integrations_hash[integration_name] = integration_module
  end
end

.versionObject

Returns the version of the currently loaded Action Mailer as a Gem::Version.



7
8
9
# File 'lib/dradis/plugins/version.rb', line 7

def self.version
  gem_version
end

.with_feature(feature) ⇒ Object

Filters the list of plugins and only returns those that provide the requested feature and enabled



25
26
27
28
29
30
# File 'lib/dradis/plugins.rb', line 25

def with_feature(feature)
  enabled_list.select do |plugin|
    # engine = "#{plugin}::Engine".constantize
    plugin.provides?(feature)
  end
end