metasploit_data_models 0.15.2 → 0.16.0
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.
- data/Gemfile +2 -0
- data/app/models/mdm/client.rb +0 -1
- data/app/models/mdm/cred.rb +1 -1
- data/app/models/mdm/exploited_host.rb +0 -1
- data/app/models/mdm/listener.rb +2 -1
- data/app/models/mdm/nexpose_console.rb +2 -2
- data/app/models/mdm/session.rb +5 -1
- data/app/models/mdm/workspace.rb +0 -1
- data/db/migrate/20130525015035_remove_campaign_id_from_clients.rb +9 -0
- data/db/migrate/20130525212420_drop_table_imported_creds.rb +14 -0
- data/db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb +6 -0
- data/lib/mdm/host/operating_system_normalization.rb +4 -4
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/client_spec.rb +43 -0
- data/spec/app/models/mdm/cred_spec.rb +211 -0
- data/spec/app/models/mdm/events_spec.rb +85 -0
- data/spec/app/models/mdm/exploit_attempt_spec.rb +60 -0
- data/spec/app/models/mdm/exploited_host_spec.rb +44 -0
- data/spec/app/models/mdm/host_detail_spec.rb +49 -0
- data/spec/app/models/mdm/host_spec.rb +468 -0
- data/spec/app/models/mdm/host_tag_spec.rb +26 -0
- data/spec/app/models/mdm/listener_spec.rb +108 -0
- data/spec/app/models/mdm/loot_spec.rb +77 -0
- data/spec/app/models/mdm/nexpose_console_spec.rb +128 -0
- data/spec/app/models/mdm/note_spec.rb +84 -0
- data/spec/app/models/mdm/ref_spec.rb +13 -0
- data/spec/app/models/mdm/report_spec.rb +104 -0
- data/spec/app/models/mdm/report_template_spec.rb +52 -0
- data/spec/app/models/mdm/route_spec.rb +36 -0
- data/spec/app/models/mdm/service_spec.rb +70 -15
- data/spec/app/models/mdm/session_event_spec.rb +42 -0
- data/spec/app/models/mdm/session_spec.rb +114 -0
- data/spec/app/models/mdm/tag_spec.rb +104 -0
- data/spec/app/models/mdm/task_creds_spec.rb +32 -0
- data/spec/app/models/mdm/task_host_spec.rb +33 -0
- data/spec/app/models/mdm/task_service_spec.rb +33 -0
- data/spec/app/models/mdm/task_spec.rb +59 -5
- data/spec/app/models/mdm/user_spec.rb +51 -0
- data/spec/app/models/mdm/vuln_attempt_spec.rb +54 -0
- data/spec/app/models/mdm/vuln_details_spec.rb +66 -0
- data/spec/app/models/mdm/vuln_ref_spec.rb +24 -0
- data/spec/app/models/mdm/vuln_spec.rb +25 -0
- data/spec/app/models/mdm/web_form_spec.rb +47 -0
- data/spec/app/models/mdm/web_page_spec.rb +55 -0
- data/spec/app/models/mdm/web_site_spec.rb +86 -0
- data/spec/app/models/mdm/web_vuln_spec.rb +12 -0
- data/spec/app/models/mdm/workspace_spec.rb +567 -0
- data/spec/dummy/db/schema.rb +5 -13
- data/spec/factories/mdm/addresses.rb +5 -0
- data/spec/factories/mdm/clients.rb +8 -0
- data/spec/factories/mdm/events.rb +15 -0
- data/spec/factories/mdm/exploit_attempts.rb +8 -0
- data/spec/factories/mdm/exploited_hosts.rb +7 -0
- data/spec/factories/mdm/fingerprints/nessus_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/nexpose_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/nmap_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/retina_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/session_fingerprints.rb +6 -0
- data/spec/factories/mdm/host_details.rb +8 -0
- data/spec/factories/mdm/listeners.rb +12 -0
- data/spec/factories/mdm/loots.rb +11 -0
- data/spec/factories/mdm/nexpose_consoles.rb +15 -0
- data/spec/factories/mdm/notes.rb +12 -0
- data/spec/factories/mdm/report_templates.rb +8 -0
- data/spec/factories/mdm/reports.rb +13 -0
- data/spec/factories/mdm/routes.rb +36 -0
- data/spec/factories/mdm/session_events.rb +8 -0
- data/spec/factories/mdm/sessions.rb +13 -0
- data/spec/factories/mdm/vuln_attempts.rb +8 -0
- data/spec/factories/mdm/vuln_details.rb +8 -0
- data/spec/factories/mdm/web_forms.rb +33 -0
- data/spec/factories/mdm/web_pages.rb +64 -0
- metadata +95 -5
- data/app/models/mdm/imported_cred.rb +0 -10
@@ -1,6 +1,97 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
describe Mdm::Tag do
|
5
|
+
|
6
|
+
context 'associations' do
|
7
|
+
it { should have_many(:hosts_tags).class_name('Mdm::HostTag') }
|
8
|
+
it { should have_many(:hosts).class_name('Mdm::Host').through(:hosts_tags) }
|
9
|
+
it { should belong_to(:user).class_name('Mdm::User') }
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'database' do
|
13
|
+
|
14
|
+
context 'timestamps'do
|
15
|
+
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
16
|
+
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'columns' do
|
20
|
+
it { should have_db_column(:user_id).of_type(:integer) }
|
21
|
+
it { should have_db_column(:name).of_type(:string) }
|
22
|
+
it { should have_db_column(:desc).of_type(:text) }
|
23
|
+
it { should have_db_column(:report_summary).of_type(:boolean).with_options(:null => false, :default =>false) }
|
24
|
+
it { should have_db_column(:report_detail).of_type(:boolean).with_options(:null => false, :default =>false) }
|
25
|
+
it { should have_db_column(:critical).of_type(:boolean).with_options(:null => false, :default =>false) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'validations' do
|
30
|
+
context 'desc' do
|
31
|
+
it 'should not ba valid for a length over 8k' do
|
32
|
+
desc = SecureRandom.hex(9001) #over 9000?!
|
33
|
+
large_tag = FactoryGirl.build(:mdm_tag, :desc => desc)
|
34
|
+
large_tag.should_not be_valid
|
35
|
+
large_tag.errors[:desc].should include('desc must be less than 8k.')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'name' do
|
40
|
+
it 'must be present' do
|
41
|
+
nameless_tag = FactoryGirl.build(:mdm_tag, :name => nil)
|
42
|
+
nameless_tag.should_not be_valid
|
43
|
+
nameless_tag.errors[:name].should include("can't be blank")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'may only contain alphanumerics, dot, dashes, and underscores' do
|
47
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => 'A.1-B_2')
|
48
|
+
mytag.should be_valid
|
49
|
+
#Test for various bad inputs we should never allow
|
50
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => "A'1")
|
51
|
+
mytag.should_not be_valid
|
52
|
+
mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
|
53
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => "A;1")
|
54
|
+
mytag.should_not be_valid
|
55
|
+
mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
|
56
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => "A%1")
|
57
|
+
mytag.should_not be_valid
|
58
|
+
mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
|
59
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => "A=1")
|
60
|
+
mytag.should_not be_valid
|
61
|
+
mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
|
62
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => "#A1")
|
63
|
+
mytag.should_not be_valid
|
64
|
+
mytag.errors[:name].should include('must be alphanumeric, dots, dashes, or underscores')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'callbacks' do
|
70
|
+
context 'before_destroy' do
|
71
|
+
it 'should call #cleanup_hosts' do
|
72
|
+
mytag = FactoryGirl.create(:mdm_tag)
|
73
|
+
mytag.should_receive(:cleanup_hosts)
|
74
|
+
mytag.destroy
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should destroy the host_tag joins' do
|
78
|
+
mytag = FactoryGirl.create(:mdm_tag)
|
79
|
+
FactoryGirl.create(:mdm_host_tag, :tag => mytag)
|
80
|
+
Mdm::HostTag.should_receive(:delete_all).with("tag_id = #{mytag.id}")
|
81
|
+
mytag.destroy
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'instance methods' do
|
87
|
+
context '#to_s' do
|
88
|
+
it 'should return the name of the tag as a string' do
|
89
|
+
mytag = FactoryGirl.build(:mdm_tag, :name => 'mytag')
|
90
|
+
mytag.to_s.should == 'mytag'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
4
95
|
context 'factories' do
|
5
96
|
context 'mdm_tag' do
|
6
97
|
subject(:mdm_tag) do
|
@@ -10,4 +101,17 @@ describe Mdm::Tag do
|
|
10
101
|
it { should be_valid }
|
11
102
|
end
|
12
103
|
end
|
104
|
+
|
105
|
+
context '#destroy' do
|
106
|
+
it 'should successfully destroy the object' do
|
107
|
+
tag = FactoryGirl.create(:mdm_tag)
|
108
|
+
expect {
|
109
|
+
tag.destroy
|
110
|
+
}.to_not raise_error
|
111
|
+
expect {
|
112
|
+
tag.reload
|
113
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
13
117
|
end
|
@@ -2,6 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mdm::TaskCred do
|
4
4
|
|
5
|
+
context 'factory' do
|
6
|
+
it 'should be valid' do
|
7
|
+
task_cred = FactoryGirl.build(:mdm_task_cred)
|
8
|
+
task_cred.should be_valid
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'database' do
|
13
|
+
|
14
|
+
context 'timestamps'do
|
15
|
+
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
16
|
+
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'columns' do
|
20
|
+
it { should have_db_column(:task_id).of_type(:integer).with_options(:null => false) }
|
21
|
+
it { should have_db_column(:cred_id).of_type(:integer).with_options(:null => false) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context '#destroy' do
|
26
|
+
it 'should successfully destroy the object' do
|
27
|
+
task_cred = FactoryGirl.create(:mdm_task_cred)
|
28
|
+
expect {
|
29
|
+
task_cred.destroy
|
30
|
+
}.to_not raise_error
|
31
|
+
expect {
|
32
|
+
task_cred.reload
|
33
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
5
37
|
context "Associations" do
|
6
38
|
it { should belong_to(:task).class_name('Mdm::Task') }
|
7
39
|
it { should belong_to(:cred).class_name('Mdm::Cred') }
|
@@ -1,6 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mdm::TaskHost do
|
4
|
+
|
5
|
+
context 'factory' do
|
6
|
+
it 'should be valid' do
|
7
|
+
task_host = FactoryGirl.build(:mdm_task_host)
|
8
|
+
task_host.should be_valid
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'database' do
|
13
|
+
|
14
|
+
context 'timestamps'do
|
15
|
+
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
16
|
+
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'columns' do
|
20
|
+
it { should have_db_column(:task_id).of_type(:integer).with_options(:null => false) }
|
21
|
+
it { should have_db_column(:host_id).of_type(:integer).with_options(:null => false) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context '#destroy' do
|
26
|
+
it 'should successfully destroy the object' do
|
27
|
+
task_host = FactoryGirl.create(:mdm_task_host)
|
28
|
+
expect {
|
29
|
+
task_host.destroy
|
30
|
+
}.to_not raise_error
|
31
|
+
expect {
|
32
|
+
task_host.reload
|
33
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
4
37
|
context "Associations" do
|
5
38
|
it { should belong_to(:task).class_name('Mdm::Task') }
|
6
39
|
it { should belong_to(:host).class_name('Mdm::Host') }
|
@@ -1,6 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mdm::TaskService do
|
4
|
+
|
5
|
+
context 'factory' do
|
6
|
+
it 'should be valid' do
|
7
|
+
task_service = FactoryGirl.build(:mdm_task_service)
|
8
|
+
task_service.should be_valid
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'database' do
|
13
|
+
|
14
|
+
context 'timestamps'do
|
15
|
+
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
16
|
+
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'columns' do
|
20
|
+
it { should have_db_column(:task_id).of_type(:integer).with_options(:null => false) }
|
21
|
+
it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context '#destroy' do
|
26
|
+
it 'should successfully destroy the object' do
|
27
|
+
task_service = FactoryGirl.create(:mdm_task_service)
|
28
|
+
expect {
|
29
|
+
task_service.destroy
|
30
|
+
}.to_not raise_error
|
31
|
+
expect {
|
32
|
+
task_service.reload
|
33
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
4
37
|
context "Associations" do
|
5
38
|
it { should belong_to(:task).class_name('Mdm::Task') }
|
6
39
|
it { should belong_to(:service).class_name('Mdm::Service') }
|
@@ -2,8 +2,50 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mdm::Task do
|
4
4
|
|
5
|
-
context
|
5
|
+
context 'factory' do
|
6
|
+
it 'should be valid' do
|
7
|
+
task = FactoryGirl.build(:mdm_task)
|
8
|
+
task.should be_valid
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'database' do
|
13
|
+
|
14
|
+
context 'timestamps'do
|
15
|
+
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
16
|
+
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
17
|
+
it { should have_db_column(:completed_at).of_type(:datetime) }
|
18
|
+
end
|
19
|
+
|
20
|
+
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(:created_by).of_type(:string) }
|
23
|
+
it { should have_db_column(:module).of_type(:string) }
|
24
|
+
it { should have_db_column(:path).of_type(:string) }
|
25
|
+
it { should have_db_column(:info).of_type(:string) }
|
26
|
+
it { should have_db_column(:description).of_type(:string) }
|
27
|
+
it { should have_db_column(:progress).of_type(:integer) }
|
28
|
+
it { should have_db_column(:options).of_type(:text) }
|
29
|
+
it { should have_db_column(:error).of_type(:text) }
|
30
|
+
it { should have_db_column(:result).of_type(:text) }
|
31
|
+
it { should have_db_column(:module_uuid).of_type(:string) }
|
32
|
+
it { should have_db_column(:settings).of_type(:binary) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context '#destroy' do
|
37
|
+
it 'should successfully destroy the object' do
|
38
|
+
task = FactoryGirl.create(:mdm_task)
|
39
|
+
expect {
|
40
|
+
task.destroy
|
41
|
+
}.to_not raise_error
|
42
|
+
expect {
|
43
|
+
task.reload
|
44
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
45
|
+
end
|
46
|
+
end
|
6
47
|
|
48
|
+
context "Associations" do
|
7
49
|
it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
|
8
50
|
it { should have_many(:creds).class_name('Mdm::Cred').through(:task_creds) }
|
9
51
|
it { should have_many(:task_hosts).class_name('Mdm::TaskHost').dependent(:destroy) }
|
@@ -14,12 +56,24 @@ describe Mdm::Task do
|
|
14
56
|
it { should have_many(:reports).class_name('Mdm::Report')}
|
15
57
|
end
|
16
58
|
|
17
|
-
context
|
18
|
-
|
19
|
-
|
20
|
-
|
59
|
+
context 'scopes' do
|
60
|
+
context "running" do
|
61
|
+
it "should exclude completed tasks" do
|
62
|
+
task = FactoryGirl.create(:mdm_task, :completed_at => Time.now)
|
63
|
+
Mdm::Task.running.should_not include(task)
|
64
|
+
end
|
21
65
|
end
|
66
|
+
end
|
22
67
|
|
68
|
+
context 'callbacks' do
|
69
|
+
context 'before_destroy' do
|
70
|
+
it 'should call #delete_file' do
|
71
|
+
task = FactoryGirl.create(:mdm_task)
|
72
|
+
task.should_receive(:delete_file)
|
73
|
+
task.destroy
|
74
|
+
end
|
75
|
+
end
|
23
76
|
end
|
24
77
|
|
78
|
+
|
25
79
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::User do
|
4
|
+
|
5
|
+
context 'associations' do
|
6
|
+
it { should have_many(:owned_workspaces).class_name('Mdm::Workspace') }
|
7
|
+
it { should have_many(:tags).class_name('Mdm::Tag') }
|
8
|
+
it { should have_and_belong_to_many(:workspaces).class_name('Mdm::Workspace') }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'database' do
|
12
|
+
|
13
|
+
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) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'columns' do
|
19
|
+
it { should have_db_column(:username).of_type(:string) }
|
20
|
+
it { should have_db_column(:crypted_password).of_type(:string) }
|
21
|
+
it { should have_db_column(:password_salt).of_type(:string) }
|
22
|
+
it { should have_db_column(:persistence_token).of_type(:string) }
|
23
|
+
it { should have_db_column(:fullname).of_type(:string) }
|
24
|
+
it { should have_db_column(:email).of_type(:string) }
|
25
|
+
it { should have_db_column(:phone).of_type(:string) }
|
26
|
+
it { should have_db_column(:company).of_type(:string) }
|
27
|
+
it { should have_db_column(:prefs).of_type(:string) }
|
28
|
+
it { should have_db_column(:admin).of_type(:boolean).with_options(:null => false, :default =>true) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'factory' do
|
33
|
+
it 'should be valid' do
|
34
|
+
user = FactoryGirl.build(:mdm_user)
|
35
|
+
user.should be_valid
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context '#destroy' do
|
40
|
+
it 'should successfully destroy the object' do
|
41
|
+
user = FactoryGirl.create(:mdm_user)
|
42
|
+
expect {
|
43
|
+
user.destroy
|
44
|
+
}.to_not raise_error
|
45
|
+
expect {
|
46
|
+
user.reload
|
47
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::VulnAttempt do
|
4
|
+
|
5
|
+
context 'association' do
|
6
|
+
it { should belong_to(:vuln).class_name('Mdm::Vuln') }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'database' do
|
10
|
+
|
11
|
+
context 'timestamps'do
|
12
|
+
it { should have_db_column(:attempted_at).of_type(:datetime) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'columns' do
|
16
|
+
it { should have_db_column(:vuln_id).of_type(:integer) }
|
17
|
+
it { should have_db_column(:exploited).of_type(:boolean) }
|
18
|
+
it { should have_db_column(:fail_reason).of_type(:string) }
|
19
|
+
it { should have_db_column(:username).of_type(:string) }
|
20
|
+
it { should have_db_column(:module).of_type(:text) }
|
21
|
+
it { should have_db_column(:session_id).of_type(:integer) }
|
22
|
+
it { should have_db_column(:loot_id).of_type(:integer) }
|
23
|
+
it { should have_db_column(:fail_detail).of_type(:text) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'validations' do
|
28
|
+
it 'should require a vuln_id' do
|
29
|
+
orphan_detail = FactoryGirl.build(:mdm_vuln_detail, :vuln => nil)
|
30
|
+
orphan_detail.should_not be_valid
|
31
|
+
orphan_detail.errors[:vuln_id].should include("can't be blank")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'factory' do
|
36
|
+
it 'should be valid' do
|
37
|
+
vuln_attempt = FactoryGirl.build(:mdm_vuln_attempt)
|
38
|
+
vuln_attempt.should be_valid
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context '#destroy' do
|
43
|
+
it 'should successfully destroy the object' do
|
44
|
+
vuln_attempt = FactoryGirl.create(:mdm_vuln_attempt)
|
45
|
+
expect {
|
46
|
+
vuln_attempt.destroy
|
47
|
+
}.to_not raise_error
|
48
|
+
expect {
|
49
|
+
vuln_attempt.reload
|
50
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::VulnDetail do
|
4
|
+
|
5
|
+
context 'association' do
|
6
|
+
it { should belong_to(:vuln).class_name('Mdm::Vuln') }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'database' do
|
10
|
+
|
11
|
+
context 'timestamps'do
|
12
|
+
it { should have_db_column(:nx_published).of_type(:datetime) }
|
13
|
+
it { should have_db_column(:nx_added).of_type(:datetime) }
|
14
|
+
it { should have_db_column(:nx_modified).of_type(:datetime) }
|
15
|
+
it { should have_db_column(:nx_vulnerable_since).of_type(:datetime) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'columns' do
|
19
|
+
it { should have_db_column(:vuln_id).of_type(:integer)}
|
20
|
+
it { should have_db_column(:cvss_score).of_type(:float) }
|
21
|
+
it { should have_db_column(:cvss_vector).of_type(:string) }
|
22
|
+
it { should have_db_column(:title).of_type(:string) }
|
23
|
+
it { should have_db_column(:description).of_type(:text) }
|
24
|
+
it { should have_db_column(:solution).of_type(:text) }
|
25
|
+
it { should have_db_column(:proof).of_type(:binary) }
|
26
|
+
it { should have_db_column(:nx_console_id).of_type(:integer) }
|
27
|
+
it { should have_db_column(:nx_device_id).of_type(:integer) }
|
28
|
+
it { should have_db_column(:nx_severity).of_type(:float) }
|
29
|
+
it { should have_db_column(:nx_pci_severity).of_type(:float) }
|
30
|
+
it { should have_db_column(:nx_tags).of_type(:text) }
|
31
|
+
it { should have_db_column(:nx_vuln_status).of_type(:text) }
|
32
|
+
it { should have_db_column(:nx_proof_key).of_type(:text) }
|
33
|
+
it { should have_db_column(:src).of_type(:string) }
|
34
|
+
it { should have_db_column(:nx_scan_id).of_type(:integer) }
|
35
|
+
it { should have_db_column(:nx_pci_compliance_status).of_type(:string) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'validations' do
|
40
|
+
it 'should require a vuln_id' do
|
41
|
+
orphan_detail = FactoryGirl.build(:mdm_vuln_detail, :vuln => nil)
|
42
|
+
orphan_detail.should_not be_valid
|
43
|
+
orphan_detail.errors[:vuln_id].should include("can't be blank")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'factory' do
|
48
|
+
it 'should be valid' do
|
49
|
+
vuln_detail = FactoryGirl.build(:mdm_vuln_detail)
|
50
|
+
vuln_detail.should be_valid
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context '#destroy' do
|
55
|
+
it 'should successfully destroy the object' do
|
56
|
+
vuln_detail = FactoryGirl.create(:mdm_vuln_detail)
|
57
|
+
expect {
|
58
|
+
vuln_detail.destroy
|
59
|
+
}.to_not raise_error
|
60
|
+
expect {
|
61
|
+
vuln_detail.reload
|
62
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|