2009-12-14 22:52:34 +00:00
|
|
|
module Msf
|
|
|
|
class DBManager
|
|
|
|
|
|
|
|
class Host < ActiveRecord::Base
|
|
|
|
include DBSave
|
|
|
|
|
|
|
|
belongs_to :workspace
|
2011-02-08 18:53:55 +00:00
|
|
|
has_and_belongs_to_many :tags, :join_table => :hosts_tags
|
2009-12-14 22:52:34 +00:00
|
|
|
has_many :services, :dependent => :destroy
|
|
|
|
has_many :clients, :dependent => :destroy
|
|
|
|
has_many :vulns, :dependent => :destroy
|
|
|
|
has_many :notes, :dependent => :destroy
|
2010-05-07 06:37:00 +00:00
|
|
|
has_many :loots, :dependent => :destroy, :order => "loots.created_at desc"
|
2009-12-14 22:52:34 +00:00
|
|
|
|
2009-12-29 23:48:45 +00:00
|
|
|
has_many :service_notes, :through => :services
|
2010-10-02 18:48:29 +00:00
|
|
|
has_many :web_sites, :through => :services
|
2010-08-18 00:58:20 +00:00
|
|
|
has_many :creds, :through => :services
|
2010-08-24 21:57:04 +00:00
|
|
|
has_many :exploited_hosts, :dependent => :destroy
|
2009-12-29 23:48:45 +00:00
|
|
|
|
2010-03-20 14:38:50 +00:00
|
|
|
validates_exclusion_of :address, :in => ['127.0.0.1']
|
2009-12-14 22:52:34 +00:00
|
|
|
validates_uniqueness_of :address, :scope => :workspace_id
|
2011-01-20 23:10:27 +00:00
|
|
|
|
|
|
|
def attribute_locked?(attr)
|
|
|
|
n = notes.find_by_ntype("host.updated.#{attr}")
|
|
|
|
n && n.data[:locked]
|
|
|
|
end
|
|
|
|
|
2009-12-14 22:52:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-12-29 23:48:45 +00:00
|
|
|
end
|