adjust templates, move SerializedPrefs into its own file

git-svn-id: file:///home/svn/framework3/trunk@10494 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2010-09-27 04:12:04 +00:00
parent 7b2a29365f
commit 337a0be8fc
6 changed files with 53 additions and 23 deletions

View File

@ -0,0 +1,11 @@
class AddTemplatePrefs < ActiveRecord::Migration
def self.up
remove_column :email_templates, :generate_exe
add_column :email_templates, :prefs, :text
add_column :web_templates, :prefs, :text
end
def self.down
remove_column :email_templates, :prefs
remove_column :web_templates, :prefs
end
end

View File

@ -1,3 +1,6 @@
require 'msf/core/model/serialized_prefs'
require 'msf/core/model/activerecord_patches' require 'msf/core/model/activerecord_patches'
require 'msf/core/model/user' require 'msf/core/model/user'
@ -24,4 +27,3 @@ require 'msf/core/model/campaign'
require 'msf/core/model/email_address' require 'msf/core/model/email_address'
require 'msf/core/model/email_template' require 'msf/core/model/email_template'
require 'msf/core/model/web_template' require 'msf/core/model/web_template'

View File

@ -1,28 +1,6 @@
module Msf module Msf
class DBManager class DBManager
module SerializedPrefs
def serialized_prefs_attr_accessor(*args)
args.each do |method_name|
method_declarations = %Q^
def #{method_name}
return if not self.prefs
self.prefs[:#{method_name}]
end
def #{method_name}=(value)
temp = self.prefs || {}
temp[:#{method_name}] = value
self.prefs = temp
end
^
class_eval method_declarations
end
end
end
class Campaign < ActiveRecord::Base class Campaign < ActiveRecord::Base
has_one :email_template has_one :email_template
has_one :web_template has_one :web_template

View File

@ -4,6 +4,13 @@ class DBManager
class EmailTemplate < ActiveRecord::Base class EmailTemplate < ActiveRecord::Base
belongs_to :campaign belongs_to :campaign
has_and_belongs_to_many :attachments has_and_belongs_to_many :attachments
extend SerializedPrefs
serialize :prefs
serialized_prefs_attr_accessor :exploit_name, :exploit_opts
serialized_prefs_attr_accessor :generate_exe
end end
end end

View File

@ -0,0 +1,25 @@
module Msf
class DBManager
module SerializedPrefs
def serialized_prefs_attr_accessor(*args)
args.each do |method_name|
method_declarations = %Q^
def #{method_name}
return if not self.prefs
self.prefs[:#{method_name}]
end
def #{method_name}=(value)
temp = self.prefs || {}
temp[:#{method_name}] = value
self.prefs = temp
end
^
class_eval method_declarations
end
end
end
end
end

View File

@ -3,6 +3,13 @@ class DBManager
class WebTemplate < ActiveRecord::Base class WebTemplate < ActiveRecord::Base
belongs_to :campaign belongs_to :campaign
extend SerializedPrefs
serialize :prefs
serialized_prefs_attr_accessor :exploit_type
serialized_prefs_attr_accessor :exploit_name, :exploit_opts
end end
end end