metasploit_data_models 3.0.8 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +1 -3
  3. data.tar.gz.sig +1 -1
  4. data/.gitignore +1 -1
  5. data/.travis.yml +1 -1
  6. data/Gemfile +6 -4
  7. data/Rakefile +1 -1
  8. data/app/models/mdm/api_key.rb +2 -2
  9. data/app/models/mdm/async_callback.rb +64 -0
  10. data/app/models/mdm/client.rb +1 -1
  11. data/app/models/mdm/cred.rb +1 -1
  12. data/app/models/mdm/event.rb +1 -1
  13. data/app/models/mdm/exploit_attempt.rb +1 -1
  14. data/app/models/mdm/exploited_host.rb +1 -1
  15. data/app/models/mdm/host.rb +2 -2
  16. data/app/models/mdm/host_detail.rb +2 -2
  17. data/app/models/mdm/host_tag.rb +1 -1
  18. data/app/models/mdm/listener.rb +1 -1
  19. data/app/models/mdm/loot.rb +1 -1
  20. data/app/models/mdm/macro.rb +1 -1
  21. data/app/models/mdm/mod_ref.rb +1 -1
  22. data/app/models/mdm/module/action.rb +1 -1
  23. data/app/models/mdm/module/arch.rb +1 -1
  24. data/app/models/mdm/module/author.rb +1 -1
  25. data/app/models/mdm/module/detail.rb +1 -1
  26. data/app/models/mdm/module/mixin.rb +1 -1
  27. data/app/models/mdm/module/platform.rb +1 -1
  28. data/app/models/mdm/module/ref.rb +1 -1
  29. data/app/models/mdm/module/target.rb +1 -1
  30. data/app/models/mdm/nexpose_console.rb +1 -1
  31. data/app/models/mdm/note.rb +2 -2
  32. data/app/models/mdm/payload.rb +1 -16
  33. data/app/models/mdm/profile.rb +1 -1
  34. data/app/models/mdm/ref.rb +1 -1
  35. data/app/models/mdm/route.rb +1 -1
  36. data/app/models/mdm/service.rb +2 -2
  37. data/app/models/mdm/session.rb +1 -1
  38. data/app/models/mdm/session_event.rb +1 -1
  39. data/app/models/mdm/tag.rb +1 -1
  40. data/app/models/mdm/task.rb +1 -1
  41. data/app/models/mdm/task_cred.rb +1 -1
  42. data/app/models/mdm/task_host.rb +1 -1
  43. data/app/models/mdm/task_service.rb +1 -1
  44. data/app/models/mdm/task_session.rb +1 -1
  45. data/app/models/mdm/user.rb +2 -2
  46. data/app/models/mdm/vuln.rb +2 -2
  47. data/app/models/mdm/vuln_attempt.rb +1 -1
  48. data/app/models/mdm/vuln_detail.rb +1 -1
  49. data/app/models/mdm/vuln_ref.rb +1 -1
  50. data/app/models/mdm/web_form.rb +1 -1
  51. data/app/models/mdm/web_page.rb +1 -1
  52. data/app/models/mdm/web_site.rb +1 -1
  53. data/app/models/mdm/web_vuln.rb +1 -1
  54. data/app/models/mdm/wmap_request.rb +1 -1
  55. data/app/models/mdm/wmap_target.rb +1 -1
  56. data/app/models/mdm/workspace.rb +6 -9
  57. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +1 -1
  58. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +1 -1
  59. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +1 -1
  60. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +2 -2
  61. data/app/models/metasploit_data_models/module_run.rb +1 -1
  62. data/app/validators/ip_format_validator.rb +1 -1
  63. data/app/validators/parameters_validator.rb +7 -7
  64. data/bin/rails +14 -0
  65. data/config/initializers/arel_helper.rb +2 -2
  66. data/config/initializers/ipaddr.rb +11 -6
  67. data/db/migrate/000_create_tables.rb +1 -1
  68. data/db/migrate/001_add_wmap_tables.rb +1 -1
  69. data/db/migrate/002_add_workspaces.rb +1 -1
  70. data/db/migrate/003_move_notes.rb +1 -1
  71. data/db/migrate/004_add_events_table.rb +1 -1
  72. data/db/migrate/005_expand_info.rb +1 -1
  73. data/db/migrate/006_add_timestamps.rb +1 -1
  74. data/db/migrate/007_add_loots.rb +1 -1
  75. data/db/migrate/008_create_users.rb +1 -1
  76. data/db/migrate/009_add_loots_ctype.rb +1 -1
  77. data/db/migrate/010_add_alert_fields.rb +1 -1
  78. data/db/migrate/011_add_reports.rb +1 -1
  79. data/db/migrate/012_add_tasks.rb +1 -1
  80. data/db/migrate/013_add_tasks_result.rb +1 -1
  81. data/db/migrate/014_add_loots_fields.rb +1 -1
  82. data/db/migrate/015_rename_user.rb +1 -1
  83. data/db/migrate/016_add_host_purpose.rb +1 -1
  84. data/db/migrate/017_expand_info2.rb +1 -1
  85. data/db/migrate/018_add_workspace_user_info.rb +1 -1
  86. data/db/migrate/019_add_workspace_desc.rb +1 -1
  87. data/db/migrate/020_add_user_preferences.rb +1 -1
  88. data/db/migrate/021_standardize_info_and_data.rb +1 -1
  89. data/db/migrate/022_enlarge_event_info.rb +1 -1
  90. data/db/migrate/023_add_report_downloaded_at.rb +1 -1
  91. data/db/migrate/024_convert_service_info_to_text.rb +1 -1
  92. data/db/migrate/025_add_user_admin.rb +1 -1
  93. data/db/migrate/026_add_creds_table.rb +1 -1
  94. data/db/migrate/20100819123300_migrate_cred_data.rb +1 -1
  95. data/db/migrate/20100824151500_add_exploited_table.rb +1 -1
  96. data/db/migrate/20100908001428_add_owner_to_workspaces.rb +1 -1
  97. data/db/migrate/20100911122000_add_report_templates.rb +1 -1
  98. data/db/migrate/20100916151530_require_admin_flag.rb +1 -1
  99. data/db/migrate/20100916175000_add_campaigns_and_templates.rb +1 -1
  100. data/db/migrate/20100920012100_add_generate_exe_column.rb +1 -1
  101. data/db/migrate/20100926214000_add_template_prefs.rb +1 -1
  102. data/db/migrate/20101001000000_add_web_tables.rb +1 -1
  103. data/db/migrate/20101002000000_add_query.rb +1 -1
  104. data/db/migrate/20101007000000_add_vuln_info.rb +1 -1
  105. data/db/migrate/20101008111800_add_clients_to_campaigns.rb +1 -1
  106. data/db/migrate/20101009023300_add_campaign_attachments.rb +1 -1
  107. data/db/migrate/20101104135100_add_imported_creds.rb +1 -1
  108. data/db/migrate/20101203000000_fix_web_tables.rb +1 -1
  109. data/db/migrate/20101203000001_expand_host_comment.rb +1 -1
  110. data/db/migrate/20101206212033_add_limit_to_network_to_workspaces.rb +1 -1
  111. data/db/migrate/20110112154300_add_module_uuid_to_tasks.rb +1 -1
  112. data/db/migrate/20110204112800_add_host_tags.rb +1 -1
  113. data/db/migrate/20110317144932_add_session_table.rb +4 -4
  114. data/db/migrate/20110414180600_add_local_id_to_session_table.rb +1 -1
  115. data/db/migrate/20110415175705_add_routes_table.rb +1 -1
  116. data/db/migrate/20110422000000_convert_binary.rb +3 -3
  117. data/db/migrate/20110425095900_add_last_seen_to_sessions.rb +1 -1
  118. data/db/migrate/20110513143900_track_successful_exploits.rb +3 -3
  119. data/db/migrate/20110517160800_rename_and_prune_nessus_vulns.rb +2 -2
  120. data/db/migrate/20110527000000_add_task_id_to_reports_table.rb +1 -1
  121. data/db/migrate/20110527000001_add_api_keys_table.rb +1 -1
  122. data/db/migrate/20110606000001_add_macros_table.rb +1 -1
  123. data/db/migrate/20110622000000_add_settings_to_tasks_table.rb +1 -1
  124. data/db/migrate/20110624000001_add_listeners_table.rb +1 -1
  125. data/db/migrate/20110625000001_add_macro_to_listeners_table.rb +1 -1
  126. data/db/migrate/20110630000001_add_nexpose_consoles_table.rb +1 -1
  127. data/db/migrate/20110630000002_add_name_to_nexpose_consoles_table.rb +1 -1
  128. data/db/migrate/20110717000001_add_profiles_table.rb +1 -1
  129. data/db/migrate/20110727163801_expand_cred_ptype_column.rb +1 -1
  130. data/db/migrate/20110730000001_add_initial_indexes.rb +1 -1
  131. data/db/migrate/20110812000001_prune_indexes.rb +1 -1
  132. data/db/migrate/20110922000000_expand_notes.rb +1 -1
  133. data/db/migrate/20110928101300_add_mod_ref_table.rb +1 -1
  134. data/db/migrate/20111011110000_add_display_name_to_reports_table.rb +2 -2
  135. data/db/migrate/20111203000000_inet_columns.rb +1 -1
  136. data/db/migrate/20111204000000_more_inet_columns.rb +1 -1
  137. data/db/migrate/20111210000000_add_scope_to_hosts.rb +1 -1
  138. data/db/migrate/20120126110000_add_virtual_host_to_hosts.rb +1 -1
  139. data/db/migrate/20120411173220_rename_workspace_members.rb +1 -1
  140. data/db/migrate/20120601152442_add_counter_caches_to_hosts.rb +2 -2
  141. data/db/migrate/20120625000000_add_vuln_details.rb +1 -1
  142. data/db/migrate/20120625000001_add_host_details.rb +1 -1
  143. data/db/migrate/20120625000002_expand_details.rb +1 -1
  144. data/db/migrate/20120625000003_expand_details2.rb +1 -1
  145. data/db/migrate/20120625000004_add_vuln_attempts.rb +1 -1
  146. data/db/migrate/20120625000005_add_vuln_and_host_counter_caches.rb +1 -1
  147. data/db/migrate/20120625000006_add_module_details.rb +1 -1
  148. data/db/migrate/20120625000007_add_exploit_attempts.rb +1 -1
  149. data/db/migrate/20120625000008_add_fail_message.rb +1 -1
  150. data/db/migrate/20120718202805_add_owner_and_payload_to_web_vulns.rb +1 -1
  151. data/db/migrate/20130412154159_change_foreign_key_in_module_actions.rb +1 -1
  152. data/db/migrate/20130412171844_change_foreign_key_in_module_archs.rb +1 -1
  153. data/db/migrate/20130412173121_change_foreign_key_in_module_authors.rb +1 -1
  154. data/db/migrate/20130412173640_change_foreign_key_in_module_mixins.rb +1 -1
  155. data/db/migrate/20130412174254_change_foreign_key_in_module_platforms.rb +1 -1
  156. data/db/migrate/20130412174719_change_foreign_key_in_module_refs.rb +1 -1
  157. data/db/migrate/20130412175040_change_foreign_key_in_module_targets.rb +1 -1
  158. data/db/migrate/20130423211152_add_creds_counter_cache.rb +1 -1
  159. data/db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb +6 -6
  160. data/db/migrate/20130510021637_remove_campaigns.rb +1 -1
  161. data/db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb +1 -1
  162. data/db/migrate/20130515172727_valid_mdm_web_vuln_params.rb +1 -1
  163. data/db/migrate/20130516204810_making_vulns_refs_a_real_ar_model.rb +2 -2
  164. data/db/migrate/20130522001343_create_task_creds.rb +1 -1
  165. data/db/migrate/20130522032517_create_task_hosts.rb +1 -1
  166. data/db/migrate/20130522041110_create_task_services.rb +1 -1
  167. data/db/migrate/20130525015035_remove_campaign_id_from_clients.rb +1 -1
  168. data/db/migrate/20130525212420_drop_table_imported_creds.rb +1 -1
  169. data/db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb +1 -1
  170. data/db/migrate/20130604145732_create_task_sessions.rb +1 -1
  171. data/db/migrate/20130717150737_remove_pname_validation.rb +1 -1
  172. data/db/migrate/20131002004641_create_automatic_exploitation_matches.rb +1 -1
  173. data/db/migrate/20131002164449_create_automatic_exploitation_match_sets.rb +1 -1
  174. data/db/migrate/20131008213344_create_automatic_exploitation_runs.rb +1 -1
  175. data/db/migrate/20131011184338_module_detail_on_automatic_exploitation_match.rb +1 -1
  176. data/db/migrate/20131017150735_create_automatic_exploitation_match_results.rb +1 -1
  177. data/db/migrate/20131021185657_make_match_polymorphic.rb +1 -1
  178. data/db/migrate/20140905031549_add_detected_arch_to_host.rb +1 -1
  179. data/db/migrate/20150112203945_remove_duplicate_services.rb +1 -1
  180. data/db/migrate/20150205192745_drop_service_uniqueness_index.rb +1 -1
  181. data/db/migrate/20150209195939_add_vuln_id_to_note.rb +1 -1
  182. data/db/migrate/20150212214222_remove_duplicate_services2.rb +1 -1
  183. data/db/migrate/20150219173821_create_module_runs.rb +1 -1
  184. data/db/migrate/20150219215039_add_module_run_to_session.rb +1 -1
  185. data/db/migrate/20150226151459_add_module_run_fk_to_loot.rb +1 -1
  186. data/db/migrate/20150312155312_add_module_full_name_to_match.rb +1 -1
  187. data/db/migrate/20150317145455_rename_module_indices.rb +2 -2
  188. data/db/migrate/20150326183742_add_missing_ae_indices.rb +1 -1
  189. data/db/migrate/20150421211719_rename_automatic_exploitation_index.rb +3 -3
  190. data/db/migrate/20150514182921_add_origin_to_mdm_vuln.rb +1 -1
  191. data/db/migrate/20160415153312_remove_not_null_from_web_vuln_p_arams.rb +1 -1
  192. data/db/migrate/20161004165612_add_fingerprinted_to_workspace.rb +1 -1
  193. data/db/migrate/20161227212223_add_os_family_to_hosts.rb +1 -1
  194. data/db/migrate/20180904120211_create_payloads.rb +1 -1
  195. data/db/migrate/20190308134512_create_async_callbacks.rb +14 -0
  196. data/db/migrate/20190507120211_remove_payload_workspaces.rb +5 -0
  197. data/lib/mdm.rb +1 -0
  198. data/lib/metasploit_data_models.rb +0 -1
  199. data/lib/metasploit_data_models/automatic_exploitation.rb +1 -1
  200. data/lib/metasploit_data_models/base64_serializer.rb +1 -1
  201. data/lib/metasploit_data_models/change_required_columns_to_null_false.rb +2 -2
  202. data/lib/metasploit_data_models/engine.rb +1 -1
  203. data/lib/metasploit_data_models/version.rb +1 -1
  204. data/metasploit_data_models.gemspec +4 -8
  205. data/spec/app/models/mdm/exploit_attempt_spec.rb +2 -2
  206. data/spec/app/models/mdm/host_detail_spec.rb +1 -1
  207. data/spec/app/models/mdm/host_spec.rb +27 -27
  208. data/spec/app/models/mdm/module/detail_spec.rb +18 -18
  209. data/spec/app/models/mdm/service_spec.rb +1 -0
  210. data/spec/app/models/mdm/vuln_attempt_spec.rb +1 -1
  211. data/spec/app/models/mdm/vuln_detail_spec.rb +1 -1
  212. data/spec/app/models/mdm/vuln_spec.rb +1 -1
  213. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +4 -4
  214. data/spec/dummy/app/assets/config/manifest.js +1 -0
  215. data/spec/dummy/app/models/application_record.rb +3 -0
  216. data/spec/dummy/db/structure.sql +213 -329
  217. metadata +92 -98
  218. metadata.gz.sig +0 -0
  219. data/spec/dummy/config/initializers/secret_token.rb +0 -7
@@ -1,4 +1,4 @@
1
- class AddMissingAeIndices < ActiveRecord::Migration
1
+ class AddMissingAeIndices < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  add_index :automatic_exploitation_match_results, :match_id
4
4
  add_index :automatic_exploitation_match_results, :run_id
@@ -1,13 +1,13 @@
1
- class RenameAutomaticExploitationIndex < ActiveRecord::Migration
1
+ class RenameAutomaticExploitationIndex < ActiveRecord::Migration[4.2]
2
2
  def up
3
- if index_name_exists? :automatic_exploitation_matches, :index_automatic_exploitation_matches_on_ref_id, false
3
+ if index_name_exists? :automatic_exploitation_matches, :index_automatic_exploitation_matches_on_ref_id
4
4
  rename_index :automatic_exploitation_matches,
5
5
  :index_automatic_exploitation_matches_on_ref_id,
6
6
  :index_automatic_exploitation_matches_on_module_detail_id
7
7
  end
8
8
  end
9
9
  def down
10
- if index_name_exists? :automatic_exploitation_matches, :index_automatic_exploitation_matches_on_module_detail_id, false
10
+ if index_name_exists? :automatic_exploitation_matches, :index_automatic_exploitation_matches_on_module_detail_id
11
11
  rename_index :automatic_exploitation_matches,
12
12
  :index_automatic_exploitation_matches_on_module_detail_id,
13
13
  :index_automatic_exploitation_matches_on_ref_id
@@ -1,4 +1,4 @@
1
- class AddOriginToMdmVuln < ActiveRecord::Migration
1
+ class AddOriginToMdmVuln < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  add_column :vulns, :origin_id, :integer
4
4
  add_column :vulns, :origin_type, :string
@@ -1,4 +1,4 @@
1
- class RemoveNotNullFromWebVulnPArams < ActiveRecord::Migration
1
+ class RemoveNotNullFromWebVulnPArams < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  change_column_null(:web_vulns, :params, true)
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddFingerprintedToWorkspace < ActiveRecord::Migration
1
+ class AddFingerprintedToWorkspace < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :workspaces, :import_fingerprint, :boolean, default: false
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddOsFamilyToHosts < ActiveRecord::Migration
1
+ class AddOsFamilyToHosts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :hosts, :os_family, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreatePayloads < ActiveRecord::Migration
1
+ class CreatePayloads < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :payloads do |t|
4
4
  t.string :name
@@ -0,0 +1,14 @@
1
+ class CreateAsyncCallbacks < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :async_callbacks do |t|
4
+ t.string :uuid, :null => false
5
+ t.integer :timestamp, :null => false
6
+ t.string :listener_uri
7
+ t.string :target_host
8
+ t.string :target_port
9
+
10
+ t.timestamps null: false
11
+ t.uuid null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class RemovePayloadWorkspaces < ActiveRecord::Migration[4.2]
2
+ def change
3
+ remove_column :payloads, :workspace_id, :references
4
+ end
5
+ end
data/lib/mdm.rb CHANGED
@@ -3,6 +3,7 @@ module Mdm
3
3
  extend ActiveSupport::Autoload
4
4
 
5
5
  autoload :ApiKey
6
+ autoload :AsyncCallback
6
7
  autoload :Client
7
8
  autoload :Cred
8
9
  autoload :Event
@@ -18,7 +18,6 @@ require 'active_support/all'
18
18
  require 'metasploit/concern'
19
19
  require 'metasploit/model'
20
20
  require 'arel-helpers'
21
- require 'postgres_ext'
22
21
 
23
22
  #
24
23
  # Project
@@ -16,7 +16,7 @@ module MetasploitDataModels::AutomaticExploitation
16
16
  # Module Methods
17
17
  #
18
18
 
19
- # The prefix of the `ActiveRecord::Base#table_name` of subclasses in this namespace.
19
+ # The prefix of the `ApplicationRecord#table_name` of subclasses in this namespace.
20
20
  #
21
21
  # @return [String]
22
22
  def self.table_name_prefix
@@ -1,5 +1,5 @@
1
1
  # Provides ActiveRecord 3.1x-friendly serialization for descendants of
2
- # ActiveRecord::Base. Backwards compatible with older YAML methods and
2
+ # ApplicationRecord. Backwards compatible with older YAML methods and
3
3
  # will fall back to string decoding in the worst case
4
4
  #
5
5
  # @example Using default default of {}
@@ -2,7 +2,7 @@
2
2
  # `:null => true`, to `:null => false`.
3
3
  #
4
4
  # @abstract Subclass and define COLUMNS as Array<Symbol> and TABLE_NAME as Symbol.
5
- class MetasploitDataModels::ChangeRequiredColumnsToNullFalse < ActiveRecord::Migration
5
+ class MetasploitDataModels::ChangeRequiredColumnsToNullFalse < ActiveRecord::Migration[4.2]
6
6
  # Marks all the COLUMNS as `:null => true`
7
7
  def down
8
8
  # Use self.class:: so constants are resolved in subclasses instead of this class.
@@ -18,4 +18,4 @@ class MetasploitDataModels::ChangeRequiredColumnsToNullFalse < ActiveRecord::Mig
18
18
  change_column_null(self.class::TABLE_NAME, column, false)
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -1,6 +1,6 @@
1
1
  require 'rails'
2
2
 
3
- # `Rails::Engine` that exposes MetasploitDataModel's `ActiveRecord::Base` subclasses and automatically loads its
3
+ # `Rails::Engine` that exposes MetasploitDataModel's `ApplicationRecord` subclasses and automatically loads its
4
4
  # `FactoryBot` factories, sequences, and traits.
5
5
  class MetasploitDataModels::Engine < Rails::Engine
6
6
  # @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '3.0.8'
3
+ VERSION = '4.0.2'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.files = `git ls-files`.split("\n")
25
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
26
  s.require_paths = %w{app/models app/validators lib}
28
27
 
29
28
  s.required_ruby_version = '>= 2.1'
@@ -32,7 +31,7 @@ Gem::Specification.new do |s|
32
31
  # documentation
33
32
  s.add_development_dependency 'metasploit-yard'
34
33
  s.add_development_dependency 'yard-activerecord'
35
- # embed ERDs on index, namespace Module and Class<ActiveRecord::Base> pages
34
+ # embed ERDs on index, namespace Module and Class<ApplicationRecord> pages
36
35
  s.add_development_dependency 'yard-metasploit-erd'
37
36
 
38
37
  s.add_development_dependency 'rake'
@@ -44,11 +43,11 @@ Gem::Specification.new do |s|
44
43
  s.add_development_dependency 'pry'
45
44
 
46
45
 
47
- s.add_runtime_dependency 'activerecord', '~>4.2.6'
48
- s.add_runtime_dependency 'activesupport', '~>4.2.6'
46
+ s.add_runtime_dependency 'activerecord', '~>5.2.2'
47
+ s.add_runtime_dependency 'activesupport', '~>5.2.2'
49
48
  s.add_runtime_dependency 'metasploit-concern'
50
49
  s.add_runtime_dependency 'metasploit-model'
51
- s.add_runtime_dependency 'railties', '~>4.2.6'
50
+ s.add_runtime_dependency 'railties', '~>5.2.2'
52
51
 
53
52
  # os fingerprinting
54
53
  s.add_runtime_dependency 'recog', '~> 2.0'
@@ -56,9 +55,6 @@ Gem::Specification.new do |s|
56
55
  # arel-helpers: Useful tools to help construct database queries with ActiveRecord and Arel.
57
56
  s.add_runtime_dependency 'arel-helpers'
58
57
 
59
- # Fixes a problem with arel not being able to visit IPAddr nodes
60
- s.add_runtime_dependency 'postgres_ext'
61
-
62
58
  if RUBY_PLATFORM =~ /java/
63
59
  # markdown formatting for yard
64
60
  s.add_development_dependency 'kramdown'
@@ -45,14 +45,14 @@ RSpec.describe Mdm::ExploitAttempt, type: :model do
45
45
  orphaned_attempt = FactoryBot.build(:mdm_exploit_attempt, :host => nil)
46
46
  expect(orphaned_attempt).not_to be_valid
47
47
  expect(orphaned_attempt.errors[:host_id]).to include("can't be blank")
48
- propper_attempt = FactoryBot.build(:mdm_exploit_attempt)
48
+ propper_attempt = FactoryBot.create(:mdm_exploit_attempt)
49
49
  expect(propper_attempt).to be_valid
50
50
  end
51
51
  end
52
52
 
53
53
  context 'factory' do
54
54
  it 'should be valid' do
55
- exploit_attempt = FactoryBot.build(:mdm_exploit_attempt)
55
+ exploit_attempt = FactoryBot.create(:mdm_exploit_attempt)
56
56
  expect(exploit_attempt).to be_valid
57
57
  end
58
58
  end
@@ -28,7 +28,7 @@ RSpec.describe Mdm::HostDetail, type: :model do
28
28
 
29
29
  context 'factory' do
30
30
  it 'should be valid' do
31
- host_detail = FactoryBot.build(:mdm_host_detail)
31
+ host_detail = FactoryBot.create(:mdm_host_detail)
32
32
  expect(host_detail).to be_valid
33
33
  end
34
34
  end
@@ -471,33 +471,33 @@ RSpec.describe Mdm::Host, type: :model do
471
471
 
472
472
  context 'os normalization' do
473
473
  context '#get_arch_from_string' do
474
- context "should return 'x64'" do
474
+ context "should return 'x86_64'" do
475
475
  it "when the string contains 'x64'" do
476
- expect(host.send(:get_arch_from_string, 'blahx64blah')).to eq('x64')
476
+ expect(host.send(:get_arch_from_string, 'blahx64blah')).to eq('x86_64')
477
477
  end
478
478
 
479
479
  it "when the string contains 'X64'" do
480
- expect(host.send(:get_arch_from_string, 'blahX64blah')).to eq('x64')
480
+ expect(host.send(:get_arch_from_string, 'blahX64blah')).to eq('x86_64')
481
481
  end
482
482
 
483
483
  it "when the string contains 'x86_64'" do
484
- expect(host.send(:get_arch_from_string, 'blahx86_64blah')).to eq('x64')
484
+ expect(host.send(:get_arch_from_string, 'blahx86_64blah')).to eq('x86_64')
485
485
  end
486
486
 
487
487
  it "when the string contains 'X86_64'" do
488
- expect(host.send(:get_arch_from_string, 'blahX86_64blah')).to eq('x64')
488
+ expect(host.send(:get_arch_from_string, 'blahX86_64blah')).to eq('x86_64')
489
489
  end
490
490
 
491
491
  it "when the string contains 'amd64'" do
492
- expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
492
+ expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x86_64')
493
493
  end
494
494
 
495
495
  it "when the string contains 'AMD64'" do
496
- expect(host.send(:get_arch_from_string, 'blahAMD64blah')).to eq('x64')
496
+ expect(host.send(:get_arch_from_string, 'blahAMD64blah')).to eq('x86_64')
497
497
  end
498
498
 
499
499
  it "when the string contains 'aMd64'" do
500
- expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
500
+ expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x86_64')
501
501
  end
502
502
  end
503
503
 
@@ -531,21 +531,21 @@ RSpec.describe Mdm::Host, type: :model do
531
531
  end
532
532
  end
533
533
 
534
- context "should return 'ppc'" do
534
+ context "should return 'PowerPC'" do
535
535
  it "when the string contains 'PowerPC'" do
536
- expect(host.send(:get_arch_from_string, 'blahPowerPCblah')).to eq('ppc')
536
+ expect(host.send(:get_arch_from_string, 'blahPowerPCblah')).to eq('PowerPC')
537
537
  end
538
538
 
539
539
  it "when the string contains 'PPC'" do
540
- expect(host.send(:get_arch_from_string, 'blahPPCblah')).to eq('ppc')
540
+ expect(host.send(:get_arch_from_string, 'blahPPCblah')).to eq('PowerPC')
541
541
  end
542
542
 
543
543
  it "when the string contains 'POWER'" do
544
- expect(host.send(:get_arch_from_string, 'blahPOWERblah')).to eq('ppc')
544
+ expect(host.send(:get_arch_from_string, 'blahPOWERblah')).to eq('PowerPC')
545
545
  end
546
546
 
547
547
  it "when the string contains 'ppc'" do
548
- expect(host.send(:get_arch_from_string, 'blahppcblah')).to eq('ppc')
548
+ expect(host.send(:get_arch_from_string, 'blahppcblah')).to eq('PowerPC')
549
549
  end
550
550
  end
551
551
 
@@ -560,22 +560,22 @@ RSpec.describe Mdm::Host, type: :model do
560
560
  end
561
561
  end
562
562
 
563
- it "should return 'sparc' if the string contains SPARC, regardless of case" do
564
- expect(host.send(:get_arch_from_string, 'blahSPARCblah')).to eq('sparc')
565
- expect(host.send(:get_arch_from_string, 'blahSPaRCblah')).to eq('sparc')
566
- expect(host.send(:get_arch_from_string, 'blahsparcblah')).to eq('sparc')
563
+ it "should return 'Sparc' if the string contains SPARC, regardless of case" do
564
+ expect(host.send(:get_arch_from_string, 'blahSPARCblah')).to eq('Sparc')
565
+ expect(host.send(:get_arch_from_string, 'blahSPaRCblah')).to eq('Sparc')
566
+ expect(host.send(:get_arch_from_string, 'blahsparcblah')).to eq('Sparc')
567
567
  end
568
568
 
569
- it "should return 'arm' if the string contains 'ARM', regardless of case" do
570
- expect(host.send(:get_arch_from_string, 'blahARMblah')).to eq('arm')
571
- expect(host.send(:get_arch_from_string, 'blahArMblah')).to eq('arm')
572
- expect(host.send(:get_arch_from_string, 'blaharmblah')).to eq('arm')
569
+ it "should return 'ARM' if the string contains 'ARM', regardless of case" do
570
+ expect(host.send(:get_arch_from_string, 'blahARMblah')).to eq('ARM')
571
+ expect(host.send(:get_arch_from_string, 'blahArMblah')).to eq('ARM')
572
+ expect(host.send(:get_arch_from_string, 'blaharmblah')).to eq('ARM')
573
573
  end
574
574
 
575
- it "should return 'mips' if the string contains 'MIPS', regardless of case" do
576
- expect(host.send(:get_arch_from_string, 'blahMIPSblah')).to eq('mips')
577
- expect(host.send(:get_arch_from_string, 'blahMiPslah')).to eq('mips')
578
- expect(host.send(:get_arch_from_string, 'blahmipsblah')).to eq('mips')
575
+ it "should return 'MIPS' if the string contains 'MIPS', regardless of case" do
576
+ expect(host.send(:get_arch_from_string, 'blahMIPSblah')).to eq('MIPS')
577
+ expect(host.send(:get_arch_from_string, 'blahMiPslah')).to eq('MIPS')
578
+ expect(host.send(:get_arch_from_string, 'blahmipsblah')).to eq('MIPS')
579
579
  end
580
580
  end
581
581
 
@@ -588,7 +588,7 @@ RSpec.describe Mdm::Host, type: :model do
588
588
  context 'arch' do
589
589
  it 'should return a value for arch if there is one' do
590
590
  result = host.send(:parse_windows_os_str, 'Windows x64')
591
- expect(result['os.arch']).to eq('x64')
591
+ expect(result['os.arch']).to eq('x86_64')
592
592
  end
593
593
 
594
594
  it "should not have an arch key if we don't know the arch" do
@@ -1093,7 +1093,7 @@ RSpec.describe Mdm::Host, type: :model do
1093
1093
  fingerprint = FactoryBot.build(:mdm_retina_fingerprint, :host => host)
1094
1094
  result = host.send(:normalize_scanner_fp, fingerprint).first
1095
1095
  expect(result['os.product']).to eq( 'Windows Server 2003')
1096
- expect(result['os.arch']).to eq('x64')
1096
+ expect(result['os.arch']).to eq('x86_64')
1097
1097
  expect(result['os.version']).to eq('SP2')
1098
1098
  expect(result['os.certainty'].to_f).to eq(0.8)
1099
1099
  end
@@ -328,10 +328,10 @@ RSpec.describe Mdm::Module::Detail, type: :model do
328
328
 
329
329
  context '#module_arch' do
330
330
  it 'finds all modules with a stance matching "java"' do
331
- expect(Mdm::Module::Detail.module_arch(['%java%']).uniq).to contain_exactly(@cve_2012_0507)
331
+ expect(Mdm::Module::Detail.module_arch(['%java%']).distinct).to contain_exactly(@cve_2012_0507)
332
332
  end
333
333
  it 'finds all modules with a stance matching "pass"' do
334
- expect(Mdm::Module::Detail.module_arch(['%java%', '%php%']).uniq).to contain_exactly(@cve_2012_0507, @cve_2010_0425)
334
+ expect(Mdm::Module::Detail.module_arch(['%java%', '%php%']).distinct).to contain_exactly(@cve_2012_0507, @cve_2010_0425)
335
335
  end
336
336
  end
337
337
 
@@ -364,68 +364,68 @@ RSpec.describe Mdm::Module::Detail, type: :model do
364
364
 
365
365
  context '#module_os_or_platform' do
366
366
  it 'finds all modules with a platform matching "linux"' do
367
- expect(Mdm::Module::Detail.module_os_or_platform(['%linux%']).uniq).to contain_exactly(@cve_2012_0507)
367
+ expect(Mdm::Module::Detail.module_os_or_platform(['%linux%']).distinct).to contain_exactly(@cve_2012_0507)
368
368
  end
369
369
 
370
370
  it 'finds all modules with a platform matching "windows"' do
371
- expect(Mdm::Module::Detail.module_os_or_platform(['%windows%']).uniq).to contain_exactly(
371
+ expect(Mdm::Module::Detail.module_os_or_platform(['%windows%']).distinct).to contain_exactly(
372
372
  @ms12_020,@ms08_067,@ms06_040,@cve_2012_0507)
373
373
  end
374
374
  end
375
375
 
376
376
  context 'module_ref' do
377
377
  it 'finds all modules with a reff matching "CVE-2012"' do
378
- expect(Mdm::Module::Detail.module_ref(['%CVE-2012%']).uniq).to contain_exactly(
378
+ expect(Mdm::Module::Detail.module_ref(['%CVE-2012%']).distinct).to contain_exactly(
379
379
  @ms12_020,@cve_2012_0507)
380
380
  end
381
381
  it 'finds all modules with a reff matching "EDB"' do
382
- expect(Mdm::Module::Detail.module_ref(['%EDB%']).uniq).to contain_exactly(@ms12_020)
382
+ expect(Mdm::Module::Detail.module_ref(['%EDB%']).distinct).to contain_exactly(@ms12_020)
383
383
  end
384
384
  end
385
385
 
386
386
  context '#module_stance' do
387
387
  it 'finds all modules with a stance matching "agg"' do
388
- expect(Mdm::Module::Detail.module_stance(['%agg%']).uniq).to contain_exactly(
388
+ expect(Mdm::Module::Detail.module_stance(['%agg%']).distinct).to contain_exactly(
389
389
  @ms12_020,@ms08_067,@ms06_040,@cve_2010_0425)
390
390
  end
391
391
  it 'finds all modules with a stance matching "pass"' do
392
- expect(Mdm::Module::Detail.module_stance(['%pass%']).uniq).to contain_exactly(@cve_2012_0507)
392
+ expect(Mdm::Module::Detail.module_stance(['%pass%']).distinct).to contain_exactly(@cve_2012_0507)
393
393
  end
394
394
  end
395
395
 
396
396
  context '#module_text' do
397
397
  it 'finds all modules with a description matching "ConnectMCSPDU"' do
398
- expect(Mdm::Module::Detail.module_text(['%ConnectMCSPDU%']).uniq).to contain_exactly(@ms12_020)
398
+ expect(Mdm::Module::Detail.module_text(['%ConnectMCSPDU%']).distinct).to contain_exactly(@ms12_020)
399
399
  end
400
400
  it 'finds all modules with a fullname matching "smb/ms0"' do
401
- expect(Mdm::Module::Detail.module_text(['%smb/ms0%']).uniq).to contain_exactly(@ms08_067,@ms06_040)
401
+ expect(Mdm::Module::Detail.module_text(['%smb/ms0%']).distinct).to contain_exactly(@ms08_067,@ms06_040)
402
402
  end
403
403
  it 'finds all modules with a name matching "Microsoft Server Service"' do
404
- expect(Mdm::Module::Detail.module_text(['%Microsoft Server Service%']).uniq).to contain_exactly(@ms08_067,@ms06_040)
404
+ expect(Mdm::Module::Detail.module_text(['%Microsoft Server Service%']).distinct).to contain_exactly(@ms08_067,@ms06_040)
405
405
  end
406
406
  it 'finds all modules with a arch matching "php"' do
407
- expect(Mdm::Module::Detail.module_text(['%php%']).uniq).to contain_exactly(@cve_2010_0425)
407
+ expect(Mdm::Module::Detail.module_text(['%php%']).distinct).to contain_exactly(@cve_2010_0425)
408
408
  end
409
409
  it 'finds all modules with a author matching "jduck"' do
410
- expect(Mdm::Module::Detail.module_text(['%jduck%']).uniq).to contain_exactly(@ms12_020,@ms08_067)
410
+ expect(Mdm::Module::Detail.module_text(['%jduck%']).distinct).to contain_exactly(@ms12_020,@ms08_067)
411
411
  end
412
412
  it 'finds all modules with a platform matching "linux"' do
413
- expect(Mdm::Module::Detail.module_text(['%linux%']).uniq).to contain_exactly(@cve_2012_0507)
413
+ expect(Mdm::Module::Detail.module_text(['%linux%']).distinct).to contain_exactly(@cve_2012_0507)
414
414
  end
415
415
  it 'finds all modules with a ref matching "MSB-MS"' do
416
- expect(Mdm::Module::Detail.module_text(['%MSB-MS%']).uniq).to contain_exactly(@ms12_020,@ms08_067,@ms06_040)
416
+ expect(Mdm::Module::Detail.module_text(['%MSB-MS%']).distinct).to contain_exactly(@ms12_020,@ms08_067,@ms06_040)
417
417
  end
418
418
  it 'finds all modules with a target matching "Auto"' do
419
- expect(Mdm::Module::Detail.module_text(['%Auto%']).uniq).to contain_exactly(@ms08_067,@ms06_040,@cve_2010_0425)
419
+ expect(Mdm::Module::Detail.module_text(['%Auto%']).distinct).to contain_exactly(@ms08_067,@ms06_040,@cve_2010_0425)
420
420
  end
421
421
  end
422
422
 
423
423
  context 'module_type' do
424
424
  it 'finds all modules with a mtype matching "aux"' do
425
- expect(Mdm::Module::Detail.module_type(['%aux%']).uniq).to contain_exactly(@ms12_020)
425
+ expect(Mdm::Module::Detail.module_type(['%aux%']).distinct).to contain_exactly(@ms12_020)
426
426
  end
427
427
  it 'finds all modules with a mtype matching "exp"' do
428
- expect(Mdm::Module::Detail.module_type(['%exp%']).uniq).to contain_exactly(
428
+ expect(Mdm::Module::Detail.module_type(['%exp%']).distinct).to contain_exactly(
429
429
  @ms08_067,@ms06_040,@cve_2012_0507,@cve_2010_0425)
430
430
  end
431
431
  end
@@ -82,6 +82,7 @@ RSpec.describe Mdm::Service, type: :model do
82
82
 
83
83
  it 'should include recog data when there is a match' do
84
84
  host = FactoryBot.create(:mdm_host)
85
+ host.name = 'example.com'
85
86
  FactoryBot.create(
86
87
  :mdm_service,
87
88
  :host => host,
@@ -33,7 +33,7 @@ RSpec.describe Mdm::VulnAttempt, type: :model do
33
33
 
34
34
  context 'factory' do
35
35
  it 'should be valid' do
36
- vuln_attempt = FactoryBot.build(:mdm_vuln_attempt)
36
+ vuln_attempt = FactoryBot.create(:mdm_vuln_attempt)
37
37
  expect(vuln_attempt).to be_valid
38
38
  end
39
39
  end