MDM Update

unstable
Samuel Huckins 2012-06-01 10:55:25 -05:00
parent 9d6fc93ed3
commit 2e15ecfbd7
9 changed files with 20 additions and 10 deletions

View File

@ -4,5 +4,3 @@ gem 'metasploit_data_models', '0.0.2', :git => "git://github.com/rapid7/metasplo
gem 'pg', '>=0.13'
gem 'msgpack'
gem 'nokogiri'

View File

@ -1,4 +1,4 @@
#!/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
#!/usr/bin/env ruby_noexec_wrapper
#
# This file was generated by RubyGems.
#

View File

@ -3,7 +3,8 @@ module MetasploitDataModels::ActiveRecordModels::Host
base.class_eval{
belongs_to :workspace, :class_name => "Mdm::Workspace"
has_and_belongs_to_many :tags, :join_table => :hosts_tags, :class_name => "Mdm::Tag"
has_many :hosts_tags, :class_name => "Mdm::HostTag"
has_many :tags, :through => :hosts_tags, :class_name => "Mdm::Tag"
has_many :services, :dependent => :destroy, :class_name => "Mdm::Service", :order => "services.port, services.proto"
has_many :clients, :dependent => :delete_all, :class_name => "Mdm::Client"
has_many :vulns, :dependent => :delete_all, :class_name => "Mdm::Vuln"

View File

@ -0,0 +1,10 @@
module MetasploitDataModels::ActiveRecordModels::HostTag
def self.included(base)
base.class_eval {
base.table_name = "hosts_tags"
belongs_to :host, :class_name => "Mdm::Host"
belongs_to :tag, :class_name => "Mdm::Tag"
}
end
end

View File

@ -4,7 +4,7 @@ module MetasploitDataModels::ActiveRecordModels::Note
notes = base.arel_table
belongs_to :workspace, :class_name => "Mdm::Workspace"
belongs_to :host, :class_name => "Mdm::Host"
belongs_to :host, :class_name => "Mdm::Host", :counter_cache => :note_count
belongs_to :service, :class_name => "Mdm::Service"
serialize :data, ::MetasploitDataModels::Base64Serializer.new

View File

@ -11,7 +11,7 @@ module MetasploitDataModels::ActiveRecordModels::Service
has_many :web_forms, :through => :web_sites, :class_name => "Mdm::WebForm"
has_many :web_vulns, :through => :web_sites, :class_name => "Mdm::WebVuln"
belongs_to :host, :class_name => "Mdm::Host"
belongs_to :host, :class_name => "Mdm::Host", :counter_cache => :service_count
has_many :web_pages, :through => :web_sites
has_many :web_forms, :through => :web_sites

View File

@ -1,8 +1,9 @@
module MetasploitDataModels::ActiveRecordModels::Tag
def self.included(base)
base.class_eval {
has_many :hosts_tags, :class_name => "Mdm::HostTag"
has_many :hosts, :through => :hosts_tags, :class_name => "Mdm::Host"
has_and_belongs_to_many :hosts, :join_table => :hosts_tags, :class_name => "Mdm::Host"
belongs_to :user, :class_name => "Mdm::User"
validates :name, :presence => true, :format => {

View File

@ -1,7 +1,7 @@
module MetasploitDataModels::ActiveRecordModels::Vuln
def self.included(base)
base.class_eval {
belongs_to :host, :class_name => "Mdm::Host"
belongs_to :host, :class_name => "Mdm::Host", :counter_cache => :vuln_count
belongs_to :service, :class_name => "Mdm::Service", :foreign_key => :service_id
has_and_belongs_to_many :refs, :join_table => :vulns_refs, :class_name => "Mdm::Ref"

View File

@ -6,14 +6,14 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Trevor Rosen"]
s.date = "2012-05-18"
s.date = "2012-06-01"
s.description = "Implements minimal ActiveRecord models and database helper code used in both the Metasploit Framework (MSF) and Metasploit commercial editions."
s.email = ["trevor_rosen@rapid7.com"]
s.executables = ["mdm_console"]
s.files = ["bin/mdm_console"]
s.homepage = ""
s.require_paths = ["lib"]
s.rubygems_version = "1.8.15"
s.rubygems_version = "1.8.24"
s.summary = "Database code for MSF and Metasploit Pro"
if s.respond_to? :specification_version then