Sha256: 83f8ddcb4403ba15af9b3b1aaaf2d4c113421fa5fe778f22795fe74effdfd467

Contents?: true

Size: 1.52 KB

Versions: 31

Compression:

Stored size: 1.52 KB

Contents

# Implementation of {Metasploit::Model::Platform} to allow testing of {Metasploit::Model::Platform} using an in-memory
# ActiveModel and use of factories.
class Dummy::Platform < Metasploit::Model::Base
  include Metasploit::Model::Platform

  #
  # Attributes
  #

  # @!attribute [rw] fully_qualified_name
  #   The fully qualified name of this platform, as would be used in the platform list in a metasploit-framework
  #   module.
  #
  #   @return [String]
  attr_accessor :fully_qualified_name

  # @!attribute [rw] parent
  #   The parent platform of this platform.  For example, Windows is parent of Windows 98, which is the parent of
  #   Windows 98 FE.
  #
  #   @return [nil] if this is a top-level platform, such as Windows or Linux.
  #   @return [Metasploit::Model::Platform]
  attr_accessor :parent

  # @!attribute [rw] relative_name
  #   The name of this platform relative to the {#fully_qualified_name} of {#parent}.
  #
  #   @return [String]
  attr_accessor :relative_name

  #
  # Methods
  #

  def self.all
    # cache so that Dummy::Platform can be compared by identity
    unless instance_variable_defined? :@all
      @all = []

      Metasploit::Model::Platform.each_seed_attributes do |attributes|
        child = new(attributes)
        # validate to populate {#fully_qualified_name}
        child.valid!

        @all << child

        # yieldreturn
        child
      end

      # freeze objects to prevent specs from modifying them and interfering with other specs.
      @all.map(&:freeze)
    end

    @all
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
metasploit-model-0.28.0 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.28.0-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.28.0.pre.engine.pre.requires spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.4 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.4-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.3 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.3-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.2 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.2-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.1 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.1-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.0 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.0-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.27.0.pre.dep.pre.railties spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.26.1-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.26.1 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.25.7 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.25.7-java spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.25.6 spec/dummy/app/models/dummy/platform.rb
metasploit-model-0.25.6-java spec/dummy/app/models/dummy/platform.rb