Fix regression issue with serializing reported events
This commit is contained in:
parent
31e0e73e56
commit
4b818000fc
|
@ -168,10 +168,13 @@ class DataStore < Hash
|
|||
return str
|
||||
end
|
||||
|
||||
# Override Hash's to_h method so we can include the original case of each key
|
||||
# (failing to do this breaks a number of places in framework and pro that use
|
||||
# serialized datastores)
|
||||
def to_h
|
||||
datastore_hash = {}
|
||||
self.keys.each do |k|
|
||||
datastore_hash[k.to_s] = self[k]
|
||||
datastore_hash[k.to_s] = self[k].to_s
|
||||
end
|
||||
datastore_hash
|
||||
end
|
||||
|
|
|
@ -23,8 +23,13 @@ RSpec::Matchers.define :have_datastore_values do |expected|
|
|||
ssh_keys = %w[RHOSTS RPORT USERNAME PASSWORD]
|
||||
required_keys = http_keys + smb_keys + mysql_keys + postgres_keys + ssh_keys
|
||||
datastores.map do |datastore|
|
||||
# Workaround: Manually convert the datastore to a hash ourselves as `datastore.to_h` coerces all datatypes into strings
|
||||
# which prevents this test suite from validating types correctly. i.e. The tests need to ensure that RPORT is correctly
|
||||
# set as an integer class etc.
|
||||
datastore_hash = datastore.keys.each_with_object({}) { |key, hash| hash[key] = datastore[key] }
|
||||
|
||||
# Slice the datastore options that we care about, ignoring other values that just add noise such as VERBOSE/WORKSPACE/etc.
|
||||
datastore.to_h.slice(*required_keys)
|
||||
datastore_hash.slice(*required_keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue