metasploit_data_models 0.16.0-java → 0.16.1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,6 +33,18 @@ class Mdm::Session < ActiveRecord::Base
33
33
  # @return [Mdm::Workspace]
34
34
  has_one :workspace, :through => :host, :class_name => 'Mdm::Workspace'
35
35
 
36
+ # @!attribute [rw] task_sessions
37
+ # Details about sessions this task touched
38
+ #
39
+ # @return [Array<Mdm::TaskSession>]
40
+ has_many :task_sessions, :dependent => :destroy, :class_name => 'Mdm::TaskSession'
41
+
42
+ # @!attribute [rw] task
43
+ # Session this task touched
44
+ #
45
+ # @return [Mdm::Session]
46
+ has_many :tasks, :through => :task_sessions, :class_name => 'Mdm::Task'
47
+
36
48
  #
37
49
  # Attributes
38
50
  #
@@ -24,7 +24,7 @@ class Mdm::Task < ActiveRecord::Base
24
24
  # @!attribute [rw] creds
25
25
  # Creds this task touched
26
26
  #
27
- # @return [Array<Mdm::TaskCred>]
27
+ # @return [Array<Mdm::Cred>]
28
28
  has_many :creds, :through => :task_creds, :class_name => 'Mdm::Cred'
29
29
 
30
30
  # @!attribute [rw] task_hosts
@@ -36,7 +36,7 @@ class Mdm::Task < ActiveRecord::Base
36
36
  # @!attribute [rw] hosts
37
37
  # Hosts this task touched
38
38
  #
39
- # @return [Array<Mdm::TaskHost>
39
+ # @return [Array<Mdm::Host>
40
40
  has_many :hosts, :through => :task_hosts, :class_name => 'Mdm::Host'
41
41
 
42
42
  # @!attribute [rw] task_services
@@ -48,9 +48,22 @@ class Mdm::Task < ActiveRecord::Base
48
48
  # @!attribute [rw] services
49
49
  # Services this task touched
50
50
  #
51
- # @return [Array<Mdm::TaskHost>
51
+ # @return [Array<Mdm::Service>
52
52
  has_many :services, :through => :task_services, :class_name => 'Mdm::Service'
53
53
 
54
+ # @!attribute [rw] task_sessions
55
+ # Details about sessions this task touched
56
+ #
57
+ # @return [Array<Mdm::TaskSession>]
58
+ has_many :task_sessions, :dependent => :destroy, :class_name => 'Mdm::TaskSession'
59
+
60
+ # @!attribute [rw] sessions
61
+ # Session this task touched
62
+ #
63
+ # @return [Array<Mdm::Session>
64
+ has_many :sessions, :through => :task_sessions, :class_name => 'Mdm::Session'
65
+
66
+
54
67
  has_many :reports, :class_name => 'Mdm::Report'
55
68
 
56
69
  #
@@ -0,0 +1,9 @@
1
+ class Mdm::TaskSession < ActiveRecord::Base
2
+ belongs_to :session, :class_name => 'Mdm::Session'
3
+ belongs_to :task, :class_name => 'Mdm::Task'
4
+
5
+ validates :session_id,
6
+ :uniqueness => {
7
+ :scope => :task_id
8
+ }
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaskSessions < ActiveRecord::Migration
2
+ def change
3
+ create_table :task_sessions do |t|
4
+ t.references :task, :null => false
5
+ t.references :session, :null => false
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -4,5 +4,5 @@ module MetasploitDataModels
4
4
  # metasploit-framework/data/sql/migrate to db/migrate in this project, not all models have specs that verify the
5
5
  # migrations (with have_db_column and have_db_index) and certain models may not be shared between metasploit-framework
6
6
  # and pro, so models may be removed in the future. Because of the unstable API the version should remain below 1.0.0
7
- VERSION = '0.16.0'
7
+ VERSION = '0.16.1'
8
8
  end
@@ -42,11 +42,13 @@ describe Mdm::Session do
42
42
  end
43
43
  end
44
44
 
45
- context 'asscoiations' do
45
+ context 'associations' do
46
46
  it { should belong_to(:host).class_name('Mdm::Host') }
47
47
  it { should have_many(:events).class_name('Mdm::SessionEvent').dependent(:delete_all) }
48
48
  it { should have_many(:routes).class_name('Mdm::Route').dependent(:delete_all) }
49
49
  it { should have_one(:workspace).class_name('Mdm::Workspace').through(:host) }
50
+ it { should have_many(:task_sessions).class_name('Mdm::TaskSession').dependent(:destroy)}
51
+ it { should have_many(:tasks).class_name('Mdm::Task').through(:task_sessions)}
50
52
  end
51
53
 
52
54
  context 'scopes' do
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::TaskSession do
4
+
5
+ context 'factory' do
6
+ it 'should be valid' do
7
+ task_session = FactoryGirl.build(:mdm_task_session)
8
+ task_session.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(:session_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_session = FactoryGirl.create(:mdm_task_session)
28
+ expect {
29
+ task_session.destroy
30
+ }.to_not raise_error
31
+ expect {
32
+ task_session.reload
33
+ }.to raise_error(ActiveRecord::RecordNotFound)
34
+ end
35
+ end
36
+
37
+ context "validations" do
38
+ it "should not allow duplicate associations" do
39
+ task = FactoryGirl.build(:mdm_task)
40
+ session = FactoryGirl.build(:mdm_session)
41
+ FactoryGirl.create(:mdm_task_session, :task => task, :session => session)
42
+ task_session2 = FactoryGirl.build(:mdm_task_session, :task => task, :session => session)
43
+ task_session2.should_not be_valid
44
+ end
45
+ end
46
+
47
+ end
@@ -48,12 +48,15 @@ describe Mdm::Task do
48
48
  context "Associations" do
49
49
  it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
50
50
  it { should have_many(:creds).class_name('Mdm::Cred').through(:task_creds) }
51
+ it { should have_many(:task_sessions).class_name('Mdm::TaskSession').dependent(:destroy) }
52
+ it { should have_many(:sessions).class_name('Mdm::Session').through(:task_sessions) }
51
53
  it { should have_many(:task_hosts).class_name('Mdm::TaskHost').dependent(:destroy) }
52
54
  it { should have_many(:hosts).class_name('Mdm::Host').through(:task_hosts) }
53
55
  it { should have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
54
56
  it { should have_many(:services).class_name('Mdm::Service').through(:task_services) }
55
57
  it { should belong_to(:workspace).class_name('Mdm::Workspace') }
56
58
  it { should have_many(:reports).class_name('Mdm::Report')}
59
+
57
60
  end
58
61
 
59
62
  context 'scopes' do
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20130531144949) do
14
+ ActiveRecord::Schema.define(:version => 20130604145732) do
15
15
 
16
16
  create_table "api_keys", :force => true do |t|
17
17
  t.text "token"
@@ -440,6 +440,13 @@ ActiveRecord::Schema.define(:version => 20130531144949) do
440
440
  t.datetime "updated_at", :null => false
441
441
  end
442
442
 
443
+ create_table "task_sessions", :force => true do |t|
444
+ t.integer "task_id", :null => false
445
+ t.integer "session_id", :null => false
446
+ t.datetime "created_at", :null => false
447
+ t.datetime "updated_at", :null => false
448
+ end
449
+
443
450
  create_table "tasks", :force => true do |t|
444
451
  t.integer "workspace_id", :default => 1, :null => false
445
452
  t.string "created_by"
@@ -0,0 +1,8 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mdm_task_session, :class => 'Mdm::TaskSession' do
5
+ association :task, :factory => :mdm_task
6
+ association :session, :factory => :mdm_session
7
+ end
8
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.16.0
5
+ version: 0.16.1
6
6
  platform: java
7
7
  authors:
8
8
  - Samuel Huckins
@@ -212,6 +212,7 @@ files:
212
212
  - app/models/mdm/task_cred.rb
213
213
  - app/models/mdm/task_host.rb
214
214
  - app/models/mdm/task_service.rb
215
+ - app/models/mdm/task_session.rb
215
216
  - app/models/mdm/user.rb
216
217
  - app/models/mdm/vuln.rb
217
218
  - app/models/mdm/vuln_attempt.rb
@@ -333,6 +334,7 @@ files:
333
334
  - db/migrate/20130525015035_remove_campaign_id_from_clients.rb
334
335
  - db/migrate/20130525212420_drop_table_imported_creds.rb
335
336
  - db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb
337
+ - db/migrate/20130604145732_create_task_sessions.rb
336
338
  - lib/mdm.rb
337
339
  - lib/mdm/host/operating_system_normalization.rb
338
340
  - lib/mdm/module.rb
@@ -378,6 +380,7 @@ files:
378
380
  - spec/app/models/mdm/task_creds_spec.rb
379
381
  - spec/app/models/mdm/task_host_spec.rb
380
382
  - spec/app/models/mdm/task_service_spec.rb
383
+ - spec/app/models/mdm/task_sessions_spec.rb
381
384
  - spec/app/models/mdm/task_spec.rb
382
385
  - spec/app/models/mdm/user_spec.rb
383
386
  - spec/app/models/mdm/vuln_attempt_spec.rb
@@ -460,6 +463,7 @@ files:
460
463
  - spec/factories/mdm/task_creds.rb
461
464
  - spec/factories/mdm/task_hosts.rb
462
465
  - spec/factories/mdm/task_services.rb
466
+ - spec/factories/mdm/task_sessions.rb
463
467
  - spec/factories/mdm/users.rb
464
468
  - spec/factories/mdm/vuln_attempts.rb
465
469
  - spec/factories/mdm/vuln_details.rb
@@ -538,6 +542,7 @@ test_files:
538
542
  - spec/app/models/mdm/task_creds_spec.rb
539
543
  - spec/app/models/mdm/task_host_spec.rb
540
544
  - spec/app/models/mdm/task_service_spec.rb
545
+ - spec/app/models/mdm/task_sessions_spec.rb
541
546
  - spec/app/models/mdm/task_spec.rb
542
547
  - spec/app/models/mdm/user_spec.rb
543
548
  - spec/app/models/mdm/vuln_attempt_spec.rb
@@ -620,6 +625,7 @@ test_files:
620
625
  - spec/factories/mdm/task_creds.rb
621
626
  - spec/factories/mdm/task_hosts.rb
622
627
  - spec/factories/mdm/task_services.rb
628
+ - spec/factories/mdm/task_sessions.rb
623
629
  - spec/factories/mdm/users.rb
624
630
  - spec/factories/mdm/vuln_attempts.rb
625
631
  - spec/factories/mdm/vuln_details.rb