Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/base/persistent_storage.rb
Views: 11780
# -*- coding: binary -*-1module Msf23# This class provides a generalized interface to persisting information,4# either in whole or in part, about the state of the framework. This can5# be used to store data that can later be reinitialized in a new instance6# of the framework or to provide a simple mechanism for generating reports7# of some form.8#9# @abstract Subclass and override {#initialize}, {#store}, and {#fetch}.10class PersistentStorage1112@@storage_classes = {}1314# Creates an instance of the storage class with the supplied name. The15# array supplied as an argument is passed to the constructor of the16# associated class as a means of generic initialization.17#18# @param name [String] the name of the storage class.19# @param params [Object] the parameters to give the new class.20# @return [PersistentStorage] the newly created class.21# @return [nil] if class has not been added through {.add_storage_class}.22def self.create(name, *params)23if (klass = @@storage_classes[name])24klass.new(*params)25else26nil27end28end2930# Stub initialization routine that takes the params passed to create.31#32# @param params [Object] the parameters to initialize with.33def initialize(*params)34end3536# This methods stores all or part of the current state of the supplied37# framework instance to whatever medium the derived class implements.38# If the derived class does not implement this method, the39# NotImplementedError is raised.40#41# @param framework [Msf::Framework] framework state to store.42# @return [void] no implementation.43# @raise [NotImpementedError] raised if not implemented.44def store(framework)45raise NotImplementedError46end4748# This method initializes the supplied framework instance with the state49# that is stored in the persisted backing that the derived class50# implements. If the derived class does not implement this method, the51# NotImplementedError is raised.52#53# @param framework [Msf::Framework] framework to restore state to.54# @return [void] no implementation.55# @raise [NotImplementedError] raised if not implemented.56def fetch(framework)57raise NotImplementedError58end5960# This method adds a new storage class to the hash of storage classes that61# can be created through create.62#63# @param name [String] the name of the storage class.64# @param klass [PersistentStorage] the storage class to add.65# @return [void]66def self.add_storage_class(name, klass)67@@storage_classes[name] = klass68end6970protected7172end7374end75767778