Sha256: 95439ba5dd7e0a3df141dc8f362e6fb45d017d39ed655fecb27d7fac19b12b03

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

class MetasploitDataModels::AutomaticExploitation::MatchResult < ActiveRecord::Base
  attr_accessible :match_id, :run_id, :state

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

  VALID_STATES = [FAILED, SUCCEEDED]

  #
  # ASSOCIATIONS
  #

  belongs_to :match,
             class_name: 'MetasploitDataModels::AutomaticExploitation::Match',
             inverse_of: :match_results,
             dependent: :destroy

  belongs_to :run,
             inverse_of: :match_results,
             class_name: 'MetasploitDataModels::AutomaticExploitation::Run'

  #
  # VALIDATIONS
  #

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

  #
  # SCOPES
  #
  scope :succeeded, lambda { where(state:"succeeded") }
  scope :failed, lambda { where(state:"failed") }

  # 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

1 entries across 1 versions & 1 rubygems

Version Path
metasploit_data_models-0.24.5 app/models/metasploit_data_models/automatic_exploitation/match_result.rb