Sha256: a8a7f00823c07ee884721f9af821d0718e5bf37d51d04b87626dee3da58a31e7

Contents?: true

Size: 1.95 KB

Versions: 38

Compression:

Stored size: 1.95 KB

Contents

# The result of {#run running} a {#match}.
class MetasploitDataModels::AutomaticExploitation::MatchResult < ActiveRecord::Base
  #
  # CONSTANTS
  #

  # Running associated exploit did NOT create a session
  FAILED = "failed"
  # Running associated exploit created a session
  SUCCEEDED = "succeeded"

  # Valid values for {#state}
  VALID_STATES = [FAILED, SUCCEEDED]

  #
  # Associations
  #

  # A {MetasploitDataModels::AutomaticExploitation::Match#module_detail Metasploit Module} matched to
  # {MetasploitDataModels::AutomaticExploitation::Match#matchable Mdm::Host or Mdm::Service}.
  belongs_to :match,
             class_name: 'MetasploitDataModels::AutomaticExploitation::Match',
             inverse_of: :match_results,
             dependent: :destroy

  # A mass automatic exploitation run.
  belongs_to :run,
             inverse_of: :match_results,
             class_name: 'MetasploitDataModels::AutomaticExploitation::Run'

  #
  # Attributes
  #

  # @!attribute state
  #   Whether the {#run} of {#match} succeeded.
  #
  #   @return ['failed', 'succeeded']

  #
  # Validations
  #

  # must be present and one of allowable values
  validates :state,
            presence: true,
            inclusion: VALID_STATES

  #
  # Scopes
  #

  # Runs of {#match} that failed
  scope :failed, lambda { where(state:"failed") }

  # Runs of {#match} that succeeded
  scope :succeeded, lambda { where(state:"succeeded") }

  # Runs of {#match} by workspace ID
  scope :by_workspace, lambda { |workspace_id|
                       joins(
                         MetasploitDataModels::AutomaticExploitation::MatchResult.join_association(:match),
                         MetasploitDataModels::AutomaticExploitation::Match.join_association(:match_set)
                       ).where(
                         MetasploitDataModels::AutomaticExploitation::MatchSet[:workspace_id].eq(workspace_id),
                       )
                     }

  Metasploit::Concern.run(self)
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
metasploit_data_models-3.0.10 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.9 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.8 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.7 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.6 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.5 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.17 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.4 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.2 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.1 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-3.0.0 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.16 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.15 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.14 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.13 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.12 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.11 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.10 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.9 app/models/metasploit_data_models/automatic_exploitation/match_result.rb
metasploit_data_models-2.0.8 app/models/metasploit_data_models/automatic_exploitation/match_result.rb