Class: Msf::PersistentStorage Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/base/persistent_storage.rb,
lib/msf/base/persistent_storage/flatfile.rb

Overview

This class is abstract.

Subclass and override #initialize, #store, and #fetch.

This class provides a generalized interface to persisting information, either in whole or in part, about the state of the framework. This can be used to store data that can later be reinitialized in a new instance of the framework or to provide a simple mechanism for generating reports of some form.

Direct Known Subclasses

Flatfile

Defined Under Namespace

Classes: Flatfile

Constant Summary collapse

@@storage_classes =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*params) ⇒ PersistentStorage

Stub initialization routine that takes the params passed to create.


34
35
# File 'lib/msf/base/persistent_storage.rb', line 34

def initialize(*params)
end

Class Method Details

.add_storage_class(name, klass) ⇒ void

This method returns an undefined value.

This method adds a new storage class to the hash of storage classes that can be created through create.


67
68
69
# File 'lib/msf/base/persistent_storage.rb', line 67

def self.add_storage_class(name, klass)
  @@storage_classes[name] = klass
end

.create(name, *params) ⇒ PersistentStorage?

Creates an instance of the storage class with the supplied name. The array supplied as an argument is passed to the constructor of the associated class as a means of generic initialization.


23
24
25
26
27
28
29
# File 'lib/msf/base/persistent_storage.rb', line 23

def self.create(name, *params)
  if (klass = @@storage_classes[name])
    klass.new(*params)
  else
    nil
  end
end

Instance Method Details

#fetch(framework) ⇒ void

This method returns an undefined value.

This method initializes the supplied framework instance with the state that is stored in the persisted backing that the derived class implements. If the derived class does not implement this method, the NotImplementedError is raised.

Raises:

  • (NotImplementedError)

    raised if not implemented.


57
58
59
# File 'lib/msf/base/persistent_storage.rb', line 57

def fetch(framework)
  raise NotImplementedError
end

#store(framework) ⇒ void

This method returns an undefined value.

This methods stores all or part of the current state of the supplied framework instance to whatever medium the derived class implements. If the derived class does not implement this method, the NotImplementedError is raised.

Raises:

  • (NotImpementedError)

    raised if not implemented.


45
46
47
# File 'lib/msf/base/persistent_storage.rb', line 45

def store(framework)
  raise NotImplementedError
end