metasploit_data_models 0.24.0 → 0.24.1.pre.rspec.pre.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -3
  3. data/Gemfile +1 -3
  4. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  5. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  6. data/app/validators/password_is_strong_validator.rb +1 -1
  7. data/lib/mdm/host/operating_system_normalization.rb +0 -10
  8. data/lib/metasploit_data_models/version.rb +2 -2
  9. data/metasploit_data_models.gemspec +1 -1
  10. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  11. data/spec/app/models/mdm/client_spec.rb +9 -11
  12. data/spec/app/models/mdm/cred_spec.rb +42 -54
  13. data/spec/app/models/mdm/event_spec.rb +21 -23
  14. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  15. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  16. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  17. data/spec/app/models/mdm/host_spec.rb +261 -260
  18. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  19. data/spec/app/models/mdm/listener_spec.rb +30 -32
  20. data/spec/app/models/mdm/loot_spec.rb +21 -23
  21. data/spec/app/models/mdm/macro_spec.rb +1 -3
  22. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  23. data/spec/app/models/mdm/module/action_spec.rb +10 -12
  24. data/spec/app/models/mdm/module/arch_spec.rb +10 -12
  25. data/spec/app/models/mdm/module/author_spec.rb +22 -17
  26. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  27. data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
  28. data/spec/app/models/mdm/module/platform_spec.rb +10 -12
  29. data/spec/app/models/mdm/module/ref_spec.rb +10 -12
  30. data/spec/app/models/mdm/module/target_spec.rb +13 -15
  31. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  32. data/spec/app/models/mdm/note_spec.rb +23 -25
  33. data/spec/app/models/mdm/profile_spec.rb +1 -3
  34. data/spec/app/models/mdm/ref_spec.rb +10 -12
  35. data/spec/app/models/mdm/route_spec.rb +6 -8
  36. data/spec/app/models/mdm/service_spec.rb +38 -40
  37. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  38. data/spec/app/models/mdm/session_spec.rb +13 -15
  39. data/spec/app/models/mdm/tag_spec.rb +29 -29
  40. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  41. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  42. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  43. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  44. data/spec/app/models/mdm/task_spec.rb +27 -29
  45. data/spec/app/models/mdm/user_spec.rb +17 -19
  46. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  47. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  48. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  49. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  50. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  51. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  52. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  53. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  54. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  55. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  56. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  57. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  58. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  59. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  60. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  61. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  62. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  63. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  64. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  65. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  66. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  67. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  68. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  69. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  70. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  71. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  72. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  73. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  74. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  75. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  76. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  77. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  78. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  79. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  80. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  81. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  82. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  83. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  84. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  85. data/spec/dummy/db/structure.sql +1 -0
  86. data/spec/lib/base64_serializer_spec.rb +19 -19
  87. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  88. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  89. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  90. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  91. data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
  92. data/spec/spec_helper.rb +72 -6
  93. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  94. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  95. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  96. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  97. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  98. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  99. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  100. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 697a5985907797cb0b1f5fd889d58589b4fe98b2
4
- data.tar.gz: 0572ecb56f59c51be7cfed129576031de086dd8a
3
+ metadata.gz: 9575cbf901167b12a5b4241d3e30bef7388a66c4
4
+ data.tar.gz: c478549cfaeb0b0172ffd8dd2fffd786a82c82cc
5
5
  SHA512:
6
- metadata.gz: ca63f729423fd054ff525b52ee8b6b2786405e15e4a77ede724d26544089ffe22238865918a9e75a6240ac2fcda174b5a66192607fad404cbb0a7fe720943b15
7
- data.tar.gz: aa08a8f0ed97860cb5aee467c90816891c5dd282dcfda3ab9ef166f6767afec54ab4cc68d4a83531bfeedb37dd04eb2632534bae1fe9a9fd07457099ca327d43
6
+ metadata.gz: eded8aa0e65dad8d9a6fa8d60cb34e572f3551312f8756a500d9990a919dd0e5c7af58738a66bd42115c95777b25db9b667451b38db3958ab984ff15569ae5ac
7
+ data.tar.gz: 32c790f07c256a251dd94ec34d2a614dc9f0741ae16c3d51febdfd88a4bf2d9050102380fcd0d9303e08f19ebd64f4b5dea770c3a0c61ad83f9c544f5b0a6873
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format nested
2
- --colour
3
- --drb
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile CHANGED
@@ -32,11 +32,9 @@ group :test do
32
32
  gem 'shoulda-matchers'
33
33
  # code coverage of tests
34
34
  gem 'simplecov', :require => false
35
- # @todo Update specs for rspec 3.0.0 compatibility and remove this gem in favor of just rspec-rails
36
- gem 'rspec-core', '< 3.0.0'
37
35
  # need rspec-rails >= 2.12.0 as 2.12.0 adds support for redefining named subject in nested context that uses the
38
36
  # named subject from the outer context without causing a stack overflow.
39
- gem 'rspec-rails', '>= 2.12.0'
37
+ gem 'rspec-rails', '~> 3.2'
40
38
  # used for building markup for webpage factories
41
39
  gem 'builder'
42
40
  end
@@ -67,7 +67,7 @@ class MetasploitDataModels::IPAddress::V4::Segmented < Metasploit::Model::Base
67
67
  #
68
68
  # @return [Regexp]
69
69
  def self.regexp
70
- unless @regexp
70
+ unless instance_variable_defined? :@regexp
71
71
  separated_segment_count = SEGMENT_COUNT - 1
72
72
 
73
73
  @regexp = %r{
@@ -32,7 +32,7 @@ class MetasploitDataModels::Search::Visitor::Where
32
32
  }
33
33
  end
34
34
 
35
- visit *EQUALITY_OPERATION_CLASS_NAMES do |operation|
35
+ visit(*EQUALITY_OPERATION_CLASS_NAMES) do |operation|
36
36
  attribute = attribute_visitor.visit operation.operator
37
37
 
38
38
  attribute.eq(operation.value)
@@ -34,7 +34,7 @@ class PasswordIsStrongValidator < ActiveModel::EachValidator
34
34
  end
35
35
 
36
36
  def contains_username?(username, password)
37
- password =~ /#{username}/i
37
+ !!(password =~ /#{username}/i)
38
38
  end
39
39
 
40
40
  def is_common_password?(password)
@@ -185,15 +185,6 @@ module Mdm::Host::OperatingSystemNormalization
185
185
  # Merge and normalize the best match to the host object
186
186
  apply_match_to_host(match) if match
187
187
 
188
- # Handle cases where the flavor contains the base name (legacy parsing, etc)
189
- # TODO: Remove this once we are sure it is no longer needed
190
- if host.os_name && host.os_flavor && host.os_flavor.index(host.os_name)
191
- dlog("Host #{host.address} has os_flavor that contains os_name")
192
- dlog("os_flavor: #{host.os_flavor}")
193
- dlog("os_name: #{host.os_name}")
194
- host.os_flavor = host.os_flavor.gsub(host.os_name, '').strip
195
- end
196
-
197
188
  # Set some sane defaults if needed
198
189
  host.os_name ||= 'Unknown'
199
190
  host.purpose ||= 'device'
@@ -302,7 +293,6 @@ module Mdm::Host::OperatingSystemNormalization
302
293
  # name collision seems silly.
303
294
  return false
304
295
  else
305
- dlog("Could not validate fingerprint data: #{fp.inspect}")
306
296
  return false
307
297
  end
308
298
  end
@@ -6,9 +6,9 @@ module MetasploitDataModels
6
6
  # The minor version number, scoped to the {MAJOR} version number.
7
7
  MINOR = 24
8
8
  # The patch number, scoped to the {MAJOR} and {MINOR} version numbers.
9
- PATCH = 0
9
+ PATCH = 1
10
10
  # The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
11
- # PRERELEASE =
11
+ PRERELEASE = 'rspec-3-1'
12
12
 
13
13
  # The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
14
14
  # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
45
45
  s.add_runtime_dependency 'recog', '~> 1.0'
46
46
 
47
47
  s.add_runtime_dependency 'metasploit-concern', '0.4.0'
48
- s.add_runtime_dependency 'metasploit-model', '~> 0.29.0'
48
+ s.add_runtime_dependency 'metasploit-model', '~> 0.30.1'
49
49
  s.add_runtime_dependency 'railties', '< 4.0.0'
50
50
 
51
51
  # arel-helpers: Useful tools to help construct database queries with ActiveRecord and Arel.
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::ApiKey do
1
+ RSpec.describe Mdm::ApiKey, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
  end
@@ -1,11 +1,9 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Client do
1
+ RSpec.describe Mdm::Client, type: :model do
4
2
 
5
3
  it_should_behave_like 'Metasploit::Concern.run'
6
4
 
7
5
  context 'associations' do
8
- it { should belong_to(:host).class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
9
7
  end
10
8
 
11
9
  context '#destroy' do
@@ -23,21 +21,21 @@ describe Mdm::Client do
23
21
  context 'factory' do
24
22
  it 'should be valid' do
25
23
  client = FactoryGirl.build(:mdm_client)
26
- client.should be_valid
24
+ expect(client).to be_valid
27
25
  end
28
26
  end
29
27
 
30
28
  context 'database' do
31
29
  context 'columns' do
32
- it { should have_db_column(:host_id).of_type(:integer)}
33
- it { should have_db_column(:ua_string).of_type(:string).with_options(:null => false) }
34
- it { should have_db_column(:ua_name).of_type(:string) }
35
- it { should have_db_column(:ua_ver).of_type(:string) }
30
+ it { is_expected.to have_db_column(:host_id).of_type(:integer)}
31
+ it { is_expected.to have_db_column(:ua_string).of_type(:string).with_options(:null => false) }
32
+ it { is_expected.to have_db_column(:ua_name).of_type(:string) }
33
+ it { is_expected.to have_db_column(:ua_ver).of_type(:string) }
36
34
  end
37
35
 
38
36
  context 'timestamps' do
39
- it { should have_db_column(:created_at).of_type(:datetime) }
40
- it { should have_db_column(:updated_at).of_type(:datetime) }
37
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
38
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
41
39
  end
42
40
 
43
41
  end
@@ -1,29 +1,27 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Cred do
1
+ RSpec.describe Mdm::Cred, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context "Associations" do
7
- it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
8
- it { should have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
9
- it { should belong_to(:service).class_name('Mdm::Service') }
5
+ it { is_expected.to have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
6
+ it { is_expected.to have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
7
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
10
8
  end
11
9
 
12
10
  context 'database' do
13
11
  context 'timestamps' do
14
- it { should have_db_column(:created_at).of_type(:datetime) }
15
- it { should have_db_column(:updated_at).of_type(:datetime) }
12
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
13
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
20
- it { should have_db_column(:user).of_type(:string) }
21
- it { should have_db_column(:pass).of_type(:string) }
22
- it { should have_db_column(:active).of_type(:boolean).with_options(:default => true) }
23
- it { should have_db_column(:proof).of_type(:string) }
24
- it { should have_db_column(:ptype).of_type(:string) }
25
- it { should have_db_column(:source_id).of_type(:integer) }
26
- it { should have_db_column(:source_type).of_type(:string) }
17
+ it { is_expected.to have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
18
+ it { is_expected.to have_db_column(:user).of_type(:string) }
19
+ it { is_expected.to have_db_column(:pass).of_type(:string) }
20
+ it { is_expected.to have_db_column(:active).of_type(:boolean).with_options(:default => true) }
21
+ it { is_expected.to have_db_column(:proof).of_type(:string) }
22
+ it { is_expected.to have_db_column(:ptype).of_type(:string) }
23
+ it { is_expected.to have_db_column(:source_id).of_type(:integer) }
24
+ it { is_expected.to have_db_column(:source_type).of_type(:string) }
27
25
  end
28
26
  end
29
27
 
@@ -68,25 +66,23 @@ describe Mdm::Cred do
68
66
 
69
67
  context 'constants' do
70
68
  it 'should define the key_id regex' do
71
- described_class::KEY_ID_REGEX.should == /([0-9a-fA-F:]{47})/
69
+ expect(described_class::KEY_ID_REGEX).to eq(/([0-9a-fA-F:]{47})/)
72
70
  end
73
71
 
74
72
  it 'should define ptypes to humanize' do
75
- described_class::PTYPES.should == {
76
- 'read/write password' => 'password_rw',
77
- 'read-only password' => 'password_ro',
78
- 'SMB hash' => 'smb_hash',
79
- 'SSH private key' => 'ssh_key',
80
- 'SSH public key' => 'ssh_pubkey'
81
- }
73
+ expect(described_class::PTYPES).to eq(
74
+ {
75
+ 'read/write password' => 'password_rw',
76
+ 'read-only password' => 'password_ro',
77
+ 'SMB hash' => 'smb_hash',
78
+ 'SSH private key' => 'ssh_key',
79
+ 'SSH public key' => 'ssh_pubkey'
80
+ }
81
+ )
82
82
  end
83
83
  end
84
84
 
85
85
  context 'methods' do
86
- #
87
- # lets
88
- #
89
-
90
86
  let(:host) {
91
87
  FactoryGirl.create(
92
88
  :mdm_host,
@@ -134,55 +130,47 @@ describe Mdm::Cred do
134
130
  FactoryGirl.create(:mdm_workspace)
135
131
  }
136
132
 
137
- #
138
- # Callbacks
139
- #
140
-
141
- before(:all) do
142
- Mdm::Workspace.any_instance.stub(:valid_ip_or_range? => true)
143
- end
144
-
145
133
  context '#ptype_human' do
146
134
  it "should return 'read/write password' for 'password_rw'" do
147
135
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
148
- cred.ptype_human.should == 'read/write password'
136
+ expect(cred.ptype_human).to eq('read/write password')
149
137
  end
150
138
 
151
139
  it "should return 'read-only password' for 'password_ro'" do
152
140
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_ro')
153
- cred.ptype_human.should == 'read-only password'
141
+ expect(cred.ptype_human).to eq('read-only password')
154
142
  end
155
143
 
156
144
  it "should return 'SMB Hash' for 'smb_hash'" do
157
145
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'smb_hash')
158
- cred.ptype_human.should == 'SMB hash'
146
+ expect(cred.ptype_human).to eq('SMB hash')
159
147
  end
160
148
 
161
149
  it "should return 'SSH private key' for 'ssh_key'" do
162
150
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_key')
163
- cred.ptype_human.should == 'SSH private key'
151
+ expect(cred.ptype_human).to eq('SSH private key')
164
152
  end
165
153
 
166
154
  it "should return 'SSH public key' for 'ssh_pubkey'" do
167
155
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_pubkey')
168
- cred.ptype_human.should == 'SSH public key'
156
+ expect(cred.ptype_human).to eq('SSH public key')
169
157
  end
170
158
  end
171
159
 
172
160
  context '#ssh_key_id' do
173
161
  it 'should return nil if not an ssh_key' do
174
162
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
175
- cred.ssh_key_id.should == nil
163
+ expect(cred.ssh_key_id).to eq(nil)
176
164
  end
177
165
 
178
166
  it 'should return nil if proof does not contain the key id' do
179
167
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "no key here")
180
- cred.ssh_key_id.should == nil
168
+ expect(cred.ssh_key_id).to eq(nil)
181
169
  end
182
170
 
183
171
  it 'should return the key id for an ssh_key' do
184
172
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
185
- cred.ssh_key_id.should == '57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a'
173
+ expect(cred.ssh_key_id).to eq('57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a')
186
174
  end
187
175
 
188
176
  end
@@ -234,14 +222,14 @@ describe Mdm::Cred do
234
222
  it 'should behave the same for public keys as private keys' do
235
223
  pubkey2 = FactoryGirl.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
236
224
  pubkey3 = FactoryGirl.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=66:d4:22:6e:88:d6:74:A1:44:3e:d6:d5:AA:89:73:8b")
237
- pubkey2.ssh_key_matches?(ssh_pubkey).should == true
238
- pubkey2.ssh_key_matches?(pubkey3).should == false
225
+ expect(pubkey2.ssh_key_matches?(ssh_pubkey)).to eq(true)
226
+ expect(pubkey2.ssh_key_matches?(pubkey3)).to eq(false)
239
227
  end
240
228
 
241
229
  it 'should always return false for non ssh key creds' do
242
230
  cred2 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
243
231
  cred3 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
244
- cred2.ssh_key_matches?(cred3).should == false
232
+ expect(cred2.ssh_key_matches?(cred3)).to eq(false)
245
233
  end
246
234
  end
247
235
 
@@ -271,11 +259,11 @@ describe Mdm::Cred do
271
259
  end
272
260
 
273
261
  it 'should return all ssh private keys with a matching id' do
274
- other_ssh_key.ssh_keys.should include(ssh_key)
262
+ expect(other_ssh_key.ssh_keys).to include(ssh_key)
275
263
  end
276
264
 
277
265
  it 'should return all ssh public keys with a matching id' do
278
- other_ssh_key.ssh_keys.should include(ssh_pubkey)
266
+ expect(other_ssh_key.ssh_keys).to include(ssh_pubkey)
279
267
  end
280
268
  end
281
269
 
@@ -305,11 +293,11 @@ describe Mdm::Cred do
305
293
  end
306
294
 
307
295
  it 'should return ssh private keys with matching ids' do
308
- other_ssh_key.ssh_private_keys.should include(ssh_key)
296
+ expect(other_ssh_key.ssh_private_keys).to include(ssh_key)
309
297
  end
310
298
 
311
299
  it 'should not return ssh public keys with matching ids' do
312
- other_ssh_key.ssh_private_keys.should_not include(ssh_pubkey)
300
+ expect(other_ssh_key.ssh_private_keys).not_to include(ssh_pubkey)
313
301
  end
314
302
  end
315
303
 
@@ -339,11 +327,11 @@ describe Mdm::Cred do
339
327
  end
340
328
 
341
329
  it 'should not return ssh private keys with matching ids' do
342
- other_ssh_key.ssh_public_keys.should_not include(ssh_key)
330
+ expect(other_ssh_key.ssh_public_keys).not_to include(ssh_key)
343
331
  end
344
332
 
345
333
  it 'should return ssh public keys with matching ids' do
346
- other_ssh_key.ssh_public_keys.should include(ssh_pubkey)
334
+ expect(other_ssh_key.ssh_public_keys).to include(ssh_pubkey)
347
335
  end
348
336
  end
349
337
  end
@@ -351,7 +339,7 @@ describe Mdm::Cred do
351
339
  context 'factory' do
352
340
  it 'should be valid' do
353
341
  cred = FactoryGirl.build(:mdm_cred)
354
- cred.should be_valid
342
+ expect(cred).to be_valid
355
343
  end
356
344
  end
357
345
 
@@ -1,27 +1,25 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Event do
1
+ RSpec.describe Mdm::Event, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:host).class_name('Mdm::Host') }
8
- it { should belong_to(:workspace).class_name('Mdm::Workspace') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'timestamps' do
13
- it { should have_db_column(:created_at).of_type(:datetime) }
14
- it { should have_db_column(:updated_at).of_type(:datetime) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
15
13
  end
16
14
 
17
15
  context 'columns' do
18
- it { should have_db_column(:workspace_id).of_type(:integer) }
19
- it { should have_db_column(:host_id).of_type(:integer) }
20
- it { should have_db_column(:name).of_type(:string) }
21
- it { should have_db_column(:critical).of_type(:boolean) }
22
- it { should have_db_column(:seen).of_type(:boolean) }
23
- it { should have_db_column(:username).of_type(:string) }
24
- it { should have_db_column(:info).of_type(:text) }
16
+ it { is_expected.to have_db_column(:workspace_id).of_type(:integer) }
17
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
18
+ it { is_expected.to have_db_column(:name).of_type(:string) }
19
+ it { is_expected.to have_db_column(:critical).of_type(:boolean) }
20
+ it { is_expected.to have_db_column(:seen).of_type(:boolean) }
21
+ it { is_expected.to have_db_column(:username).of_type(:string) }
22
+ it { is_expected.to have_db_column(:info).of_type(:text) }
25
23
  end
26
24
  end
27
25
 
@@ -44,16 +42,16 @@ describe Mdm::Event do
44
42
  flagged_event = FactoryGirl.create(:mdm_event, :name => 'flagme', :critical => true, :seen => false)
45
43
  non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro', :critical => false, :seen => false)
46
44
  flagged_set = Mdm::Event.flagged
47
- flagged_set.should include(flagged_event)
48
- flagged_set.should_not include(non_critical_event)
45
+ expect(flagged_set).to include(flagged_event)
46
+ expect(flagged_set).not_to include(non_critical_event)
49
47
  end
50
48
 
51
49
  it 'should exclude seen events' do
52
50
  flagged_event = FactoryGirl.create(:mdm_event, :name => 'flagme', :critical => true, :seen => false)
53
51
  non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro', :critical => false, :seen => true)
54
52
  flagged_set = Mdm::Event.flagged
55
- flagged_set.should include(flagged_event)
56
- flagged_set.should_not include(non_critical_event)
53
+ expect(flagged_set).to include(flagged_event)
54
+ expect(flagged_set).not_to include(non_critical_event)
57
55
  end
58
56
  end
59
57
 
@@ -62,8 +60,8 @@ describe Mdm::Event do
62
60
  flagged_event = FactoryGirl.create(:mdm_event, :name => 'module_run')
63
61
  non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro')
64
62
  flagged_set = Mdm::Event.module_run
65
- flagged_set.should include(flagged_event)
66
- flagged_set.should_not include(non_critical_event)
63
+ expect(flagged_set).to include(flagged_event)
64
+ expect(flagged_set).not_to include(non_critical_event)
67
65
  end
68
66
  end
69
67
  end
@@ -71,15 +69,15 @@ describe Mdm::Event do
71
69
  context 'validations' do
72
70
  it 'should require name' do
73
71
  unnamed_event = FactoryGirl.build(:mdm_event, :name => nil)
74
- unnamed_event.should_not be_valid
75
- unnamed_event.errors[:name].should include("can't be blank")
72
+ expect(unnamed_event).not_to be_valid
73
+ expect(unnamed_event.errors[:name]).to include("can't be blank")
76
74
  end
77
75
  end
78
76
 
79
77
  context 'factory' do
80
78
  it 'should be valid' do
81
79
  event = FactoryGirl.build(:mdm_event)
82
- event.should be_valid
80
+ expect(event).to be_valid
83
81
  end
84
82
  end
85
83