metasploit_data_models 0.7.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.simplecov +38 -0
- data/.travis.yml +6 -0
- data/.yardopts +4 -0
- data/Gemfile +27 -0
- data/LICENSE +27 -0
- data/README.md +72 -0
- data/Rakefile +53 -0
- data/app/models/mdm/api_key.rb +20 -0
- data/app/models/mdm/client.rb +9 -0
- data/app/models/mdm/cred.rb +93 -0
- data/app/models/mdm/event.rb +30 -0
- data/app/models/mdm/exploit_attempt.rb +14 -0
- data/app/models/mdm/exploited_host.rb +11 -0
- data/app/models/mdm/host.rb +134 -0
- data/app/models/mdm/host_detail.rb +15 -0
- data/app/models/mdm/host_tag.rb +13 -0
- data/app/models/mdm/imported_cred.rb +10 -0
- data/app/models/mdm/listener.rb +24 -0
- data/app/models/mdm/loot.rb +63 -0
- data/app/models/mdm/macro.rb +20 -0
- data/app/models/mdm/mod_ref.rb +3 -0
- data/app/models/mdm/module_action.rb +24 -0
- data/app/models/mdm/module_arch.rb +24 -0
- data/app/models/mdm/module_author.rb +25 -0
- data/app/models/mdm/module_detail.rb +59 -0
- data/app/models/mdm/module_mixin.rb +24 -0
- data/app/models/mdm/module_platform.rb +24 -0
- data/app/models/mdm/module_ref.rb +24 -0
- data/app/models/mdm/module_target.rb +26 -0
- data/app/models/mdm/nexpose_console.rb +20 -0
- data/app/models/mdm/note.rb +49 -0
- data/app/models/mdm/profile.rb +9 -0
- data/app/models/mdm/ref.rb +14 -0
- data/app/models/mdm/report.rb +50 -0
- data/app/models/mdm/report_template.rb +27 -0
- data/app/models/mdm/route.rb +9 -0
- data/app/models/mdm/service.rb +56 -0
- data/app/models/mdm/session.rb +48 -0
- data/app/models/mdm/session_event.rb +9 -0
- data/app/models/mdm/tag.rb +46 -0
- data/app/models/mdm/task.rb +41 -0
- data/app/models/mdm/user.rb +25 -0
- data/app/models/mdm/vuln.rb +60 -0
- data/app/models/mdm/vuln_attempt.rb +15 -0
- data/app/models/mdm/vuln_detail.rb +14 -0
- data/app/models/mdm/vuln_ref.rb +13 -0
- data/app/models/mdm/web_form.rb +16 -0
- data/app/models/mdm/web_page.rb +16 -0
- data/app/models/mdm/web_site.rb +47 -0
- data/app/models/mdm/web_vuln.rb +190 -0
- data/app/models/mdm/wmap_request.rb +3 -0
- data/app/models/mdm/wmap_target.rb +3 -0
- data/app/models/mdm/workspace.rb +196 -0
- data/bin/mdm_console +68 -0
- data/console_db.yml +9 -0
- data/db/migrate/000_create_tables.rb +79 -0
- data/db/migrate/001_add_wmap_tables.rb +35 -0
- data/db/migrate/002_add_workspaces.rb +36 -0
- data/db/migrate/003_move_notes.rb +20 -0
- data/db/migrate/004_add_events_table.rb +16 -0
- data/db/migrate/005_expand_info.rb +58 -0
- data/db/migrate/006_add_timestamps.rb +26 -0
- data/db/migrate/007_add_loots.rb +20 -0
- data/db/migrate/008_create_users.rb +16 -0
- data/db/migrate/009_add_loots_ctype.rb +10 -0
- data/db/migrate/010_add_alert_fields.rb +16 -0
- data/db/migrate/011_add_reports.rb +19 -0
- data/db/migrate/012_add_tasks.rb +24 -0
- data/db/migrate/013_add_tasks_result.rb +10 -0
- data/db/migrate/014_add_loots_fields.rb +12 -0
- data/db/migrate/015_rename_user.rb +16 -0
- data/db/migrate/016_add_host_purpose.rb +10 -0
- data/db/migrate/017_expand_info2.rb +58 -0
- data/db/migrate/018_add_workspace_user_info.rb +29 -0
- data/db/migrate/019_add_workspace_desc.rb +23 -0
- data/db/migrate/020_add_user_preferences.rb +11 -0
- data/db/migrate/021_standardize_info_and_data.rb +18 -0
- data/db/migrate/022_enlarge_event_info.rb +10 -0
- data/db/migrate/023_add_report_downloaded_at.rb +10 -0
- data/db/migrate/024_convert_service_info_to_text.rb +12 -0
- data/db/migrate/025_add_user_admin.rb +19 -0
- data/db/migrate/026_add_creds_table.rb +19 -0
- data/db/migrate/20100819123300_migrate_cred_data.rb +154 -0
- data/db/migrate/20100824151500_add_exploited_table.rb +16 -0
- data/db/migrate/20100908001428_add_owner_to_workspaces.rb +9 -0
- data/db/migrate/20100911122000_add_report_templates.rb +18 -0
- data/db/migrate/20100916151530_require_admin_flag.rb +15 -0
- data/db/migrate/20100916175000_add_campaigns_and_templates.rb +61 -0
- data/db/migrate/20100920012100_add_generate_exe_column.rb +8 -0
- data/db/migrate/20100926214000_add_template_prefs.rb +11 -0
- data/db/migrate/20101001000000_add_web_tables.rb +57 -0
- data/db/migrate/20101002000000_add_query.rb +10 -0
- data/db/migrate/20101007000000_add_vuln_info.rb +15 -0
- data/db/migrate/20101008111800_add_clients_to_campaigns.rb +10 -0
- data/db/migrate/20101009023300_add_campaign_attachments.rb +15 -0
- data/db/migrate/20101104135100_add_imported_creds.rb +17 -0
- data/db/migrate/20101203000000_fix_web_tables.rb +34 -0
- data/db/migrate/20101203000001_expand_host_comment.rb +12 -0
- data/db/migrate/20101206212033_add_limit_to_network_to_workspaces.rb +9 -0
- data/db/migrate/20110112154300_add_module_uuid_to_tasks.rb +9 -0
- data/db/migrate/20110204112800_add_host_tags.rb +28 -0
- data/db/migrate/20110317144932_add_session_table.rb +110 -0
- data/db/migrate/20110414180600_add_local_id_to_session_table.rb +11 -0
- data/db/migrate/20110415175705_add_routes_table.rb +18 -0
- data/db/migrate/20110422000000_convert_binary.rb +73 -0
- data/db/migrate/20110425095900_add_last_seen_to_sessions.rb +8 -0
- data/db/migrate/20110513143900_track_successful_exploits.rb +31 -0
- data/db/migrate/20110517160800_rename_and_prune_nessus_vulns.rb +26 -0
- data/db/migrate/20110527000000_add_task_id_to_reports_table.rb +11 -0
- data/db/migrate/20110527000001_add_api_keys_table.rb +12 -0
- data/db/migrate/20110606000001_add_macros_table.rb +16 -0
- data/db/migrate/20110622000000_add_settings_to_tasks_table.rb +12 -0
- data/db/migrate/20110624000001_add_listeners_table.rb +19 -0
- data/db/migrate/20110625000001_add_macro_to_listeners_table.rb +12 -0
- data/db/migrate/20110630000001_add_nexpose_consoles_table.rb +21 -0
- data/db/migrate/20110630000002_add_name_to_nexpose_consoles_table.rb +12 -0
- data/db/migrate/20110717000001_add_profiles_table.rb +15 -0
- data/db/migrate/20110727163801_expand_cred_ptype_column.rb +9 -0
- data/db/migrate/20110730000001_add_initial_indexes.rb +85 -0
- data/db/migrate/20110812000001_prune_indexes.rb +23 -0
- data/db/migrate/20110922000000_expand_notes.rb +9 -0
- data/db/migrate/20110928101300_add_mod_ref_table.rb +17 -0
- data/db/migrate/20111011110000_add_display_name_to_reports_table.rb +24 -0
- data/db/migrate/20111203000000_inet_columns.rb +13 -0
- data/db/migrate/20111204000000_more_inet_columns.rb +17 -0
- data/db/migrate/20111210000000_add_scope_to_hosts.rb +9 -0
- data/db/migrate/20120126110000_add_virtual_host_to_hosts.rb +9 -0
- data/db/migrate/20120411173220_rename_workspace_members.rb +9 -0
- data/db/migrate/20120601152442_add_counter_caches_to_hosts.rb +21 -0
- data/db/migrate/20120625000000_add_vuln_details.rb +34 -0
- data/db/migrate/20120625000001_add_host_details.rb +16 -0
- data/db/migrate/20120625000002_expand_details.rb +16 -0
- data/db/migrate/20120625000003_expand_details2.rb +24 -0
- data/db/migrate/20120625000004_add_vuln_attempts.rb +19 -0
- data/db/migrate/20120625000005_add_vuln_and_host_counter_caches.rb +14 -0
- data/db/migrate/20120625000006_add_module_details.rb +118 -0
- data/db/migrate/20120625000007_add_exploit_attempts.rb +26 -0
- data/db/migrate/20120625000008_add_fail_message.rb +12 -0
- data/db/migrate/20120718202805_add_owner_and_payload_to_web_vulns.rb +13 -0
- data/db/migrate/20130228214900_change_required_columns_to_null_false_in_web_vulns.rb +35 -0
- data/db/migrate/20130423211152_add_creds_counter_cache.rb +24 -0
- data/lib/mdm.rb +12 -0
- data/lib/mdm/host/operating_system_normalization.rb +984 -0
- data/lib/metasploit_data_models.rb +60 -0
- data/lib/metasploit_data_models/base64_serializer.rb +103 -0
- data/lib/metasploit_data_models/engine.rb +23 -0
- data/lib/metasploit_data_models/serialized_prefs.rb +23 -0
- data/lib/metasploit_data_models/validators/ip_format_validator.rb +13 -0
- data/lib/metasploit_data_models/validators/password_is_strong_validator.rb +70 -0
- data/lib/metasploit_data_models/version.rb +8 -0
- data/lib/tasks/yard.rake +26 -0
- data/metasploit_data_models.gemspec +54 -0
- data/script/rails +8 -0
- data/spec/app/models/mdm/module_action_spec.rb +38 -0
- data/spec/app/models/mdm/module_arch_spec.rb +38 -0
- data/spec/app/models/mdm/module_author_spec.rb +50 -0
- data/spec/app/models/mdm/module_detail_spec.rb +291 -0
- data/spec/app/models/mdm/module_mixin_spec.rb +38 -0
- data/spec/app/models/mdm/module_platform_spec.rb +38 -0
- data/spec/app/models/mdm/module_ref_spec.rb +38 -0
- data/spec/app/models/mdm/module_target_spec.rb +41 -0
- data/spec/app/models/mdm/web_vuln_spec.rb +126 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml.example +22 -0
- data/spec/dummy/config/database.yml.travis +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +639 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/mdm/addresses.rb +7 -0
- data/spec/factories/mdm/hosts.rb +18 -0
- data/spec/factories/mdm/module_actions.rb +14 -0
- data/spec/factories/mdm/module_archs.rb +14 -0
- data/spec/factories/mdm/module_authors.rb +22 -0
- data/spec/factories/mdm/module_details.rb +9 -0
- data/spec/factories/mdm/module_mixins.rb +14 -0
- data/spec/factories/mdm/module_platforms.rb +14 -0
- data/spec/factories/mdm/module_refs.rb +14 -0
- data/spec/factories/mdm/module_targets.rb +19 -0
- data/spec/factories/mdm/services.rb +35 -0
- data/spec/factories/mdm/users.rb +22 -0
- data/spec/factories/mdm/web_sites.rb +8 -0
- data/spec/factories/mdm/web_vulns.rb +64 -0
- data/spec/factories/mdm/workspaces.rb +23 -0
- data/spec/lib/base64_serializer_spec.rb +174 -0
- data/spec/spec_helper.rb +36 -0
- metadata +472 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
class AddRoutesTable < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :routes do |t|
|
5
|
+
t.integer :session_id
|
6
|
+
t.string :subnet
|
7
|
+
t.string :netmask
|
8
|
+
end
|
9
|
+
|
10
|
+
remove_column :sessions, :routes
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :routes
|
15
|
+
|
16
|
+
add_column :sessions, :routes, :string
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
class ConvertBinary < ActiveRecord::Migration
|
3
|
+
|
4
|
+
|
5
|
+
class WebPage < ActiveRecord::Base
|
6
|
+
serialize :headers
|
7
|
+
end
|
8
|
+
|
9
|
+
class WebVuln < ActiveRecord::Base
|
10
|
+
serialize :params
|
11
|
+
end
|
12
|
+
|
13
|
+
def bfilter(str)
|
14
|
+
str = str.to_s
|
15
|
+
str.encoding = 'binary' if str.respond_to?('encoding=')
|
16
|
+
str.gsub(/[\x00\x7f-\xff]/, '')
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.up
|
20
|
+
rename_column :web_pages, :body, :body_text
|
21
|
+
rename_column :web_pages, :request, :request_text
|
22
|
+
rename_column :web_vulns, :request, :request_text
|
23
|
+
rename_column :web_vulns, :proof, :proof_text
|
24
|
+
|
25
|
+
add_column :web_pages, :body, :binary
|
26
|
+
add_column :web_pages, :request, :binary
|
27
|
+
add_column :web_vulns, :request, :binary
|
28
|
+
add_column :web_vulns, :proof, :binary
|
29
|
+
|
30
|
+
WebPage.find(:all).each { |r| r.body = r.body_text; r.save! }
|
31
|
+
WebPage.find(:all).each { |r| r.request = r.request_text; r.save! }
|
32
|
+
WebVuln.find(:all).each { |r| r.proof = r.proof_text; r.save! }
|
33
|
+
WebVuln.find(:all).each { |r| r.request = r.request_text; r.save! }
|
34
|
+
|
35
|
+
remove_column :web_pages, :body_text
|
36
|
+
remove_column :web_pages, :request_text
|
37
|
+
remove_column :web_vulns, :request_text
|
38
|
+
remove_column :web_vulns, :proof_text
|
39
|
+
|
40
|
+
WebPage.connection.schema_cache.clear!
|
41
|
+
WebPage.reset_column_information
|
42
|
+
WebVuln.connection.schema_cache.clear!
|
43
|
+
WebVuln.reset_column_information
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.down
|
47
|
+
|
48
|
+
rename_column :web_pages, :body, :body_binary
|
49
|
+
rename_column :web_pages, :request, :request_binary
|
50
|
+
rename_column :web_vulns, :request, :request_binary
|
51
|
+
rename_column :web_vulns, :proof, :proof_binary
|
52
|
+
|
53
|
+
add_column :web_pages, :body, :text
|
54
|
+
add_column :web_pages, :request, :text
|
55
|
+
add_column :web_vulns, :request, :text
|
56
|
+
add_column :web_vulns, :proof, :text
|
57
|
+
|
58
|
+
WebPage.find(:all).each { |r| r.body = bfilter(r.body_binary); r.save! }
|
59
|
+
WebPage.find(:all).each { |r| r.request = bfilter(r.request_binary); r.save! }
|
60
|
+
WebVuln.find(:all).each { |r| r.proof = bfilter(r.proof_binary); r.save! }
|
61
|
+
WebVuln.find(:all).each { |r| r.request = bfilter(r.request_binary); r.save! }
|
62
|
+
|
63
|
+
remove_column :web_pages, :body_binary
|
64
|
+
remove_column :web_pages, :request_binary
|
65
|
+
remove_column :web_vulns, :request_binary
|
66
|
+
remove_column :web_vulns, :proof_binary
|
67
|
+
|
68
|
+
WebPage.connection.schema_cache.clear!
|
69
|
+
WebPage.reset_column_information
|
70
|
+
WebVuln.connection.schema_cache.clear!
|
71
|
+
WebVuln.reset_column_information
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class TrackSuccessfulExploits < ActiveRecord::Migration
|
2
|
+
|
3
|
+
|
4
|
+
class ExploitedHost < ActiveRecord::Base
|
5
|
+
end
|
6
|
+
|
7
|
+
class Vuln < ActiveRecord::Base
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.up
|
11
|
+
add_column :vulns, :exploited_at, :timestamp
|
12
|
+
|
13
|
+
# Migrate existing exploited_hosts entries
|
14
|
+
|
15
|
+
ExploitedHost.find(:all).select {|x| x.name}.each do |exploited_host|
|
16
|
+
next unless(exploited_host.name =~ /^(exploit|auxiliary)\//)
|
17
|
+
vulns = Vuln.find_all_by_name_and_host_id(exploited_host.name, exploited_host.host_id)
|
18
|
+
next if vulns.empty?
|
19
|
+
vulns.each do |vuln|
|
20
|
+
vuln.exploited_at = exploited_host.updated_at
|
21
|
+
vuln.save
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.down
|
28
|
+
remove_column :vulns, :exploited_at
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class RenameAndPruneNessusVulns < ActiveRecord::Migration
|
2
|
+
|
3
|
+
class Vuln < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
# No table changes, just vuln renaming to drop the NSS id
|
7
|
+
# from those vulns that have it and a descriptive name.
|
8
|
+
def self.up
|
9
|
+
Vuln.find(:all).each do |v|
|
10
|
+
if v.name =~ /^NSS-0?\s*$/
|
11
|
+
v.delete
|
12
|
+
next
|
13
|
+
end
|
14
|
+
next unless(v.name =~ /^NSS-[0-9]+\s(.+)/)
|
15
|
+
new_name = $1
|
16
|
+
next if(new_name.nil? || new_name.strip.empty?)
|
17
|
+
v.name = new_name
|
18
|
+
v.save!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.down
|
23
|
+
say "Cannot un-rename and un-prune NSS vulns for migration 20110517160800."
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AddMacrosTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :macros do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.text :owner
|
6
|
+
t.text :name
|
7
|
+
t.text :description
|
8
|
+
t.binary :actions
|
9
|
+
t.binary :prefs
|
10
|
+
end
|
11
|
+
end
|
12
|
+
def self.down
|
13
|
+
drop_table :macros
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AddListenersTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :listeners do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.integer :workspace_id, :null => false, :default => 1
|
6
|
+
t.integer :task_id
|
7
|
+
t.boolean :enabled, :default => true
|
8
|
+
t.text :owner
|
9
|
+
t.text :payload
|
10
|
+
t.text :address
|
11
|
+
t.integer :port
|
12
|
+
t.binary :options
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def self.down
|
16
|
+
drop_table :listeners
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AddNexposeConsolesTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :nexpose_consoles do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.boolean :enabled, :default => true
|
6
|
+
t.text :owner
|
7
|
+
t.text :address
|
8
|
+
t.integer :port, :default => 3780
|
9
|
+
t.text :username
|
10
|
+
t.text :password
|
11
|
+
t.text :status
|
12
|
+
t.text :version
|
13
|
+
t.text :cert
|
14
|
+
t.binary :cached_sites
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def self.down
|
18
|
+
drop_table :nexpose_consoles
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddProfilesTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :profiles do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.boolean :active, :default => true
|
6
|
+
t.text :name
|
7
|
+
t.text :owner
|
8
|
+
t.binary :settings
|
9
|
+
end
|
10
|
+
end
|
11
|
+
def self.down
|
12
|
+
drop_table :profiles
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class AddInitialIndexes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
|
5
|
+
add_index :hosts, :address
|
6
|
+
add_index :hosts, :address6
|
7
|
+
add_index :hosts, :name
|
8
|
+
add_index :hosts, :state
|
9
|
+
add_index :hosts, :os_name
|
10
|
+
add_index :hosts, :os_flavor
|
11
|
+
add_index :hosts, :purpose
|
12
|
+
|
13
|
+
# Removed (conditionally dropped in the next migration)
|
14
|
+
# add_index :hosts, :comments
|
15
|
+
|
16
|
+
add_index :services, :port
|
17
|
+
add_index :services, :proto
|
18
|
+
add_index :services, :state
|
19
|
+
add_index :services, :name
|
20
|
+
|
21
|
+
# Removed (conditionally dropped in the next migration)
|
22
|
+
# add_index :services, :info
|
23
|
+
|
24
|
+
add_index :notes, :ntype
|
25
|
+
|
26
|
+
add_index :vulns, :name
|
27
|
+
|
28
|
+
# Removed (conditionally dropped in the next migration)
|
29
|
+
# add_index :vulns, :info
|
30
|
+
|
31
|
+
add_index :refs, :name
|
32
|
+
|
33
|
+
add_index :web_sites, :vhost
|
34
|
+
add_index :web_sites, :comments
|
35
|
+
add_index :web_sites, :options
|
36
|
+
|
37
|
+
add_index :web_pages, :path
|
38
|
+
add_index :web_pages, :query
|
39
|
+
|
40
|
+
add_index :web_forms, :path
|
41
|
+
|
42
|
+
add_index :web_vulns, :path
|
43
|
+
add_index :web_vulns, :method
|
44
|
+
add_index :web_vulns, :name
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.down
|
48
|
+
|
49
|
+
remove_index :hosts, :address
|
50
|
+
remove_index :hosts, :address6
|
51
|
+
remove_index :hosts, :name
|
52
|
+
remove_index :hosts, :state
|
53
|
+
remove_index :hosts, :os_name
|
54
|
+
remove_index :hosts, :os_flavor
|
55
|
+
remove_index :hosts, :purpose
|
56
|
+
remove_index :hosts, :comments
|
57
|
+
|
58
|
+
remove_index :services, :port
|
59
|
+
remove_index :services, :proto
|
60
|
+
remove_index :services, :state
|
61
|
+
remove_index :services, :name
|
62
|
+
remove_index :services, :info
|
63
|
+
|
64
|
+
remove_index :notes, :ntype
|
65
|
+
|
66
|
+
remove_index :vulns, :name
|
67
|
+
remove_index :vulns, :info
|
68
|
+
|
69
|
+
remove_index :refs, :name
|
70
|
+
|
71
|
+
remove_index :web_sites, :vhost
|
72
|
+
remove_index :web_sites, :comments
|
73
|
+
remove_index :web_sites, :options
|
74
|
+
|
75
|
+
remove_index :web_pages, :path
|
76
|
+
remove_index :web_pages, :query
|
77
|
+
|
78
|
+
remove_index :web_forms, :path
|
79
|
+
|
80
|
+
remove_index :web_vulns, :path
|
81
|
+
remove_index :web_vulns, :method
|
82
|
+
remove_index :web_vulns, :name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class PruneIndexes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
if indexes(:hosts).map{|x| x.columns }.flatten.include?("comments")
|
5
|
+
remove_index :hosts, :comments
|
6
|
+
end
|
7
|
+
|
8
|
+
if indexes(:services).map{|x| x.columns }.flatten.include?("info")
|
9
|
+
remove_index :services, :info
|
10
|
+
end
|
11
|
+
|
12
|
+
if indexes(:vulns).map{|x| x.columns }.flatten.include?("info")
|
13
|
+
remove_index :vulns, :info
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
add_index :hosts, :comments
|
19
|
+
add_index :services, :info
|
20
|
+
add_index :vulns, :info
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|