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.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/Gemfile +1 -3
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/password_is_strong_validator.rb +1 -1
- data/lib/mdm/host/operating_system_normalization.rb +0 -10
- data/lib/metasploit_data_models/version.rb +2 -2
- data/metasploit_data_models.gemspec +1 -1
- data/spec/app/models/mdm/api_key_spec.rb +1 -3
- data/spec/app/models/mdm/client_spec.rb +9 -11
- data/spec/app/models/mdm/cred_spec.rb +42 -54
- data/spec/app/models/mdm/event_spec.rb +21 -23
- data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
- data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
- data/spec/app/models/mdm/host_detail_spec.rb +15 -17
- data/spec/app/models/mdm/host_spec.rb +261 -260
- data/spec/app/models/mdm/host_tag_spec.rb +6 -8
- data/spec/app/models/mdm/listener_spec.rb +30 -32
- data/spec/app/models/mdm/loot_spec.rb +21 -23
- data/spec/app/models/mdm/macro_spec.rb +1 -3
- data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
- data/spec/app/models/mdm/module/action_spec.rb +10 -12
- data/spec/app/models/mdm/module/arch_spec.rb +10 -12
- data/spec/app/models/mdm/module/author_spec.rb +22 -17
- data/spec/app/models/mdm/module/detail_spec.rb +184 -75
- data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
- data/spec/app/models/mdm/module/platform_spec.rb +10 -12
- data/spec/app/models/mdm/module/ref_spec.rb +10 -12
- data/spec/app/models/mdm/module/target_spec.rb +13 -15
- data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
- data/spec/app/models/mdm/note_spec.rb +23 -25
- data/spec/app/models/mdm/profile_spec.rb +1 -3
- data/spec/app/models/mdm/ref_spec.rb +10 -12
- data/spec/app/models/mdm/route_spec.rb +6 -8
- data/spec/app/models/mdm/service_spec.rb +38 -40
- data/spec/app/models/mdm/session_event_spec.rb +10 -12
- data/spec/app/models/mdm/session_spec.rb +13 -15
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +9 -11
- data/spec/app/models/mdm/task_host_spec.rb +9 -11
- data/spec/app/models/mdm/task_service_spec.rb +9 -11
- data/spec/app/models/mdm/task_session_spec.rb +7 -9
- data/spec/app/models/mdm/task_spec.rb +27 -29
- data/spec/app/models/mdm/user_spec.rb +17 -19
- data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
- data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
- data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
- data/spec/app/models/mdm/vuln_spec.rb +24 -26
- data/spec/app/models/mdm/web_form_spec.rb +11 -13
- data/spec/app/models/mdm/web_page_spec.rb +19 -21
- data/spec/app/models/mdm/web_site_spec.rb +21 -23
- data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
- data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
- data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
- data/spec/app/models/mdm/workspace_spec.rb +97 -100
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
- data/spec/dummy/db/structure.sql +1 -0
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
- data/spec/spec_helper.rb +72 -6
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
- metadata +6 -6
@@ -1,17 +1,15 @@
|
|
1
|
-
|
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 {
|
8
|
-
it {
|
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 {
|
14
|
-
it {
|
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 {
|
22
|
+
it { is_expected.to be_valid }
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
@@ -1,37 +1,35 @@
|
|
1
|
-
|
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 {
|
8
|
-
it {
|
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 {
|
15
|
-
it {
|
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 {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
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.
|
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.
|
55
|
-
portless_listener.errors[:port].
|
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.
|
61
|
-
out_of_range.errors[:port].
|
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.
|
67
|
-
out_of_range.errors[:port].
|
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.
|
73
|
-
out_of_range.errors[:port].
|
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.
|
79
|
-
out_of_range.errors[:port].
|
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.
|
87
|
-
addressless_listener.errors[:address].
|
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.
|
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.
|
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.
|
100
|
+
expect(invalid_listener).not_to be_valid
|
103
101
|
end
|
104
102
|
|
105
103
|
end
|
@@ -1,39 +1,37 @@
|
|
1
|
-
|
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 {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
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 {
|
17
|
-
it {
|
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 {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
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.
|
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').
|
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').
|
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').
|
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.
|
73
|
+
expect(myloot).to receive(:delete_file)
|
76
74
|
myloot.destroy
|
77
75
|
end
|
78
76
|
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
|
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 {
|
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 {
|
14
|
-
it {
|
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 {
|
16
|
+
it { is_expected.to have_db_index(:detail_id) }
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -25,17 +23,17 @@ describe Mdm::Module::Action do
|
|
25
23
|
FactoryGirl.build(:mdm_module_action)
|
26
24
|
end
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { is_expected.to be_valid }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'mass assignment security' do
|
33
|
-
it {
|
34
|
-
it {
|
31
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
32
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
35
33
|
end
|
36
34
|
|
37
35
|
context 'validations' do
|
38
|
-
it {
|
39
|
-
it {
|
36
|
+
it { is_expected.to validate_presence_of(:detail) }
|
37
|
+
it { is_expected.to validate_presence_of(:name) }
|
40
38
|
end
|
41
39
|
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
|
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 {
|
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 {
|
14
|
-
it {
|
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 {
|
16
|
+
it { is_expected.to have_db_index(:detail_id) }
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -25,17 +23,17 @@ describe Mdm::Module::Arch do
|
|
25
23
|
FactoryGirl.build(:mdm_module_arch)
|
26
24
|
end
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { is_expected.to be_valid }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'mass assignment security' do
|
33
|
-
it {
|
34
|
-
it {
|
31
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
32
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
35
33
|
end
|
36
34
|
|
37
35
|
context 'validations' do
|
38
|
-
it {
|
39
|
-
it {
|
36
|
+
it { is_expected.to validate_presence_of(:detail) }
|
37
|
+
it { is_expected.to validate_presence_of(:name) }
|
40
38
|
end
|
41
39
|
end
|
@@ -1,22 +1,20 @@
|
|
1
|
-
|
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 {
|
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 {
|
14
|
-
it {
|
15
|
-
it {
|
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 {
|
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 {
|
30
|
-
|
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,19 +40,19 @@ describe Mdm::Module::Author do
|
|
35
40
|
FactoryGirl.build :mdm_module_author
|
36
41
|
end
|
37
42
|
|
38
|
-
it {
|
43
|
+
it { is_expected.to be_valid }
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
47
|
context 'mass assignment security' do
|
43
|
-
it {
|
44
|
-
it {
|
45
|
-
it {
|
48
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
49
|
+
it { is_expected.to allow_mass_assignment_of(:email) }
|
50
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
46
51
|
end
|
47
52
|
|
48
53
|
context 'validations' do
|
49
|
-
it {
|
50
|
-
it {
|
51
|
-
it {
|
54
|
+
it { is_expected.to validate_presence_of(:detail) }
|
55
|
+
it { is_expected.not_to validate_presence_of(:email) }
|
56
|
+
it { is_expected.to validate_presence_of(:name) }
|
52
57
|
end
|
53
58
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
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 {
|
54
|
-
it {
|
55
|
-
it {
|
56
|
-
it {
|
57
|
-
it {
|
58
|
-
it {
|
59
|
-
it {
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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.
|
83
|
-
privileges.
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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 {
|
107
|
-
it {
|
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 {
|
114
|
-
it {
|
115
|
-
it {
|
116
|
-
it {
|
117
|
-
it {
|
118
|
-
it {
|
119
|
-
it {
|
120
|
-
it {
|
121
|
-
it {
|
122
|
-
it {
|
123
|
-
it {
|
124
|
-
it {
|
125
|
-
it {
|
126
|
-
it {
|
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 {
|
131
|
-
it {
|
132
|
-
it {
|
133
|
-
it {
|
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 {
|
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 {
|
190
|
+
it { is_expected.to be_valid }
|
191
|
+
|
192
|
+
context '#stance' do
|
193
|
+
subject(:stance) {
|
194
|
+
mdm_module_detail.stance
|
195
|
+
}
|
156
196
|
|
157
|
-
|
158
|
-
|
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 {
|
214
|
+
it { is_expected.to be_valid }
|
215
|
+
|
216
|
+
context '#stance' do
|
217
|
+
subject(:stance) {
|
218
|
+
mdm_module_detail.stance
|
219
|
+
}
|
167
220
|
|
168
|
-
|
169
|
-
|
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 {
|
237
|
+
it { is_expected.to ensure_inclusion_of(:mtype).in_array(types) }
|
177
238
|
|
178
239
|
# Because the boolean field will cast most strings to false,
|
179
240
|
# ensure_inclusion_of(:privileged).in_array([true, false]) will fail on the disallowed values check.
|
180
241
|
|
181
242
|
context 'rank' do
|
182
|
-
it {
|
183
|
-
it {
|
243
|
+
it { is_expected.to validate_numericality_of(:rank).only_integer }
|
244
|
+
it { is_expected.to ensure_inclusion_of(:rank).in_array(ranks) }
|
184
245
|
end
|
185
246
|
|
186
|
-
it {
|
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 {
|
289
|
+
it { is_expected.to be_valid }
|
229
290
|
|
230
|
-
|
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 {
|
321
|
+
it { is_expected.to be_valid }
|
257
322
|
|
258
|
-
|
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 {
|
358
|
+
it { is_expected.to be_valid }
|
290
359
|
|
291
|
-
|
292
|
-
|
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 {
|
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
|
-
|
317
|
-
|
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 {
|
345
|
-
|
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 {
|
372
|
-
|
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 {
|
399
|
-
|
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 {
|
430
|
-
|
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
|