metasploit_data_models 0.24.4 → 0.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/.travis.yml +3 -6
- data/CONTRIBUTING.md +52 -10
- data/Gemfile +8 -1
- data/Rakefile +0 -23
- data/app/models/mdm/api_key.rb +1 -41
- data/app/models/mdm/client.rb +1 -41
- data/app/models/mdm/cred.rb +19 -107
- data/app/models/mdm/event.rb +1 -48
- data/app/models/mdm/exploit_attempt.rb +16 -65
- data/app/models/mdm/exploited_host.rb +1 -28
- data/app/models/mdm/host_detail.rb +1 -45
- data/app/models/mdm/host_tag.rb +8 -6
- data/app/models/mdm/listener.rb +1 -53
- data/app/models/mdm/macro.rb +0 -42
- data/app/models/mdm/mod_ref.rb +0 -21
- data/app/models/mdm/module/action.rb +0 -15
- data/app/models/mdm/module/arch.rb +0 -10
- data/app/models/mdm/module/author.rb +0 -16
- data/app/models/mdm/module/mixin.rb +0 -13
- data/app/models/mdm/module/platform.rb +0 -11
- data/app/models/mdm/module/target.rb +0 -18
- data/app/models/mdm/nexpose_console.rb +4 -82
- data/app/models/mdm/profile.rb +0 -36
- data/app/models/mdm/route.rb +5 -17
- data/app/models/mdm/session_event.rb +1 -33
- data/app/models/mdm/tag.rb +10 -49
- data/app/models/mdm/task.rb +45 -94
- data/app/models/mdm/task_cred.rb +0 -29
- data/app/models/mdm/task_host.rb +0 -25
- data/app/models/mdm/task_service.rb +0 -25
- data/app/models/mdm/task_session.rb +0 -25
- data/app/models/mdm/user.rb +6 -188
- data/app/models/mdm/vuln_attempt.rb +12 -37
- data/app/models/mdm/vuln_detail.rb +5 -139
- data/app/models/mdm/vuln_ref.rb +1 -4
- data/app/models/mdm/web_form.rb +1 -35
- data/app/models/mdm/web_page.rb +1 -70
- data/app/models/mdm/web_site.rb +1 -51
- data/app/models/mdm/wmap_request.rb +0 -85
- data/app/models/mdm/wmap_target.rb +0 -40
- data/app/models/mdm/workspace.rb +14 -152
- data/app/models/metasploit_data_models/automatic_exploitation.rb +16 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +24 -19
- data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +5 -33
- data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +4 -22
- data/app/models/metasploit_data_models/automatic_exploitation/run.rb +3 -13
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/module_run.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/ip_format_validator.rb +0 -4
- data/app/validators/parameters_validator.rb +0 -12
- data/app/validators/password_is_strong_validator.rb +1 -10
- data/lib/mdm/host/operating_system_normalization.rb +10 -7
- data/lib/metasploit_data_models.rb +0 -4
- data/lib/metasploit_data_models/engine.rb +0 -2
- data/lib/metasploit_data_models/serialized_prefs.rb +0 -6
- data/lib/metasploit_data_models/version.rb +10 -24
- data/lib/tasks/yard.rake +33 -0
- data/metasploit_data_models.gemspec +2 -9
- data/spec/app/models/mdm/api_key_spec.rb +3 -1
- data/spec/app/models/mdm/client_spec.rb +11 -9
- data/spec/app/models/mdm/cred_spec.rb +54 -42
- data/spec/app/models/mdm/event_spec.rb +23 -21
- data/spec/app/models/mdm/exploit_attempt_spec.rb +21 -19
- data/spec/app/models/mdm/exploited_host_spec.rb +13 -11
- data/spec/app/models/mdm/host_detail_spec.rb +17 -15
- data/spec/app/models/mdm/host_spec.rb +260 -261
- data/spec/app/models/mdm/host_tag_spec.rb +8 -6
- data/spec/app/models/mdm/listener_spec.rb +32 -30
- data/spec/app/models/mdm/loot_spec.rb +23 -21
- data/spec/app/models/mdm/macro_spec.rb +3 -1
- data/spec/app/models/mdm/mod_ref_spec.rb +3 -1
- data/spec/app/models/mdm/module/action_spec.rb +12 -10
- data/spec/app/models/mdm/module/arch_spec.rb +12 -10
- data/spec/app/models/mdm/module/author_spec.rb +17 -22
- data/spec/app/models/mdm/module/detail_spec.rb +75 -184
- data/spec/app/models/mdm/module/mixin_spec.rb +12 -10
- data/spec/app/models/mdm/module/platform_spec.rb +12 -10
- data/spec/app/models/mdm/module/ref_spec.rb +12 -10
- data/spec/app/models/mdm/module/target_spec.rb +15 -13
- data/spec/app/models/mdm/nexpose_console_spec.rb +37 -35
- data/spec/app/models/mdm/note_spec.rb +25 -23
- data/spec/app/models/mdm/profile_spec.rb +3 -1
- data/spec/app/models/mdm/ref_spec.rb +12 -10
- data/spec/app/models/mdm/route_spec.rb +8 -6
- data/spec/app/models/mdm/service_spec.rb +40 -38
- data/spec/app/models/mdm/session_event_spec.rb +12 -10
- data/spec/app/models/mdm/session_spec.rb +15 -13
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +11 -9
- data/spec/app/models/mdm/task_host_spec.rb +11 -9
- data/spec/app/models/mdm/task_service_spec.rb +11 -9
- data/spec/app/models/mdm/task_session_spec.rb +9 -7
- data/spec/app/models/mdm/task_spec.rb +29 -27
- data/spec/app/models/mdm/user_spec.rb +19 -17
- data/spec/app/models/mdm/vuln_attempt_spec.rb +16 -14
- data/spec/app/models/mdm/vuln_detail_spec.rb +28 -26
- data/spec/app/models/mdm/vuln_ref_spec.rb +10 -8
- data/spec/app/models/mdm/vuln_spec.rb +26 -24
- data/spec/app/models/mdm/web_form_spec.rb +13 -11
- data/spec/app/models/mdm/web_page_spec.rb +21 -19
- data/spec/app/models/mdm/web_site_spec.rb +23 -21
- data/spec/app/models/mdm/web_vuln_spec.rb +65 -63
- data/spec/app/models/mdm/wmap_request_spec.rb +3 -1
- data/spec/app/models/mdm/wmap_target_spec.rb +3 -1
- data/spec/app/models/mdm/workspace_spec.rb +100 -97
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +5 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +15 -13
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +12 -10
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +15 -22
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +20 -18
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +4 -2
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +19 -17
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +23 -61
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +10 -8
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +46 -54
- data/spec/dummy/db/structure.sql +3403 -0
- data/spec/factories/mdm/module/details.rb +1 -1
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +12 -18
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/match/child_spec.rb +4 -2
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/version_spec.rb +141 -3
- data/spec/spec_helper.rb +12 -86
- 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 +6 -7
- metadata +9 -67
- data/CHANGELOG.md +0 -6
- data/RELEASING.md +0 -88
- data/UPGRADING.md +0 -1
- data/lib/metasploit_data_models/automatic_exploitation.rb +0 -25
- data/spec/lib/metasploit_data_models_spec.rb +0 -4
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::Module::Mixin do
|
|
2
4
|
|
|
3
5
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
4
6
|
|
|
5
7
|
context 'associations' do
|
|
6
|
-
it {
|
|
8
|
+
it { should belong_to(:detail).class_name('Mdm::Module::Detail') }
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
context 'database' do
|
|
10
12
|
context 'columns' do
|
|
11
|
-
it {
|
|
12
|
-
it {
|
|
13
|
+
it { should have_db_column(:detail_id).of_type(:integer) }
|
|
14
|
+
it { should have_db_column(:name).of_type(:text) }
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
context 'indices' do
|
|
16
|
-
it {
|
|
18
|
+
it { should have_db_index(:detail_id) }
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
@@ -23,17 +25,17 @@ RSpec.describe Mdm::Module::Mixin, type: :model do
|
|
|
23
25
|
FactoryGirl.build :mdm_module_mixin
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
it {
|
|
28
|
+
it { should be_valid }
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
context 'mass assignment security' do
|
|
31
|
-
it {
|
|
32
|
-
it {
|
|
33
|
+
it { should_not allow_mass_assignment_of(:detail_id) }
|
|
34
|
+
it { should allow_mass_assignment_of(:name) }
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
context 'validations' do
|
|
36
|
-
it {
|
|
37
|
-
it {
|
|
38
|
+
it { should validate_presence_of(:detail) }
|
|
39
|
+
it { should validate_presence_of(:name) }
|
|
38
40
|
end
|
|
39
41
|
end
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::Module::Platform do
|
|
2
4
|
|
|
3
5
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
4
6
|
|
|
5
7
|
context 'associations' do
|
|
6
|
-
it {
|
|
8
|
+
it { should belong_to(:detail).class_name('Mdm::Module::Detail') }
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
context 'database' do
|
|
10
12
|
context 'columns' do
|
|
11
|
-
it {
|
|
12
|
-
it {
|
|
13
|
+
it { should have_db_column(:detail_id).of_type(:integer) }
|
|
14
|
+
it { should have_db_column(:name).of_type(:text) }
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
context 'indices' do
|
|
16
|
-
it {
|
|
18
|
+
it { should have_db_index(:detail_id) }
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
@@ -23,17 +25,17 @@ RSpec.describe Mdm::Module::Platform, type: :model do
|
|
|
23
25
|
FactoryGirl.build :mdm_module_platform
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
it {
|
|
28
|
+
it { should be_valid }
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
context 'mass assignment security' do
|
|
31
|
-
it {
|
|
32
|
-
it {
|
|
33
|
+
it { should_not allow_mass_assignment_of(:detail_id) }
|
|
34
|
+
it { should allow_mass_assignment_of(:name) }
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
context 'validations' do
|
|
36
|
-
it {
|
|
37
|
-
it {
|
|
38
|
+
it { should validate_presence_of :detail }
|
|
39
|
+
it { should validate_presence_of :name }
|
|
38
40
|
end
|
|
39
41
|
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::Module::Ref do
|
|
2
4
|
|
|
3
5
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
4
6
|
|
|
5
7
|
context 'associations' do
|
|
6
|
-
it {
|
|
8
|
+
it { should belong_to(:detail).class_name('Mdm::Module::Detail') }
|
|
7
9
|
|
|
8
10
|
# shoulda matchers don't have support for :primary_key option, so need
|
|
9
11
|
# to test this association manually
|
|
@@ -32,12 +34,12 @@ RSpec.describe Mdm::Module::Ref, type: :model do
|
|
|
32
34
|
|
|
33
35
|
context 'database' do
|
|
34
36
|
context 'columns' do
|
|
35
|
-
it {
|
|
36
|
-
it {
|
|
37
|
+
it { should have_db_column(:detail_id).of_type(:integer) }
|
|
38
|
+
it { should have_db_column(:name) }
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
context 'indices' do
|
|
40
|
-
it {
|
|
42
|
+
it { should have_db_column(:detail_id) }
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
@@ -47,17 +49,17 @@ RSpec.describe Mdm::Module::Ref, type: :model do
|
|
|
47
49
|
FactoryGirl.build :mdm_module_ref
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
it {
|
|
52
|
+
it { should be_valid }
|
|
51
53
|
end
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
context 'mass assignment security' do
|
|
55
|
-
it {
|
|
56
|
-
it {
|
|
57
|
+
it { should_not allow_mass_assignment_of(:detail_id) }
|
|
58
|
+
it { should allow_mass_assignment_of(:name) }
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
context 'validations' do
|
|
60
|
-
it {
|
|
61
|
-
it {
|
|
62
|
+
it { should validate_presence_of(:detail) }
|
|
63
|
+
it { should validate_presence_of(:name) }
|
|
62
64
|
end
|
|
63
65
|
end
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::Module::Target do
|
|
2
4
|
|
|
3
5
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
4
6
|
|
|
5
7
|
context 'associations' do
|
|
6
|
-
it {
|
|
8
|
+
it { should belong_to(:detail).class_name('Mdm::Module::Detail') }
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
context 'database' do
|
|
10
12
|
context 'columns' do
|
|
11
|
-
it {
|
|
12
|
-
it {
|
|
13
|
-
it {
|
|
13
|
+
it { should have_db_column(:detail_id).of_type(:integer) }
|
|
14
|
+
it { should have_db_column(:index).of_type(:integer) }
|
|
15
|
+
it { should have_db_column(:name).of_type(:text) }
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
context 'indices' do
|
|
17
|
-
it {
|
|
19
|
+
it { should have_db_index(:detail_id) }
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
@@ -24,19 +26,19 @@ RSpec.describe Mdm::Module::Target, type: :model do
|
|
|
24
26
|
FactoryGirl.build :mdm_module_target
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
it {
|
|
29
|
+
it { should be_valid }
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
context 'mass assignment security' do
|
|
32
|
-
it {
|
|
33
|
-
it {
|
|
34
|
-
it {
|
|
34
|
+
it { should_not allow_mass_assignment_of(:detail_id) }
|
|
35
|
+
it { should allow_mass_assignment_of(:index) }
|
|
36
|
+
it { should allow_mass_assignment_of(:name) }
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
context 'validations' do
|
|
38
|
-
it {
|
|
39
|
-
it {
|
|
40
|
-
it {
|
|
40
|
+
it { should validate_presence_of(:detail) }
|
|
41
|
+
it { should validate_presence_of(:index) }
|
|
42
|
+
it { should validate_presence_of(:name) }
|
|
41
43
|
end
|
|
42
44
|
end
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::NexposeConsole do
|
|
2
4
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
3
5
|
|
|
4
6
|
context 'factory' do
|
|
5
7
|
it 'should be valid' do
|
|
6
8
|
nexpose_console = FactoryGirl.build(:mdm_nexpose_console)
|
|
7
|
-
|
|
9
|
+
nexpose_console.should be_valid
|
|
8
10
|
end
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
context 'database' do
|
|
12
14
|
|
|
13
15
|
context 'timestamps'do
|
|
14
|
-
it {
|
|
15
|
-
it {
|
|
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) }
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
context 'columns' do
|
|
19
|
-
it {
|
|
20
|
-
it {
|
|
21
|
-
it {
|
|
22
|
-
it {
|
|
23
|
-
it {
|
|
24
|
-
it {
|
|
25
|
-
it {
|
|
26
|
-
it {
|
|
27
|
-
it {
|
|
28
|
-
it {
|
|
29
|
-
it {
|
|
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(:address).of_type(:text) }
|
|
24
|
+
it { should have_db_column(:port).of_type(:integer).with_options(:default => 3780) }
|
|
25
|
+
it { should have_db_column(:username).of_type(:text) }
|
|
26
|
+
it { should have_db_column(:password).of_type(:text) }
|
|
27
|
+
it { should have_db_column(:status).of_type(:text) }
|
|
28
|
+
it { should have_db_column(:version).of_type(:text) }
|
|
29
|
+
it { should have_db_column(:cert).of_type(:text) }
|
|
30
|
+
it { should have_db_column(:cached_sites).of_type(:binary) }
|
|
31
|
+
it { should have_db_column(:name).of_type(:text) }
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -46,74 +48,74 @@ RSpec.describe Mdm::NexposeConsole, type: :model do
|
|
|
46
48
|
context 'address' do
|
|
47
49
|
it 'should require an address' do
|
|
48
50
|
addressless_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => nil)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
addressless_nexpose_console.should_not be_valid
|
|
52
|
+
addressless_nexpose_console.errors[:address].should include("can't be blank")
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
it 'should be valid for IPv4 format' do
|
|
54
56
|
ipv4_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => '192.168.1.120')
|
|
55
|
-
|
|
57
|
+
ipv4_nexpose_console.should be_valid
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
it 'should be valid for IPv6 format' do
|
|
59
61
|
ipv6_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => '2001:0db8:85a3:0000:0000:8a2e:0370:7334')
|
|
60
|
-
|
|
62
|
+
ipv6_nexpose_console.should be_valid
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
context 'port' do
|
|
65
67
|
it 'should require a port' do
|
|
66
68
|
portless_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :port => nil)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
portless_nexpose_console.should_not be_valid
|
|
70
|
+
portless_nexpose_console.errors[:port].should include("is not included in the list")
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
it 'should not be valid for out-of-range numbers' do
|
|
72
74
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 70000)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
out_of_range.should_not be_valid
|
|
76
|
+
out_of_range.errors[:port].should include("is not included in the list")
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
it 'should not be valid for port 0' do
|
|
78
80
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 0)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
out_of_range.should_not be_valid
|
|
82
|
+
out_of_range.errors[:port].should include("is not included in the list")
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
it 'should not be valid for decimal numbers' do
|
|
84
86
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 5.67)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
out_of_range.should_not be_valid
|
|
88
|
+
out_of_range.errors[:port].should include("must be an integer")
|
|
87
89
|
end
|
|
88
90
|
|
|
89
91
|
it 'should not be valid for a negative number' do
|
|
90
92
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => -8)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
out_of_range.should_not be_valid
|
|
94
|
+
out_of_range.errors[:port].should include("is not included in the list")
|
|
93
95
|
end
|
|
94
96
|
end
|
|
95
97
|
|
|
96
98
|
context 'name' do
|
|
97
99
|
it 'should require a name' do
|
|
98
100
|
unnamed_console = FactoryGirl.build(:mdm_nexpose_console, :name => nil)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
unnamed_console.should_not be_valid
|
|
102
|
+
unnamed_console.errors[:name].should include("can't be blank")
|
|
101
103
|
end
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
context 'username' do
|
|
105
107
|
it 'should require a name' do
|
|
106
108
|
console = FactoryGirl.build(:mdm_nexpose_console, :username => nil)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
console.should_not be_valid
|
|
110
|
+
console.errors[:username].should include("can't be blank")
|
|
109
111
|
end
|
|
110
112
|
end
|
|
111
113
|
|
|
112
114
|
context 'password' do
|
|
113
115
|
it 'should require a password' do
|
|
114
116
|
console = FactoryGirl.build(:mdm_nexpose_console, :password => nil)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
console.should_not be_valid
|
|
118
|
+
console.errors[:password].should include("can't be blank")
|
|
117
119
|
end
|
|
118
120
|
end
|
|
119
121
|
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Mdm::Note do
|
|
2
4
|
it_should_behave_like 'Metasploit::Concern.run'
|
|
3
5
|
|
|
4
6
|
context 'factory' do
|
|
5
7
|
it 'should be valid' do
|
|
6
8
|
note = FactoryGirl.build(:mdm_note)
|
|
7
|
-
|
|
9
|
+
note.should be_valid
|
|
8
10
|
end
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
context 'database' do
|
|
12
14
|
|
|
13
15
|
context 'timestamps'do
|
|
14
|
-
it {
|
|
15
|
-
it {
|
|
16
|
+
it { should have_db_column(:created_at).of_type(:datetime) }
|
|
17
|
+
it { should have_db_column(:updated_at).of_type(:datetime) }
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
context 'columns' do
|
|
19
|
-
it {
|
|
20
|
-
it {
|
|
21
|
-
it {
|
|
22
|
-
it {
|
|
23
|
-
it {
|
|
24
|
-
it {
|
|
25
|
-
it {
|
|
26
|
-
it {
|
|
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(:vuln_id).of_type(:integer) }
|
|
25
|
+
it { should have_db_column(:ntype).of_type(:string) }
|
|
26
|
+
it { should have_db_column(:critical).of_type(:boolean) }
|
|
27
|
+
it { should have_db_column(:seen).of_type(:boolean) }
|
|
28
|
+
it { should have_db_column(:data).of_type(:text) }
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -40,10 +42,10 @@ RSpec.describe Mdm::Note, type: :model do
|
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
context 'associations' do
|
|
43
|
-
it {
|
|
44
|
-
it {
|
|
45
|
-
it {
|
|
46
|
-
it {
|
|
45
|
+
it { should belong_to(:workspace).class_name('Mdm::Workspace') }
|
|
46
|
+
it { should belong_to(:host).class_name('Mdm::Host') }
|
|
47
|
+
it { should belong_to(:service).class_name('Mdm::Service') }
|
|
48
|
+
it { should belong_to(:vuln).class_name('Mdm::Vuln') }
|
|
47
49
|
end
|
|
48
50
|
|
|
49
51
|
context 'scopes' do
|
|
@@ -52,16 +54,16 @@ RSpec.describe Mdm::Note, type: :model do
|
|
|
52
54
|
flagged_note = FactoryGirl.create(:mdm_note, :critical => true, :seen => false)
|
|
53
55
|
non_critical_note = FactoryGirl.create(:mdm_note, :critical => false, :seen => false)
|
|
54
56
|
flagged_set = Mdm::Note.flagged
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
flagged_set.should include(flagged_note)
|
|
58
|
+
flagged_set.should_not include(non_critical_note)
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
it 'should exclude seen notes' do
|
|
60
62
|
flagged_note = FactoryGirl.create(:mdm_note, :critical => true, :seen => false)
|
|
61
63
|
non_critical_note = FactoryGirl.create(:mdm_note, :critical => false, :seen => true)
|
|
62
64
|
flagged_set = Mdm::Note.flagged
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
flagged_set.should include(flagged_note)
|
|
66
|
+
flagged_set.should_not include(non_critical_note)
|
|
65
67
|
end
|
|
66
68
|
end
|
|
67
69
|
|
|
@@ -70,15 +72,15 @@ RSpec.describe Mdm::Note, type: :model do
|
|
|
70
72
|
flagged_note = FactoryGirl.create(:mdm_note, :ntype => 'flag.me', :critical => true, :seen => false)
|
|
71
73
|
webform_note = FactoryGirl.create(:mdm_note, :ntype => 'web.form', :critical => true, :seen => false)
|
|
72
74
|
visible_set = Mdm::Note.visible
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
visible_set.should include(flagged_note)
|
|
76
|
+
visible_set.should_not include(webform_note)
|
|
75
77
|
end
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
context 'search' do
|
|
79
81
|
it 'should match on ntype' do
|
|
80
82
|
flagged_note = FactoryGirl.create(:mdm_note, :ntype => 'flag.me', :critical => true, :seen => false)
|
|
81
|
-
|
|
83
|
+
Mdm::Note.search('flag.me').should include(flagged_note)
|
|
82
84
|
end
|
|
83
85
|
end
|
|
84
86
|
end
|