metasploit_data_models 1.0.0.pre.rails.pre.4.0b → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/.travis.yml +6 -3
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +10 -52
  6. data/Gemfile +4 -6
  7. data/RELEASING.md +88 -0
  8. data/Rakefile +23 -0
  9. data/UPGRADING.md +1 -0
  10. data/app/models/mdm/api_key.rb +41 -1
  11. data/app/models/mdm/client.rb +41 -1
  12. data/app/models/mdm/cred.rb +116 -28
  13. data/app/models/mdm/event.rb +47 -0
  14. data/app/models/mdm/exploit_attempt.rb +65 -16
  15. data/app/models/mdm/exploited_host.rb +27 -0
  16. data/app/models/mdm/host_detail.rb +44 -0
  17. data/app/models/mdm/host_tag.rb +6 -8
  18. data/app/models/mdm/listener.rb +52 -0
  19. data/app/models/mdm/macro.rb +42 -0
  20. data/app/models/mdm/mod_ref.rb +21 -1
  21. data/app/models/mdm/module/action.rb +15 -0
  22. data/app/models/mdm/module/arch.rb +10 -0
  23. data/app/models/mdm/module/author.rb +17 -1
  24. data/app/models/mdm/module/mixin.rb +13 -0
  25. data/app/models/mdm/module/platform.rb +11 -0
  26. data/app/models/mdm/module/target.rb +18 -0
  27. data/app/models/mdm/nexpose_console.rb +82 -4
  28. data/app/models/mdm/profile.rb +36 -0
  29. data/app/models/mdm/route.rb +16 -4
  30. data/app/models/mdm/session_event.rb +32 -0
  31. data/app/models/mdm/tag.rb +48 -9
  32. data/app/models/mdm/task.rb +85 -46
  33. data/app/models/mdm/task_cred.rb +29 -0
  34. data/app/models/mdm/task_host.rb +25 -0
  35. data/app/models/mdm/task_service.rb +25 -0
  36. data/app/models/mdm/task_session.rb +25 -0
  37. data/app/models/mdm/user.rb +192 -6
  38. data/app/models/mdm/vuln_attempt.rb +37 -12
  39. data/app/models/mdm/vuln_detail.rb +138 -5
  40. data/app/models/mdm/vuln_ref.rb +3 -0
  41. data/app/models/mdm/web_form.rb +34 -0
  42. data/app/models/mdm/web_page.rb +69 -0
  43. data/app/models/mdm/web_site.rb +50 -0
  44. data/app/models/mdm/wmap_request.rb +85 -0
  45. data/app/models/mdm/wmap_target.rb +40 -0
  46. data/app/models/mdm/workspace.rb +160 -17
  47. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +13 -23
  48. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +25 -4
  49. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +15 -4
  50. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +7 -3
  51. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  52. data/app/models/metasploit_data_models/module_run.rb +1 -1
  53. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  54. data/app/validators/ip_format_validator.rb +4 -0
  55. data/app/validators/parameters_validator.rb +12 -0
  56. data/app/validators/password_is_strong_validator.rb +10 -1
  57. data/lib/mdm/host/operating_system_normalization.rb +7 -10
  58. data/lib/metasploit_data_models.rb +4 -0
  59. data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
  60. data/lib/metasploit_data_models/engine.rb +2 -0
  61. data/lib/metasploit_data_models/serialized_prefs.rb +6 -0
  62. data/lib/metasploit_data_models/version.rb +30 -7
  63. data/metasploit_data_models.gemspec +9 -2
  64. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  65. data/spec/app/models/mdm/client_spec.rb +9 -11
  66. data/spec/app/models/mdm/cred_spec.rb +42 -54
  67. data/spec/app/models/mdm/event_spec.rb +22 -24
  68. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  69. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  70. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  71. data/spec/app/models/mdm/host_spec.rb +262 -260
  72. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  73. data/spec/app/models/mdm/listener_spec.rb +30 -32
  74. data/spec/app/models/mdm/loot_spec.rb +21 -23
  75. data/spec/app/models/mdm/macro_spec.rb +1 -3
  76. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  77. data/spec/app/models/mdm/module/action_spec.rb +8 -10
  78. data/spec/app/models/mdm/module/arch_spec.rb +8 -10
  79. data/spec/app/models/mdm/module/author_spec.rb +19 -14
  80. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  81. data/spec/app/models/mdm/module/mixin_spec.rb +8 -10
  82. data/spec/app/models/mdm/module/platform_spec.rb +8 -10
  83. data/spec/app/models/mdm/module/ref_spec.rb +8 -10
  84. data/spec/app/models/mdm/module/target_spec.rb +10 -12
  85. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  86. data/spec/app/models/mdm/note_spec.rb +23 -25
  87. data/spec/app/models/mdm/profile_spec.rb +1 -3
  88. data/spec/app/models/mdm/ref_spec.rb +9 -12
  89. data/spec/app/models/mdm/route_spec.rb +6 -8
  90. data/spec/app/models/mdm/service_spec.rb +38 -40
  91. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  92. data/spec/app/models/mdm/session_spec.rb +13 -15
  93. data/spec/app/models/mdm/tag_spec.rb +29 -30
  94. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  95. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  96. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  97. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  98. data/spec/app/models/mdm/task_spec.rb +27 -29
  99. data/spec/app/models/mdm/user_spec.rb +17 -19
  100. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  101. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  102. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  103. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  104. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  105. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  106. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  107. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  108. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  109. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  110. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  111. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  112. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  113. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  114. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  115. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  116. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  117. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  118. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  119. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  120. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  121. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  122. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  123. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  124. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  125. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  126. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  127. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  128. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  129. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  130. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  131. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  132. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  133. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  134. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  135. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  136. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  137. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  138. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  139. data/spec/lib/base64_serializer_spec.rb +19 -21
  140. data/spec/lib/ipaddr_spec.rb +1 -3
  141. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  142. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  143. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  144. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  145. data/spec/lib/metasploit_data_models/version_spec.rb +3 -139
  146. data/spec/lib/metasploit_data_models_spec.rb +4 -0
  147. data/spec/spec_helper.rb +86 -12
  148. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  149. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  150. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  151. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  152. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  153. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  154. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  155. metadata +74 -14
  156. data/app/models/metasploit_data_models/automatic_exploitation.rb +0 -16
  157. data/lib/tasks/yard.rake +0 -33
@@ -1,16 +1,14 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Route do
1
+ RSpec.describe Mdm::Route, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:session).class_name('Mdm::Session') }
5
+ it { is_expected.to belong_to(:session).class_name('Mdm::Session') }
8
6
  end
9
7
 
10
8
  context 'factory' do
11
9
  it 'should be valid' do
12
10
  route = FactoryGirl.build(:mdm_route)
13
- route.should be_valid
11
+ expect(route).to be_valid
14
12
  end
15
13
  end
16
14
 
@@ -28,9 +26,9 @@ describe Mdm::Route do
28
26
 
29
27
  context 'database' do
30
28
  context 'columns' do
31
- it { should have_db_column(:session_id).of_type(:integer) }
32
- it { should have_db_column(:subnet).of_type(:string) }
33
- it { should have_db_column(:netmask).of_type(:string) }
29
+ it { is_expected.to have_db_column(:session_id).of_type(:integer) }
30
+ it { is_expected.to have_db_column(:subnet).of_type(:string) }
31
+ it { is_expected.to have_db_column(:netmask).of_type(:string) }
34
32
  end
35
33
  end
36
34
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Service do
1
+ RSpec.describe Mdm::Service, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'CONSTANTS' do
@@ -9,8 +7,8 @@ describe Mdm::Service do
9
7
  described_class::PROTOS
10
8
  }
11
9
 
12
- it { should include 'tcp' }
13
- it { should include 'udp' }
10
+ it { is_expected.to include 'tcp' }
11
+ it { is_expected.to include 'udp' }
14
12
  end
15
13
 
16
14
  context 'STATES' do
@@ -18,40 +16,40 @@ describe Mdm::Service do
18
16
  described_class::STATES
19
17
  }
20
18
 
21
- it { should include 'closed' }
22
- it { should include 'filtered' }
23
- it { should include 'open' }
24
- it { should include 'unknown' }
19
+ it { is_expected.to include 'closed' }
20
+ it { is_expected.to include 'filtered' }
21
+ it { is_expected.to include 'open' }
22
+ it { is_expected.to include 'unknown' }
25
23
  end
26
24
  end
27
25
 
28
26
  context "Associations" do
29
27
 
30
- it { should have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
31
- it { should have_many(:tasks).class_name('Mdm::Task').through(:task_services) }
32
- it { should have_many(:creds).class_name('Mdm::Cred').dependent(:destroy) }
33
- it { should have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').dependent(:destroy) }
34
- it { should have_many(:notes).class_name('Mdm::Note').dependent(:destroy) }
35
- it { should have_many(:vulns).class_name('Mdm::Vuln').dependent(:destroy) }
36
- it { should have_many(:web_sites).class_name('Mdm::WebSite').dependent(:destroy) }
37
- it { should have_many(:web_pages).class_name('Mdm::WebPage').through(:web_sites) }
38
- it { should have_many(:web_forms).class_name('Mdm::WebForm').through(:web_sites) }
39
- it { should have_many(:web_vulns).class_name('Mdm::WebVuln').through(:web_sites) }
40
- it { should belong_to(:host).class_name('Mdm::Host') }
28
+ it { is_expected.to have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
29
+ it { is_expected.to have_many(:tasks).class_name('Mdm::Task').through(:task_services) }
30
+ it { is_expected.to have_many(:creds).class_name('Mdm::Cred').dependent(:destroy) }
31
+ it { is_expected.to have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').dependent(:destroy) }
32
+ it { is_expected.to have_many(:notes).class_name('Mdm::Note').dependent(:destroy) }
33
+ it { is_expected.to have_many(:vulns).class_name('Mdm::Vuln').dependent(:destroy) }
34
+ it { is_expected.to have_many(:web_sites).class_name('Mdm::WebSite').dependent(:destroy) }
35
+ it { is_expected.to have_many(:web_pages).class_name('Mdm::WebPage').through(:web_sites) }
36
+ it { is_expected.to have_many(:web_forms).class_name('Mdm::WebForm').through(:web_sites) }
37
+ it { is_expected.to have_many(:web_vulns).class_name('Mdm::WebVuln').through(:web_sites) }
38
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
41
39
  end
42
40
 
43
41
  context 'scopes' do
44
42
  context "inactive" do
45
43
  it "should exclude open services" do
46
44
  open_service = FactoryGirl.create(:mdm_service, :state => 'open')
47
- Mdm::Service.inactive.should_not include(open_service)
45
+ expect(Mdm::Service.inactive).not_to include(open_service)
48
46
  end
49
47
  end
50
48
 
51
49
  context "with_state open" do
52
50
  it "should exclude closed services" do
53
51
  closed_service = FactoryGirl.create(:mdm_service, :state => 'closed')
54
- Mdm::Service.with_state('open').should_not include(closed_service)
52
+ expect(Mdm::Service.with_state('open')).not_to include(closed_service)
55
53
  end
56
54
  end
57
55
 
@@ -60,8 +58,8 @@ describe Mdm::Service do
60
58
  tcp_service = FactoryGirl.create(:mdm_service, proto: 'tcp')
61
59
  udp_service = FactoryGirl.create(:mdm_service, proto: 'udp')
62
60
  search_results = Mdm::Service.search('tcp')
63
- search_results.should include(tcp_service)
64
- search_results.should_not include(udp_service)
61
+ expect(search_results).to include(tcp_service)
62
+ expect(search_results).not_to include(udp_service)
65
63
  end
66
64
  end
67
65
  end
@@ -70,7 +68,7 @@ describe Mdm::Service do
70
68
  context 'after_save' do
71
69
  it 'should call #normalize_host_os' do
72
70
  svc = FactoryGirl.create(:mdm_service)
73
- svc.should_receive(:normalize_host_os)
71
+ expect(svc).to receive(:normalize_host_os)
74
72
  svc.run_callbacks(:save)
75
73
  end
76
74
  end
@@ -79,7 +77,7 @@ describe Mdm::Service do
79
77
  context 'factory' do
80
78
  it 'should be valid' do
81
79
  service = FactoryGirl.build(:mdm_service)
82
- service.should be_valid
80
+ expect(service).to be_valid
83
81
  end
84
82
  end
85
83
 
@@ -98,24 +96,24 @@ describe Mdm::Service do
98
96
  context 'database' do
99
97
 
100
98
  context 'timestamps'do
101
- it { should have_db_column(:created_at).of_type(:datetime) }
102
- it { should have_db_column(:updated_at).of_type(:datetime) }
99
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
100
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
103
101
  end
104
102
 
105
103
  context 'columns' do
106
- it { should have_db_column(:host_id).of_type(:integer) }
107
- it { should have_db_column(:port).of_type(:integer).with_options(:null => false) }
108
- it { should have_db_column(:proto).of_type(:string).with_options(:null => false) }
109
- it { should have_db_column(:state).of_type(:string) }
110
- it { should have_db_column(:name).of_type(:string) }
111
- it { should have_db_column(:info).of_type(:text) }
104
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
105
+ it { is_expected.to have_db_column(:port).of_type(:integer).with_options(:null => false) }
106
+ it { is_expected.to have_db_column(:proto).of_type(:string).with_options(:null => false) }
107
+ it { is_expected.to have_db_column(:state).of_type(:string) }
108
+ it { is_expected.to have_db_column(:name).of_type(:string) }
109
+ it { is_expected.to have_db_column(:info).of_type(:text) }
112
110
  end
113
111
 
114
112
  context 'indices' do
115
- it { should have_db_index(:name) }
116
- it { should have_db_index(:port) }
117
- it { should have_db_index(:proto) }
118
- it { should have_db_index(:state) }
113
+ it { is_expected.to have_db_index(:name) }
114
+ it { is_expected.to have_db_index(:port) }
115
+ it { is_expected.to have_db_index(:proto) }
116
+ it { is_expected.to have_db_index(:state) }
119
117
  end
120
118
  end
121
119
 
@@ -151,8 +149,8 @@ describe Mdm::Service do
151
149
  FactoryGirl.build(:mdm_service)
152
150
  }
153
151
 
154
- it { should validate_numericality_of(:port).only_integer }
155
- it { should validate_inclusion_of(:proto).in_array(described_class::PROTOS) }
152
+ it { is_expected.to validate_numericality_of(:port).only_integer }
153
+ it { is_expected.to validate_inclusion_of(:proto).in_array(described_class::PROTOS) }
156
154
 
157
155
  context 'when a duplicate service already exists' do
158
156
  let(:service1) { FactoryGirl.create(:mdm_service)}
@@ -1,16 +1,14 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::SessionEvent do
1
+ RSpec.describe Mdm::SessionEvent, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:session).class_name('Mdm::Session') }
5
+ it { is_expected.to belong_to(:session).class_name('Mdm::Session') }
8
6
  end
9
7
 
10
8
  context 'factory' do
11
9
  it 'should be valid' do
12
10
  session_event = FactoryGirl.build(:mdm_session_event)
13
- session_event.should be_valid
11
+ expect(session_event).to be_valid
14
12
  end
15
13
  end
16
14
 
@@ -28,16 +26,16 @@ describe Mdm::SessionEvent do
28
26
 
29
27
  context 'database' do
30
28
  context 'timestamps'do
31
- it { should have_db_column(:created_at).of_type(:datetime) }
29
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
32
30
  end
33
31
 
34
32
  context 'columns' do
35
- it { should have_db_column(:session_id).of_type(:integer) }
36
- it { should have_db_column(:etype).of_type(:string) }
37
- it { should have_db_column(:command).of_type(:binary) }
38
- it { should have_db_column(:output).of_type(:binary) }
39
- it { should have_db_column(:remote_path).of_type(:string) }
40
- it { should have_db_column(:local_path).of_type(:string) }
33
+ it { is_expected.to have_db_column(:session_id).of_type(:integer) }
34
+ it { is_expected.to have_db_column(:etype).of_type(:string) }
35
+ it { is_expected.to have_db_column(:command).of_type(:binary) }
36
+ it { is_expected.to have_db_column(:output).of_type(:binary) }
37
+ it { is_expected.to have_db_column(:remote_path).of_type(:string) }
38
+ it { is_expected.to have_db_column(:local_path).of_type(:string) }
41
39
  end
42
40
  end
43
41
 
@@ -1,12 +1,10 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Session do
1
+ RSpec.describe Mdm::Session, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'factory' do
7
5
  it 'should be valid' do
8
6
  session = FactoryGirl.build(:mdm_session)
9
- session.should be_valid
7
+ expect(session).to be_valid
10
8
  end
11
9
  end
12
10
 
@@ -61,8 +59,8 @@ describe Mdm::Session do
61
59
  alive_session = FactoryGirl.create(:mdm_session)
62
60
  dead_session = FactoryGirl.create(:mdm_session, :closed_at => Time.now)
63
61
  alive_set = Mdm::Session.alive
64
- alive_set.should include(alive_session)
65
- alive_set.should_not include(dead_session)
62
+ expect(alive_set).to include(alive_session)
63
+ expect(alive_set).not_to include(dead_session)
66
64
  end
67
65
  end
68
66
 
@@ -71,8 +69,8 @@ describe Mdm::Session do
71
69
  alive_session = FactoryGirl.create(:mdm_session)
72
70
  dead_session = FactoryGirl.create(:mdm_session, :closed_at => Time.now)
73
71
  dead_set = Mdm::Session.dead
74
- dead_set.should_not include(alive_session)
75
- dead_set.should include(dead_session)
72
+ expect(dead_set).not_to include(alive_session)
73
+ expect(dead_set).to include(dead_session)
76
74
  end
77
75
  end
78
76
 
@@ -82,9 +80,9 @@ describe Mdm::Session do
82
80
  linux_shell = FactoryGirl.create(:mdm_session, :stype => 'shell', :platform => 'Linux')
83
81
  win_meterp = FactoryGirl.create(:mdm_session, :stype => 'meterpreter', :platform => 'Windows')
84
82
  upgrade_set = Mdm::Session.upgradeable
85
- upgrade_set.should include(win_shell)
86
- upgrade_set.should_not include(linux_shell)
87
- upgrade_set.should_not include(win_meterp)
83
+ expect(upgrade_set).to include(win_shell)
84
+ expect(upgrade_set).not_to include(linux_shell)
85
+ expect(upgrade_set).not_to include(win_meterp)
88
86
  end
89
87
  end
90
88
  end
@@ -93,7 +91,7 @@ describe Mdm::Session do
93
91
  context 'before_destroy' do
94
92
  it 'should call #stop' do
95
93
  mysession = FactoryGirl.create(:mdm_session)
96
- mysession.should_receive(:stop)
94
+ expect(mysession).to receive(:stop)
97
95
  mysession.destroy
98
96
  end
99
97
  end
@@ -103,17 +101,17 @@ describe Mdm::Session do
103
101
  context '#upgradeable?' do
104
102
  it 'should return true for windows shells' do
105
103
  win_shell = FactoryGirl.create(:mdm_session, :stype => 'shell', :platform => 'Windows')
106
- win_shell.upgradeable?.should == true
104
+ expect(win_shell.upgradeable?).to eq(true)
107
105
  end
108
106
 
109
107
  it 'should return false for non-windows shells' do
110
108
  linux_shell = FactoryGirl.create(:mdm_session, :stype => 'shell', :platform => 'Linux')
111
- linux_shell.upgradeable?.should == false
109
+ expect(linux_shell.upgradeable?).to eq(false)
112
110
  end
113
111
 
114
112
  it 'should return false for Windows Meterpreter Sessions' do
115
113
  win_meterp = FactoryGirl.create(:mdm_session, :stype => 'meterpreter', :platform => 'Windows')
116
- win_meterp.upgradeable?.should == false
114
+ expect(win_meterp.upgradeable?).to eq(false)
117
115
  end
118
116
  end
119
117
  end
@@ -1,29 +1,28 @@
1
- require 'spec_helper'
2
1
  require 'securerandom'
3
2
 
4
- describe Mdm::Tag do
3
+ RSpec.describe Mdm::Tag, type: :model do
5
4
  it_should_behave_like 'Metasploit::Concern.run'
6
5
 
7
6
  context 'associations' do
8
- it { should have_many(:hosts_tags).class_name('Mdm::HostTag') }
9
- it { should have_many(:hosts).class_name('Mdm::Host').through(:hosts_tags) }
10
- it { should belong_to(:user).class_name('Mdm::User') }
7
+ it { is_expected.to have_many(:hosts_tags).class_name('Mdm::HostTag') }
8
+ it { is_expected.to have_many(:hosts).class_name('Mdm::Host').through(:hosts_tags) }
9
+ it { is_expected.to belong_to(:user).class_name('Mdm::User') }
11
10
  end
12
11
 
13
12
  context 'database' do
14
13
 
15
14
  context 'timestamps'do
16
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
17
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
15
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
16
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
18
17
  end
19
18
 
20
19
  context 'columns' do
21
- it { should have_db_column(:user_id).of_type(:integer) }
22
- it { should have_db_column(:name).of_type(:string) }
23
- it { should have_db_column(:desc).of_type(:text) }
24
- it { should have_db_column(:report_summary).of_type(:boolean).with_options(:null => false, :default =>false) }
25
- it { should have_db_column(:report_detail).of_type(:boolean).with_options(:null => false, :default =>false) }
26
- it { should have_db_column(:critical).of_type(:boolean).with_options(:null => false, :default =>false) }
20
+ it { is_expected.to have_db_column(:user_id).of_type(:integer) }
21
+ it { is_expected.to have_db_column(:name).of_type(:string) }
22
+ it { is_expected.to have_db_column(:desc).of_type(:text) }
23
+ it { is_expected.to have_db_column(:report_summary).of_type(:boolean).with_options(:null => false, :default =>false) }
24
+ it { is_expected.to have_db_column(:report_detail).of_type(:boolean).with_options(:null => false, :default =>false) }
25
+ it { is_expected.to have_db_column(:critical).of_type(:boolean).with_options(:null => false, :default =>false) }
27
26
  end
28
27
  end
29
28
 
@@ -32,37 +31,37 @@ describe Mdm::Tag do
32
31
  it 'should not ba valid for a length over 8k' do
33
32
  desc = SecureRandom.hex(9001) #over 9000?!
34
33
  large_tag = FactoryGirl.build(:mdm_tag, :desc => desc)
35
- large_tag.should_not be_valid
36
- large_tag.errors[:desc].should include('desc must be less than 8k.')
34
+ expect(large_tag).not_to be_valid
35
+ expect(large_tag.errors[:desc]).to include('desc must be less than 8k.')
37
36
  end
38
37
  end
39
38
 
40
39
  context 'name' do
41
40
  it 'must be present' do
42
41
  nameless_tag = FactoryGirl.build(:mdm_tag, :name => nil)
43
- nameless_tag.should_not be_valid
44
- nameless_tag.errors[:name].should include("can't be blank")
42
+ expect(nameless_tag).not_to be_valid
43
+ expect(nameless_tag.errors[:name]).to include("can't be blank")
45
44
  end
46
45
 
47
46
  it 'may only contain alphanumerics, dot, dashes, and underscores' do
48
47
  mytag = FactoryGirl.build(:mdm_tag, :name => 'A.1-B_2')
49
- mytag.should be_valid
48
+ expect(mytag).to be_valid
50
49
  #Test for various bad inputs we should never allow
51
50
  mytag = FactoryGirl.build(:mdm_tag, :name => "A'1")
52
- mytag.should_not be_valid
53
- mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
51
+ expect(mytag).not_to be_valid
52
+ expect(mytag.errors[:name]).to include('must be alphanumeric, dots, dashes, or underscores')
54
53
  mytag = FactoryGirl.build(:mdm_tag, :name => "A;1")
55
- mytag.should_not be_valid
56
- mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
54
+ expect(mytag).not_to be_valid
55
+ expect(mytag.errors[:name]).to include('must be alphanumeric, dots, dashes, or underscores')
57
56
  mytag = FactoryGirl.build(:mdm_tag, :name => "A%1")
58
- mytag.should_not be_valid
59
- mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
57
+ expect(mytag).not_to be_valid
58
+ expect(mytag.errors[:name]).to include('must be alphanumeric, dots, dashes, or underscores')
60
59
  mytag = FactoryGirl.build(:mdm_tag, :name => "A=1")
61
- mytag.should_not be_valid
62
- mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
60
+ expect(mytag).not_to be_valid
61
+ expect(mytag.errors[:name]).to include('must be alphanumeric, dots, dashes, or underscores')
63
62
  mytag = FactoryGirl.build(:mdm_tag, :name => "#A1")
64
- mytag.should_not be_valid
65
- mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
63
+ expect(mytag).not_to be_valid
64
+ expect(mytag.errors[:name]).to include('must be alphanumeric, dots, dashes, or underscores')
66
65
  end
67
66
  end
68
67
  end
@@ -71,7 +70,7 @@ describe Mdm::Tag do
71
70
  context '#to_s' do
72
71
  it 'should return the name of the tag as a string' do
73
72
  mytag = FactoryGirl.build(:mdm_tag, :name => 'mytag')
74
- mytag.to_s.should == 'mytag'
73
+ expect(mytag.to_s).to eq('mytag')
75
74
  end
76
75
  end
77
76
  end
@@ -82,7 +81,7 @@ describe Mdm::Tag do
82
81
  FactoryGirl.build(:mdm_tag)
83
82
  end
84
83
 
85
- it { should be_valid }
84
+ it { is_expected.to be_valid }
86
85
  end
87
86
  end
88
87
 
@@ -1,25 +1,23 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::TaskCred do
1
+ RSpec.describe Mdm::TaskCred, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'factory' do
7
5
  it 'should be valid' do
8
6
  task_cred = FactoryGirl.build(:mdm_task_cred)
9
- task_cred.should be_valid
7
+ expect(task_cred).to be_valid
10
8
  end
11
9
  end
12
10
 
13
11
  context 'database' do
14
12
 
15
13
  context 'timestamps'do
16
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
17
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
14
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
15
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
18
16
  end
19
17
 
20
18
  context 'columns' do
21
- it { should have_db_column(:task_id).of_type(:integer).with_options(:null => false) }
22
- it { should have_db_column(:cred_id).of_type(:integer).with_options(:null => false) }
19
+ it { is_expected.to have_db_column(:task_id).of_type(:integer).with_options(:null => false) }
20
+ it { is_expected.to have_db_column(:cred_id).of_type(:integer).with_options(:null => false) }
23
21
  end
24
22
  end
25
23
 
@@ -36,8 +34,8 @@ describe Mdm::TaskCred do
36
34
  end
37
35
 
38
36
  context "Associations" do
39
- it { should belong_to(:task).class_name('Mdm::Task') }
40
- it { should belong_to(:cred).class_name('Mdm::Cred') }
37
+ it { is_expected.to belong_to(:task).class_name('Mdm::Task') }
38
+ it { is_expected.to belong_to(:cred).class_name('Mdm::Cred') }
41
39
  end
42
40
 
43
41
  context "validations" do
@@ -46,7 +44,7 @@ describe Mdm::TaskCred do
46
44
  cred = FactoryGirl.build(:mdm_cred)
47
45
  FactoryGirl.create(:mdm_task_cred, :task => task, :cred => cred)
48
46
  task_cred2 = FactoryGirl.build(:mdm_task_cred, :task => task, :cred => cred)
49
- task_cred2.should_not be_valid
47
+ expect(task_cred2).not_to be_valid
50
48
  end
51
49
  end
52
50