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,17 +1,15 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::HostTag do
1
+ RSpec.describe Mdm::HostTag, 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(:tag).class_name('Mdm::Tag') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:tag).class_name('Mdm::Tag') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'columns' do
13
- it { should have_db_column(:host_id).of_type(:integer) }
14
- it { should have_db_column(:tag_id).of_type(:integer) }
11
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
12
+ it { is_expected.to have_db_column(:tag_id).of_type(:integer) }
15
13
  end
16
14
  end
17
15
 
@@ -21,7 +19,7 @@ describe Mdm::HostTag do
21
19
  FactoryGirl.build(:mdm_host_tag)
22
20
  end
23
21
 
24
- it { should be_valid }
22
+ it { is_expected.to be_valid }
25
23
  end
26
24
  end
27
25
 
@@ -1,37 +1,35 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Listener do
1
+ RSpec.describe Mdm::Listener, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:workspace).class_name('Mdm::Workspace') }
8
- it { should belong_to(:task).class_name('Mdm::Task') }
5
+ it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
6
+ it { is_expected.to belong_to(:task).class_name('Mdm::Task') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
 
13
11
  context 'timestamps'do
14
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
15
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
13
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
20
- it { should have_db_column(:task_id).of_type(:integer) }
21
- it { should have_db_column(:enabled).of_type(:boolean).with_options(:default => true) }
22
- it { should have_db_column(:owner).of_type(:text) }
23
- it { should have_db_column(:payload).of_type(:text) }
24
- it { should have_db_column(:address).of_type(:text) }
25
- it { should have_db_column(:port).of_type(:integer) }
26
- it { should have_db_column(:options).of_type(:binary) }
27
- it { should have_db_column(:macro).of_type(:text) }
17
+ it { is_expected.to have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
18
+ it { is_expected.to have_db_column(:task_id).of_type(:integer) }
19
+ it { is_expected.to have_db_column(:enabled).of_type(:boolean).with_options(:default => true) }
20
+ it { is_expected.to have_db_column(:owner).of_type(:text) }
21
+ it { is_expected.to have_db_column(:payload).of_type(:text) }
22
+ it { is_expected.to have_db_column(:address).of_type(:text) }
23
+ it { is_expected.to have_db_column(:port).of_type(:integer) }
24
+ it { is_expected.to have_db_column(:options).of_type(:binary) }
25
+ it { is_expected.to have_db_column(:macro).of_type(:text) }
28
26
  end
29
27
  end
30
28
 
31
29
  context 'factory' do
32
30
  it 'should be valid' do
33
31
  listener = FactoryGirl.build(:mdm_listener)
34
- listener.should be_valid
32
+ expect(listener).to be_valid
35
33
  end
36
34
  end
37
35
 
@@ -51,55 +49,55 @@ describe Mdm::Listener do
51
49
  context 'port' do
52
50
  it 'should require a port' do
53
51
  portless_listener = FactoryGirl.build(:mdm_listener, :port => nil)
54
- portless_listener.should_not be_valid
55
- portless_listener.errors[:port].should include("can't be blank")
52
+ expect(portless_listener).not_to be_valid
53
+ expect(portless_listener.errors[:port]).to include("can't be blank")
56
54
  end
57
55
 
58
56
  it 'should not be valid for out-of-range numbers' do
59
57
  out_of_range = FactoryGirl.build(:mdm_listener, :port => 70000)
60
- out_of_range.should_not be_valid
61
- out_of_range.errors[:port].should include("is not included in the list")
58
+ expect(out_of_range).not_to be_valid
59
+ expect(out_of_range.errors[:port]).to include("is not included in the list")
62
60
  end
63
61
 
64
62
  it 'should not be valid for port 0' do
65
63
  out_of_range = FactoryGirl.build(:mdm_listener, :port => 0)
66
- out_of_range.should_not be_valid
67
- out_of_range.errors[:port].should include("is not included in the list")
64
+ expect(out_of_range).not_to be_valid
65
+ expect(out_of_range.errors[:port]).to include("is not included in the list")
68
66
  end
69
67
 
70
68
  it 'should not be valid for decimal numbers' do
71
69
  out_of_range = FactoryGirl.build(:mdm_listener, :port => 5.67)
72
- out_of_range.should_not be_valid
73
- out_of_range.errors[:port].should include("must be an integer")
70
+ expect(out_of_range).not_to be_valid
71
+ expect(out_of_range.errors[:port]).to include("must be an integer")
74
72
  end
75
73
 
76
74
  it 'should not be valid for a negative number' do
77
75
  out_of_range = FactoryGirl.build(:mdm_listener, :port => -8)
78
- out_of_range.should_not be_valid
79
- out_of_range.errors[:port].should include("is not included in the list")
76
+ expect(out_of_range).not_to be_valid
77
+ expect(out_of_range.errors[:port]).to include("is not included in the list")
80
78
  end
81
79
  end
82
80
 
83
81
  context 'address' do
84
82
  it 'should require an address' do
85
83
  addressless_listener = FactoryGirl.build(:mdm_listener, :address => nil)
86
- addressless_listener.should_not be_valid
87
- addressless_listener.errors[:address].should include("can't be blank")
84
+ expect(addressless_listener).not_to be_valid
85
+ expect(addressless_listener.errors[:address]).to include("can't be blank")
88
86
  end
89
87
 
90
88
  it 'should be valid for IPv4 format' do
91
89
  ipv4_listener = FactoryGirl.build(:mdm_listener, :address => '192.168.1.120')
92
- ipv4_listener.should be_valid
90
+ expect(ipv4_listener).to be_valid
93
91
  end
94
92
 
95
93
  it 'should be valid for IPv6 format' do
96
94
  ipv6_listener = FactoryGirl.build(:mdm_listener, :address => '2001:0db8:85a3:0000:0000:8a2e:0370:7334')
97
- ipv6_listener.should be_valid
95
+ expect(ipv6_listener).to be_valid
98
96
  end
99
97
 
100
98
  it 'should not be valid for strings not conforming to IPv4 or IPv6' do
101
99
  invalid_listener = FactoryGirl.build(:mdm_listener, :address => '1234-fark')
102
- invalid_listener.should_not be_valid
100
+ expect(invalid_listener).not_to be_valid
103
101
  end
104
102
 
105
103
  end
@@ -1,39 +1,37 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Loot do
1
+ RSpec.describe Mdm::Loot, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:workspace).class_name('Mdm::Workspace') }
8
- it { should belong_to(:service).class_name('Mdm::Service') }
9
- it { should belong_to(:host).class_name('Mdm::Host') }
10
- it { should belong_to(:module_run).class_name('MetasploitDataModels::ModuleRun') }
5
+ it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
6
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
7
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
8
+ it { is_expected.to belong_to(:module_run).class_name('MetasploitDataModels::ModuleRun') }
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(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
22
- it { should have_db_column(:host_id).of_type(:integer) }
23
- it { should have_db_column(:service_id).of_type(:integer) }
24
- it { should have_db_column(:ltype).of_type(:string) }
25
- it { should have_db_column(:path).of_type(:string) }
26
- it { should have_db_column(:data).of_type(:text) }
27
- it { should have_db_column(:content_type).of_type(:string) }
28
- it { should have_db_column(:name).of_type(:text) }
29
- it { should have_db_column(:info).of_type(:text) }
19
+ it { is_expected.to have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
20
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
21
+ it { is_expected.to have_db_column(:service_id).of_type(:integer) }
22
+ it { is_expected.to have_db_column(:ltype).of_type(:string) }
23
+ it { is_expected.to have_db_column(:path).of_type(:string) }
24
+ it { is_expected.to have_db_column(:data).of_type(:text) }
25
+ it { is_expected.to have_db_column(:content_type).of_type(:string) }
26
+ it { is_expected.to have_db_column(:name).of_type(:text) }
27
+ it { is_expected.to have_db_column(:info).of_type(:text) }
30
28
  end
31
29
  end
32
30
 
33
31
  context 'factory' do
34
32
  it 'should be valid' do
35
33
  loot = FactoryGirl.build(:mdm_loot)
36
- loot.should be_valid
34
+ expect(loot).to be_valid
37
35
  end
38
36
  end
39
37
 
@@ -53,17 +51,17 @@ describe Mdm::Loot do
53
51
  context 'search' do
54
52
  it 'should match on ltype' do
55
53
  myloot = FactoryGirl.create(:mdm_loot, :ltype => 'find.this.ltype')
56
- Mdm::Loot.search('find.this.ltype').should include(myloot)
54
+ expect(Mdm::Loot.search('find.this.ltype')).to include(myloot)
57
55
  end
58
56
 
59
57
  it 'should match on name' do
60
58
  myloot = FactoryGirl.create(:mdm_loot, :name => 'Find This')
61
- Mdm::Loot.search('Find This').should include(myloot)
59
+ expect(Mdm::Loot.search('Find This')).to include(myloot)
62
60
  end
63
61
 
64
62
  it 'should match on info' do
65
63
  myloot = FactoryGirl.create(:mdm_loot, :info => 'Find This')
66
- Mdm::Loot.search('Find This').should include(myloot)
64
+ expect(Mdm::Loot.search('Find This')).to include(myloot)
67
65
  end
68
66
  end
69
67
  end
@@ -72,7 +70,7 @@ describe Mdm::Loot do
72
70
  context 'before_destroy' do
73
71
  it 'should call #delete_file' do
74
72
  myloot = FactoryGirl.create(:mdm_loot)
75
- myloot.should_receive(:delete_file)
73
+ expect(myloot).to receive(:delete_file)
76
74
  myloot.destroy
77
75
  end
78
76
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Macro do
1
+ RSpec.describe Mdm::Macro, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::ModRef do
1
+ RSpec.describe Mdm::ModRef, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
  end
@@ -1,21 +1,19 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Module::Action do
1
+ RSpec.describe Mdm::Module::Action, 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(:detail).class_name('Mdm::Module::Detail') }
6
+ it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'columns' do
13
- it { should have_db_column(:detail_id).of_type(:integer) }
14
- it { should have_db_column(:name).of_type(:text) }
11
+ it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
12
+ it { is_expected.to have_db_column(:name).of_type(:text) }
15
13
  end
16
14
 
17
15
  context 'indices' do
18
- it { should have_db_index(:detail_id) }
16
+ it { is_expected.to have_db_index(:detail_id) }
19
17
  end
20
18
  end
21
19
 
@@ -25,12 +23,12 @@ describe Mdm::Module::Action do
25
23
  FactoryGirl.build(:mdm_module_action)
26
24
  end
27
25
 
28
- it { should be_valid }
26
+ it { is_expected.to be_valid }
29
27
  end
30
28
  end
31
29
 
32
30
  context 'validations' do
33
- it { should validate_presence_of(:detail) }
34
- it { should validate_presence_of(:name) }
31
+ it { is_expected.to validate_presence_of(:detail) }
32
+ it { is_expected.to validate_presence_of(:name) }
35
33
  end
36
34
  end
@@ -1,21 +1,19 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Module::Arch do
1
+ RSpec.describe Mdm::Module::Arch, 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(:detail).class_name('Mdm::Module::Detail') }
6
+ it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'columns' do
13
- it { should have_db_column(:detail_id).of_type(:integer) }
14
- it { should have_db_column(:name).of_type(:text) }
11
+ it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
12
+ it { is_expected.to have_db_column(:name).of_type(:text) }
15
13
  end
16
14
 
17
15
  context 'indices' do
18
- it { should have_db_index(:detail_id) }
16
+ it { is_expected.to have_db_index(:detail_id) }
19
17
  end
20
18
  end
21
19
 
@@ -25,12 +23,12 @@ describe Mdm::Module::Arch do
25
23
  FactoryGirl.build(:mdm_module_arch)
26
24
  end
27
25
 
28
- it { should be_valid }
26
+ it { is_expected.to be_valid }
29
27
  end
30
28
  end
31
29
 
32
30
  context 'validations' do
33
- it { should validate_presence_of(:detail) }
34
- it { should validate_presence_of(:name) }
31
+ it { is_expected.to validate_presence_of(:detail) }
32
+ it { is_expected.to validate_presence_of(:name) }
35
33
  end
36
34
  end
@@ -1,22 +1,20 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Module::Author do
1
+ RSpec.describe Mdm::Module::Author, 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(:detail).class_name('Mdm::Module::Detail') }
6
+ it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'columns' do
13
- it { should have_db_column(:detail_id).of_type(:integer) }
14
- it { should have_db_column(:name).of_type(:text) }
15
- it { should have_db_column(:email).of_type(:text) }
11
+ it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
12
+ it { is_expected.to have_db_column(:name).of_type(:text) }
13
+ it { is_expected.to have_db_column(:email).of_type(:text) }
16
14
  end
17
15
 
18
16
  context 'indices' do
19
- it { should have_db_index(:detail_id) }
17
+ it { is_expected.to have_db_index(:detail_id) }
20
18
  end
21
19
  end
22
20
 
@@ -26,8 +24,15 @@ describe Mdm::Module::Author do
26
24
  FactoryGirl.build :full_mdm_module_author
27
25
  end
28
26
 
29
- it { should be_valid }
30
- its(:email) { should_not be_nil }
27
+ it { is_expected.to be_valid }
28
+
29
+ context 'email' do
30
+ subject(:email) {
31
+ full_mdm_module_author.email
32
+ }
33
+
34
+ it { is_expected.not_to be_nil }
35
+ end
31
36
  end
32
37
 
33
38
  context 'mdm_module_author' do
@@ -35,13 +40,13 @@ describe Mdm::Module::Author do
35
40
  FactoryGirl.build :mdm_module_author
36
41
  end
37
42
 
38
- it { should be_valid }
43
+ it { is_expected.to be_valid }
39
44
  end
40
45
  end
41
46
 
42
47
  context 'validations' do
43
- it { should validate_presence_of(:detail) }
44
- it { should_not validate_presence_of(:email) }
45
- it { should validate_presence_of(:name) }
48
+ it { is_expected.to validate_presence_of(:detail) }
49
+ it { is_expected.not_to validate_presence_of(:email) }
50
+ it { is_expected.to validate_presence_of(:name) }
46
51
  end
47
52
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Module::Detail do
1
+ RSpec.describe Mdm::Module::Detail, type: :model do
4
2
  subject(:detail) do
5
3
  FactoryGirl.build(
6
4
  :mdm_module_detail,
@@ -50,13 +48,13 @@ describe Mdm::Module::Detail do
50
48
  it_should_behave_like 'Metasploit::Concern.run'
51
49
 
52
50
  context 'associations' do
53
- it { should have_many(:actions).class_name('Mdm::Module::Action').dependent(:destroy) }
54
- it { should have_many(:archs).class_name('Mdm::Module::Arch').dependent(:destroy) }
55
- it { should have_many(:authors).class_name('Mdm::Module::Author').dependent(:destroy) }
56
- it { should have_many(:mixins).class_name('Mdm::Module::Mixin').dependent(:destroy) }
57
- it { should have_many(:platforms).class_name('Mdm::Module::Platform').dependent(:destroy) }
58
- it { should have_many(:refs).class_name('Mdm::Module::Ref').dependent(:destroy) }
59
- it { should have_many(:targets).class_name('Mdm::Module::Target').dependent(:destroy) }
51
+ it { is_expected.to have_many(:actions).class_name('Mdm::Module::Action').dependent(:destroy) }
52
+ it { is_expected.to have_many(:archs).class_name('Mdm::Module::Arch').dependent(:destroy) }
53
+ it { is_expected.to have_many(:authors).class_name('Mdm::Module::Author').dependent(:destroy) }
54
+ it { is_expected.to have_many(:mixins).class_name('Mdm::Module::Mixin').dependent(:destroy) }
55
+ it { is_expected.to have_many(:platforms).class_name('Mdm::Module::Platform').dependent(:destroy) }
56
+ it { is_expected.to have_many(:refs).class_name('Mdm::Module::Ref').dependent(:destroy) }
57
+ it { is_expected.to have_many(:targets).class_name('Mdm::Module::Target').dependent(:destroy) }
60
58
  end
61
59
 
62
60
  context 'CONSTANTS' do
@@ -65,12 +63,29 @@ describe Mdm::Module::Detail do
65
63
  described_class::DIRECTORY_BY_TYPE
66
64
  end
67
65
 
68
- its(['auxiliary']) { should == 'auxiliary' }
69
- its(['encoder']) { should == 'encoders' }
70
- its(['exploit']) { should == 'exploits' }
71
- its(['nop']) { should == 'nops' }
72
- its(['payload']) { should == 'payloads' }
73
- its(['post']) { should == 'post' }
66
+ it "maps 'auxiliary' to 'auxiliary'" do
67
+ expect(directory_by_type['auxiliary']).to eq('auxiliary')
68
+ end
69
+
70
+ it "maps 'encoder' to 'encoders'" do
71
+ expect(directory_by_type['encoder']).to eq('encoders')
72
+ end
73
+
74
+ it "maps 'exploit' to 'exploits'" do
75
+ expect(directory_by_type['exploit']).to eq('exploits')
76
+ end
77
+
78
+ it "maps 'nop' to 'nops'" do
79
+ expect(directory_by_type['nop']).to eq('nops')
80
+ end
81
+
82
+ it "maps 'payload' to 'payloads'" do
83
+ expect(directory_by_type['payload']).to eq('payloads')
84
+ end
85
+
86
+ it "maps 'post' to 'post'" do
87
+ expect(directory_by_type['post']).to eq('post')
88
+ end
74
89
  end
75
90
 
76
91
  context 'PRIVILEGES' do
@@ -79,8 +94,8 @@ describe Mdm::Module::Detail do
79
94
  end
80
95
 
81
96
  it 'should contain both Boolean values' do
82
- privileges.should include(false)
83
- privileges.should include(true)
97
+ expect(privileges).to include(false)
98
+ expect(privileges).to include(true)
84
99
  end
85
100
  end
86
101
 
@@ -89,13 +104,33 @@ describe Mdm::Module::Detail do
89
104
  described_class::RANK_BY_NAME
90
105
  end
91
106
 
92
- its(['Manual']) { should == 0 }
93
- its(['Low']) { should == 100 }
94
- its(['Average']) { should == 200 }
95
- its(['Normal']) { should == 300 }
96
- its(['Good']) { should == 400 }
97
- its(['Great']) { should == 500 }
98
- its(['Excellent']) { should == 600 }
107
+ it "maps 'Manual' to 0" do
108
+ expect(rank_by_name['Manual']).to eq(0)
109
+ end
110
+
111
+ it "maps 'Low' to 100" do
112
+ expect(rank_by_name['Low']).to eq(100)
113
+ end
114
+
115
+ it "maps 'Average' to 200" do
116
+ expect(rank_by_name['Average']).to eq(200)
117
+ end
118
+
119
+ it "maps 'Normal' to 300" do
120
+ expect(rank_by_name['Normal']).to eq(300)
121
+ end
122
+
123
+ it "maps 'Good' to 400" do
124
+ expect(rank_by_name['Good']).to eq(400)
125
+ end
126
+
127
+ it "maps 'Great' to 500" do
128
+ expect(rank_by_name['Great']).to eq(500)
129
+ end
130
+
131
+ it "maps 'Excellent' to 600" do
132
+ expect(rank_by_name['Excellent']).to eq(600)
133
+ end
99
134
  end
100
135
 
101
136
  context 'STANCES' do
@@ -103,34 +138,34 @@ describe Mdm::Module::Detail do
103
138
  described_class::STANCES
104
139
  end
105
140
 
106
- it { should include('aggressive') }
107
- it { should include('passive') }
141
+ it { is_expected.to include('aggressive') }
142
+ it { is_expected.to include('passive') }
108
143
  end
109
144
  end
110
145
 
111
146
  context 'database' do
112
147
  context 'columns' do
113
- it { should have_db_column(:default_target).of_type(:integer) }
114
- it { should have_db_column(:description).of_type(:text) }
115
- it { should have_db_column(:disclosure_date).of_type(:datetime)}
116
- it { should have_db_column(:file).of_type(:text) }
117
- it { should have_db_column(:fullname).of_type(:text) }
118
- it { should have_db_column(:license).of_type(:string) }
119
- it { should have_db_column(:mtime).of_type(:datetime) }
120
- it { should have_db_column(:mtype).of_type(:string) }
121
- it { should have_db_column(:name).of_type(:text) }
122
- it { should have_db_column(:privileged).of_type(:boolean) }
123
- it { should have_db_column(:rank).of_type(:integer) }
124
- it { should have_db_column(:ready).of_type(:boolean) }
125
- it { should have_db_column(:refname).of_type(:text) }
126
- it { should have_db_column(:stance).of_type(:string).with_options(:null => true) }
148
+ it { is_expected.to have_db_column(:default_target).of_type(:integer) }
149
+ it { is_expected.to have_db_column(:description).of_type(:text) }
150
+ it { is_expected.to have_db_column(:disclosure_date).of_type(:datetime)}
151
+ it { is_expected.to have_db_column(:file).of_type(:text) }
152
+ it { is_expected.to have_db_column(:fullname).of_type(:text) }
153
+ it { is_expected.to have_db_column(:license).of_type(:string) }
154
+ it { is_expected.to have_db_column(:mtime).of_type(:datetime) }
155
+ it { is_expected.to have_db_column(:mtype).of_type(:string) }
156
+ it { is_expected.to have_db_column(:name).of_type(:text) }
157
+ it { is_expected.to have_db_column(:privileged).of_type(:boolean) }
158
+ it { is_expected.to have_db_column(:rank).of_type(:integer) }
159
+ it { is_expected.to have_db_column(:ready).of_type(:boolean) }
160
+ it { is_expected.to have_db_column(:refname).of_type(:text) }
161
+ it { is_expected.to have_db_column(:stance).of_type(:string).with_options(:null => true) }
127
162
  end
128
163
 
129
164
  context 'indices' do
130
- it { should have_db_index(:description) }
131
- it { should have_db_index(:mtype) }
132
- it { should have_db_index(:name) }
133
- it { should have_db_index(:refname) }
165
+ it { is_expected.to have_db_index(:description) }
166
+ it { is_expected.to have_db_index(:mtype) }
167
+ it { is_expected.to have_db_index(:name) }
168
+ it { is_expected.to have_db_index(:refname) }
134
169
  end
135
170
  end
136
171
 
@@ -140,7 +175,7 @@ describe Mdm::Module::Detail do
140
175
  FactoryGirl.build(:mdm_module_detail)
141
176
  end
142
177
 
143
- it { should be_valid }
178
+ it { is_expected.to be_valid }
144
179
 
145
180
  context 'stance' do
146
181
  subject(:mdm_module_detail) do
@@ -152,10 +187,23 @@ describe Mdm::Module::Detail do
152
187
  'exploit'
153
188
  end
154
189
 
155
- it { should be_valid }
190
+ it { is_expected.to be_valid }
191
+
192
+ context '#stance' do
193
+ subject(:stance) {
194
+ mdm_module_detail.stance
195
+ }
156
196
 
157
- its(:stance) { should_not be_nil }
158
- its(:supports_stance?) { should be_true }
197
+ it { is_expected.not_to be_nil }
198
+ end
199
+
200
+ context '#supports_stance?' do
201
+ subject(:supports_stance?) {
202
+ mdm_module_detail.supports_stance?
203
+ }
204
+
205
+ it { is_expected.to eq(true) }
206
+ end
159
207
  end
160
208
 
161
209
  context 'without supports_stance?' do
@@ -163,27 +211,40 @@ describe Mdm::Module::Detail do
163
211
  'post'
164
212
  end
165
213
 
166
- it { should be_valid }
214
+ it { is_expected.to be_valid }
215
+
216
+ context '#stance' do
217
+ subject(:stance) {
218
+ mdm_module_detail.stance
219
+ }
167
220
 
168
- its(:stance) { should be_nil }
169
- its(:supports_stance?) { should be_false }
221
+ it { is_expected.to be_nil }
222
+ end
223
+
224
+ context '#supports_stance?' do
225
+ subject(:supports_stance?) {
226
+ mdm_module_detail.supports_stance?
227
+ }
228
+
229
+ it { is_expected.to eq(false) }
230
+ end
170
231
  end
171
232
  end
172
233
  end
173
234
  end
174
235
 
175
236
  context 'validations' do
176
- it { should validate_inclusion_of(:mtype).in_array(types) }
237
+ it { is_expected.to validate_inclusion_of(:mtype).in_array(types) }
177
238
 
178
239
  # Because the boolean field will cast most strings to false,
179
240
  # validate_inclusion_of(:privileged).in_array([true, false]) will fail on the disallowed values check.
180
241
 
181
242
  context 'rank' do
182
- it { should validate_numericality_of(:rank).only_integer }
183
- it { should validate_inclusion_of(:rank).in_array(ranks) }
243
+ it { is_expected.to validate_numericality_of(:rank).only_integer }
244
+ it { is_expected.to validate_inclusion_of(:rank).in_array(ranks) }
184
245
  end
185
246
 
186
- it { should validate_presence_of(:refname) }
247
+ it { is_expected.to validate_presence_of(:refname) }
187
248
 
188
249
  context 'stance' do
189
250
  context 'mtype' do
@@ -225,9 +286,13 @@ describe Mdm::Module::Detail do
225
286
  detail.actions.last
226
287
  end
227
288
 
228
- it { should be_valid }
289
+ it { is_expected.to be_valid }
229
290
 
230
- its(:name) { should == name }
291
+ context '#name' do
292
+ it 'is name passed to add_action' do
293
+ expect(module_action.name).to eq(name)
294
+ end
295
+ end
231
296
  end
232
297
  end
233
298
 
@@ -253,9 +318,13 @@ describe Mdm::Module::Detail do
253
318
  detail.archs.last
254
319
  end
255
320
 
256
- it { should be_valid }
321
+ it { is_expected.to be_valid }
257
322
 
258
- its(:name) { should == name }
323
+ context '#name' do
324
+ it 'is name passed to add_arch' do
325
+ expect(module_arch.name).to eq(name)
326
+ end
327
+ end
259
328
  end
260
329
  end
261
330
 
@@ -286,10 +355,19 @@ describe Mdm::Module::Detail do
286
355
  detail.authors.last
287
356
  end
288
357
 
289
- it { should be_valid }
358
+ it { is_expected.to be_valid }
290
359
 
291
- its(:email) { should == email }
292
- its(:name) { should == name }
360
+ context '#email' do
361
+ it 'is email passed to add_author' do
362
+ expect(module_author.email).to eq(email)
363
+ end
364
+ end
365
+
366
+ context '#name' do
367
+ it 'is name passed to add_author' do
368
+ expect(module_author.name).to eq(name)
369
+ end
370
+ end
293
371
  end
294
372
  end
295
373
 
@@ -311,10 +389,21 @@ describe Mdm::Module::Detail do
311
389
  detail.authors.last
312
390
  end
313
391
 
314
- it { should be_valid }
392
+ it { is_expected.to be_valid }
393
+
394
+ context '#email' do
395
+ subject(:module_author_email) {
396
+ module_author.email
397
+ }
398
+
399
+ it { is_expected.to be_nil }
400
+ end
315
401
 
316
- its(:email) { should be_nil }
317
- its(:name) { should == name }
402
+ context '#name' do
403
+ it 'is name passed to add_author' do
404
+ expect(module_author.name).to eq(name)
405
+ end
406
+ end
318
407
  end
319
408
  end
320
409
  end
@@ -335,14 +424,19 @@ describe Mdm::Module::Detail do
335
424
  end
336
425
 
337
426
  context 'new Mdm::ModuleMixin' do
338
- subject do
427
+ subject(:mdm_module_mixin) do
339
428
  add_mixin
340
429
 
341
430
  detail.mixins.last
342
431
  end
343
432
 
344
- it { should be_valid }
345
- its(:name) { should == name }
433
+ it { is_expected.to be_valid }
434
+
435
+ context '#name' do
436
+ it 'is name passed to add_mixin' do
437
+ expect(mdm_module_mixin.name).to eq(name)
438
+ end
439
+ end
346
440
  end
347
441
  end
348
442
 
@@ -368,8 +462,13 @@ describe Mdm::Module::Detail do
368
462
  detail.platforms.last
369
463
  end
370
464
 
371
- it { should be_valid }
372
- its(:name) { should == name }
465
+ it { is_expected.to be_valid }
466
+
467
+ context '#name' do
468
+ it 'is name passed to add_platform' do
469
+ expect(module_platform.name).to eq(name)
470
+ end
471
+ end
373
472
  end
374
473
  end
375
474
 
@@ -395,8 +494,13 @@ describe Mdm::Module::Detail do
395
494
  detail.refs.last
396
495
  end
397
496
 
398
- it { should be_valid }
399
- its(:name) { should == name }
497
+ it { is_expected.to be_valid }
498
+
499
+ context '#name' do
500
+ it 'is name passed to add_ref' do
501
+ expect(module_ref.name).to eq(name)
502
+ end
503
+ end
400
504
  end
401
505
  end
402
506
 
@@ -426,8 +530,13 @@ describe Mdm::Module::Detail do
426
530
  detail.targets.last
427
531
  end
428
532
 
429
- it { should be_valid }
430
- its(:name) { should == name }
533
+ it { is_expected.to be_valid }
534
+
535
+ context '#name' do
536
+ it 'is name passed to add_target' do
537
+ expect(module_target.name).to eq(name)
538
+ end
539
+ end
431
540
  end
432
541
  end
433
542
  end