Sha256: 3a18ea0cfd1ee7d4a50cb578b9dc7268ec3453baf7384b581fae2d46f9bbbeff

Contents?: true

Size: 863 Bytes

Versions: 22

Compression:

Stored size: 863 Bytes

Contents

class ValidMdmWebVulnParams < ActiveRecord::Migration[4.2]
  # Don't put back the bad format because there's not way to figure our which of the [] were '' before {#up} and
  # which were `[]` before {#up}.
  #
  # @return [void]
  def down
  end

  # Changes any Mdm::WebVuln#params with value `''` to value `[]`.
  #
  # @return [void]
  def up
    # Can't search serialized columns, so have to load all the Mdm::WebVulns in memory
    Mdm::WebVuln.find_each do |web_vuln|
      if web_vuln.invalid?
        # cast nil, '' and {} to correct [].
        if web_vuln.params.blank?
          web_vuln.params = []
        end

        # If its still invalid have to destroy the Mdm::WebVuln or a different export error could occur.
        if web_vuln.invalid?
          web_vuln.destroy
        else
          web_vuln.save!
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
wg-metasploit_data_models-4.1.4.02 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.5 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.4 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.3 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.2 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.1 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-6.0.0 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.6 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.5 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.4 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.3 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.2 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.1 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-5.0.0 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.1.4 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.1.3 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.1.2 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.1.1 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.1.0 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
metasploit_data_models-4.0.2 db/migrate/20130515172727_valid_mdm_web_vuln_params.rb