Purge the NoteSerializer and switch to Base64, have Base64 use the old format as well

unstable
HD Moore 2012-04-23 22:20:41 -05:00
parent 0a0f5459b4
commit 0e4593ce5b
4 changed files with 23 additions and 15 deletions

View File

@ -1,4 +1,4 @@
#!/home/egypt/.rvm/rubies/ruby-1.9.1-p378/bin/ruby
#!/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
#
# This file was generated by RubyGems.
#
@ -10,13 +10,9 @@ require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
end
gem 'metasploit_data_models', version

View File

@ -1,4 +1,3 @@
require 'metasploit_data_models/note_serializer'
module MetasploitDataModels::ActiveRecordModels::Note
def self.included(base)
base.class_eval{
@ -7,7 +6,7 @@ module MetasploitDataModels::ActiveRecordModels::Note
belongs_to :workspace, :class_name => "Mdm::Workspace"
belongs_to :host, :class_name => "Mdm::Host"
belongs_to :service, :class_name => "Mdm::Service"
serialize :data, ::MetasploitDataModels::NoteSerializer.new
serialize :data, ::MetasploitDataModels::Base64Serializer.new
scope :flagged, where('critical = true AND seen = false')
scope :visible, where(notes[:ntype].not_in(['web.form', 'web.url', 'web.vuln']))

View File

@ -1,7 +1,8 @@
# 2011-12-07
# 2012-04-23
#
# Provides ActiveRecord 3.1x-friendly serialization for descendants of
# ActiveRecord::Base
# ActiveRecord::Base. Backwards compatible with older YAML methods and
# will fall back to string decoding in the worst case
#
# usage:
# serialize :foo, MetasploitDataModels::Base64Serializer.new
@ -10,10 +11,22 @@ module MetasploitDataModels
class Base64Serializer
def load(value)
return {} if value.blank?
Marshal.load value.unpack('m').first
begin
# Load the unpacked Marshal object first
Marshal.load(value.unpack('m').first)
rescue
begin
# Support legacy YAML encoding for existing data
YAML.load(value)
rescue
# Fall back to string decoding
value
end
end
end
def dump(value)
# Always store data back in the Marshal format
[ Marshal.dump(value) ].pack('m')
end
end

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-04-17"
s.date = "2012-04-24"
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.22"
s.rubygems_version = "1.8.21"
s.summary = "Database code for MSF and Metasploit Pro"
if s.respond_to? :specification_version then