fix migration crazieness

MS-1486
bug/bundler_fix
David Maloney 2016-05-11 14:05:34 -05:00
parent 6142d2cef1
commit 2fb3123ef2
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
4 changed files with 32 additions and 150 deletions

View File

@ -10,7 +10,7 @@ GIT
GIT
remote: git://github.com/rapid7/metasploit-credential.git
revision: 91c854a1158975d0fad46334773af90efc73d9bb
revision: 3a9bd597c0f91c32b3203a6c8c9bcfdee8988942
branch: staging/rails-upgrade
specs:
metasploit-credential (1.1.0)
@ -212,7 +212,7 @@ GEM
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
minitest (5.8.4)
msgpack (0.7.5)
msgpack (0.7.6)
multi_json (1.12.0)
multi_test (0.1.2)
multipart-post (2.0.0)
@ -260,7 +260,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (11.1.2)
rb-readline-r7 (0.5.2.0)
recog (2.0.20)
recog (2.0.21)
nokogiri
redcarpet (3.3.4)
rkelly-remix (0.0.6)

View File

@ -79,16 +79,6 @@ ActiveRecord::Schema.define(version: 20160415153312) do
t.datetime "updated_at"
end
create_table "credential_cores_tasks", id: false, force: :cascade do |t|
t.integer "core_id"
t.integer "task_id"
end
create_table "credential_logins_tasks", id: false, force: :cascade do |t|
t.integer "login_id"
t.integer "task_id"
end
create_table "creds", force: :cascade do |t|
t.integer "service_id", null: false
t.datetime "created_at", null: false
@ -232,114 +222,6 @@ ActiveRecord::Schema.define(version: 20160415153312) do
t.binary "prefs"
end
create_table "metasploit_credential_cores", force: :cascade do |t|
t.integer "origin_id", null: false
t.string "origin_type", null: false
t.integer "private_id"
t.integer "public_id"
t.integer "realm_id"
t.integer "workspace_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "logins_count", default: 0
end
add_index "metasploit_credential_cores", ["origin_type", "origin_id"], name: "index_metasploit_credential_cores_on_origin_type_and_origin_id", using: :btree
add_index "metasploit_credential_cores", ["private_id"], name: "index_metasploit_credential_cores_on_private_id", using: :btree
add_index "metasploit_credential_cores", ["public_id"], name: "index_metasploit_credential_cores_on_public_id", using: :btree
add_index "metasploit_credential_cores", ["realm_id"], name: "index_metasploit_credential_cores_on_realm_id", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "private_id"], name: "unique_private_metasploit_credential_cores", unique: true, where: "(((realm_id IS NULL) AND (public_id IS NULL)) AND (private_id IS NOT NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "public_id", "private_id"], name: "unique_realmless_metasploit_credential_cores", unique: true, where: "(((realm_id IS NULL) AND (public_id IS NOT NULL)) AND (private_id IS NOT NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "public_id"], name: "unique_public_metasploit_credential_cores", unique: true, where: "(((realm_id IS NULL) AND (public_id IS NOT NULL)) AND (private_id IS NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "realm_id", "private_id"], name: "unique_publicless_metasploit_credential_cores", unique: true, where: "(((realm_id IS NOT NULL) AND (public_id IS NULL)) AND (private_id IS NOT NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "realm_id", "public_id", "private_id"], name: "unique_complete_metasploit_credential_cores", unique: true, where: "(((realm_id IS NOT NULL) AND (public_id IS NOT NULL)) AND (private_id IS NOT NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id", "realm_id", "public_id"], name: "unique_privateless_metasploit_credential_cores", unique: true, where: "(((realm_id IS NOT NULL) AND (public_id IS NOT NULL)) AND (private_id IS NULL))", using: :btree
add_index "metasploit_credential_cores", ["workspace_id"], name: "index_metasploit_credential_cores_on_workspace_id", using: :btree
create_table "metasploit_credential_logins", force: :cascade do |t|
t.integer "core_id", null: false
t.integer "service_id", null: false
t.string "access_level"
t.string "status", null: false
t.datetime "last_attempted_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_logins", ["core_id", "service_id"], name: "index_metasploit_credential_logins_on_core_id_and_service_id", unique: true, using: :btree
add_index "metasploit_credential_logins", ["service_id", "core_id"], name: "index_metasploit_credential_logins_on_service_id_and_core_id", unique: true, using: :btree
create_table "metasploit_credential_origin_cracked_passwords", force: :cascade do |t|
t.integer "metasploit_credential_core_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_origin_cracked_passwords", ["metasploit_credential_core_id"], name: "originating_credential_cores", using: :btree
create_table "metasploit_credential_origin_imports", force: :cascade do |t|
t.text "filename", null: false
t.integer "task_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_origin_imports", ["task_id"], name: "index_metasploit_credential_origin_imports_on_task_id", using: :btree
create_table "metasploit_credential_origin_manuals", force: :cascade do |t|
t.integer "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_origin_manuals", ["user_id"], name: "index_metasploit_credential_origin_manuals_on_user_id", using: :btree
create_table "metasploit_credential_origin_services", force: :cascade do |t|
t.integer "service_id", null: false
t.text "module_full_name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_origin_services", ["service_id", "module_full_name"], name: "unique_metasploit_credential_origin_services", unique: true, using: :btree
create_table "metasploit_credential_origin_sessions", force: :cascade do |t|
t.text "post_reference_name", null: false
t.integer "session_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_origin_sessions", ["session_id", "post_reference_name"], name: "unique_metasploit_credential_origin_sessions", unique: true, using: :btree
create_table "metasploit_credential_privates", force: :cascade do |t|
t.string "type", null: false
t.text "data", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "jtr_format"
end
add_index "metasploit_credential_privates", ["type", "data"], name: "index_metasploit_credential_privates_on_type_and_data", unique: true, using: :btree
create_table "metasploit_credential_publics", force: :cascade do |t|
t.string "username", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "type", null: false
end
add_index "metasploit_credential_publics", ["username"], name: "index_metasploit_credential_publics_on_username", unique: true, using: :btree
create_table "metasploit_credential_realms", force: :cascade do |t|
t.string "key", null: false
t.string "value", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "metasploit_credential_realms", ["key", "value"], name: "index_metasploit_credential_realms_on_key_and_value", unique: true, using: :btree
create_table "mod_refs", force: :cascade do |t|
t.string "module", limit: 1024
t.string "mtype", limit: 128

View File

@ -5,30 +5,30 @@ Before do
end
# don't setup child processes to load simplecov_setup.rb if simplecov isn't installed
unless Bundler.settings.without.include?(:coverage)
Before do |scenario|
command_name = case scenario
when Cucumber::Ast::Scenario, Cucumber::Ast::ScenarioOutline
"#{scenario.feature.title} #{scenario.name}"
when Cucumber::Ast::OutlineTable::ExampleRow
scenario_outline = scenario.scenario_outline
"#{scenario_outline.feature.title} #{scenario_outline.name} #{scenario.name}"
else
raise TypeError, "Don't know how to extract command name from #{scenario.class}"
end
# Used in simplecov_setup so that each scenario has a different name and their coverage results are merged instead
# of overwriting each other as 'Cucumber Features'
set_env('SIMPLECOV_COMMAND_NAME', command_name)
simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
# set environment variable so child processes will merge their coverage data with parent process's coverage data.
set_env('RUBYOPT', "#{ENV['RUBYOPT']} -r#{simplecov_setup_pathname}")
end
Before('@db') do |scenario|
dbconfig = YAML::load(File.open(Metasploit::Framework::Database.configurations_pathname))
ActiveRecord::Base.establish_connection(dbconfig["test"])
end
end
# unless Bundler.settings.without.include?(:coverage)
# Before do |scenario|
# command_name = case scenario
# when Cucumber::Ast::Scenario, Cucumber::Ast::ScenarioOutline
# "#{scenario.feature.title} #{scenario.name}"
# when Cucumber::Ast::OutlineTable::ExampleRow
# scenario_outline = scenario.scenario_outline
#
# "#{scenario_outline.feature.title} #{scenario_outline.name} #{scenario.name}"
# else
# raise TypeError, "Don't know how to extract command name from #{scenario.class}"
# end
#
# # Used in simplecov_setup so that each scenario has a different name and their coverage results are merged instead
# # of overwriting each other as 'Cucumber Features'
# set_env('SIMPLECOV_COMMAND_NAME', command_name)
#
# simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
# # set environment variable so child processes will merge their coverage data with parent process's coverage data.
# set_env('RUBYOPT', "#{ENV['RUBYOPT']} -r#{simplecov_setup_pathname}")
# end
#
# Before('@db') do |scenario|
# dbconfig = YAML::load(File.open(Metasploit::Framework::Database.configurations_pathname))
# ActiveRecord::Base.establish_connection(dbconfig["test"])
# end
# end

View File

@ -3,7 +3,7 @@ namespace :db do
task :load_config do
# It's important to call to_a or the paths will just be relative and not realpaths
gem_migrations = Metasploit::Credential::Engine.instance.paths['db/migrate'].to_a
#ActiveRecord::Migrator.migrations_paths += gem_migrations
ActiveRecord::Tasks::DatabaseTasks.migrations_paths += gem_migrations
ActiveRecord::Migrator.migrations_paths += gem_migrations
#ActiveRecord::Tasks::DatabaseTasks.migrations_paths += gem_migrations
end
end