metasploit_data_models 0.14.4-java → 0.15.1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,8 +14,25 @@ class Mdm::Cred < ActiveRecord::Base
14
14
  #
15
15
  # Relations
16
16
  #
17
+
18
+ # @!attribute [rw] servce
19
+ # The service this cred is for
20
+ #
21
+ # @return [Mdm::Service]
17
22
  belongs_to :service, :class_name => "Mdm::Service"
18
23
 
24
+ # @!attribute [rw] task_creds
25
+ # Details about what Tasks touched this cred
26
+ #
27
+ # @return [Array<Mdm::TaskCred>]
28
+ has_many :task_creds, :dependent => :destroy, :class_name => "Mdm::TaskCred"
29
+
30
+ # @!attribute [rw] tasks
31
+ # Tasks that touched this service
32
+ #
33
+ # @return [Array<Mdm::Task>]
34
+ has_many :tasks, :through => :task_creds
35
+
19
36
  after_create :increment_host_counter_cache
20
37
  after_destroy :decrement_host_counter_cache
21
38
 
@@ -53,6 +53,18 @@ class Mdm::Host < ActiveRecord::Base
53
53
  # Associations
54
54
  #
55
55
 
56
+ # @!attribute [rw] task_hosts
57
+ # Details about what Tasks touched this host
58
+ #
59
+ # @return [Array<Mdm::TaskHost>]
60
+ has_many :task_hosts, :dependent => :destroy, :class_name => 'Mdm::TaskHost'
61
+
62
+ # @!attribute [rw] tasks
63
+ # Tasks that touched this service
64
+ #
65
+ # @return [Array<Mdm::Task>]
66
+ has_many :tasks, :through => :task_hosts, :class_name => 'Mdm::Task'
67
+
56
68
  # @!attribute [rw] exploit_attempts
57
69
  # Attempts to run exploits against this host.
58
70
  #
@@ -11,6 +11,18 @@ class Mdm::Service < ActiveRecord::Base
11
11
  # Associations
12
12
  #
13
13
 
14
+ # @!attribute [rw] task_services
15
+ # Details about what Tasks touched this service
16
+ #
17
+ # @return [Array<Mdm::TaskService>]
18
+ has_many :task_services, :dependent => :destroy, :class_name => 'Mdm::TaskService'
19
+
20
+ # @!attribute [rw] tasks
21
+ # Tasks that touched this service
22
+ #
23
+ # @return [Array<Mdm::Task>]
24
+ has_many :tasks, :through => :task_services, :class_name => 'Mdm::Task'
25
+
14
26
  # @!attribute [rw] creds
15
27
  # Credentials gathered from this service.
16
28
  #
@@ -9,7 +9,47 @@ class Mdm::Task < ActiveRecord::Base
9
9
  # Relations
10
10
  #
11
11
 
12
- belongs_to :workspace, :class_name => "Mdm::Workspace"
12
+ # @!attribute [rw] workspace
13
+ # The Workspace the Task belongs to
14
+ #
15
+ # @return [Mdm::Workspace]
16
+ belongs_to :workspace, :class_name => "Mdm::Workspace"
17
+
18
+ # @!attribute [rw] task_creds
19
+ # Details about creds this task touched
20
+ #
21
+ # @return [Array<Mdm::TaskCred>]
22
+ has_many :task_creds, :dependent => :destroy, :class_name => 'Mdm::TaskCred'
23
+
24
+ # @!attribute [rw] creds
25
+ # Creds this task touched
26
+ #
27
+ # @return [Array<Mdm::TaskCred>]
28
+ has_many :creds, :through => :task_creds, :class_name => 'Mdm::Cred'
29
+
30
+ # @!attribute [rw] task_hosts
31
+ # Details about hosts this task touched
32
+ #
33
+ # @return [Array<Mdm::TaskHost>]
34
+ has_many :task_hosts, :dependent => :destroy, :class_name => 'Mdm::TaskHost'
35
+
36
+ # @!attribute [rw] hosts
37
+ # Hosts this task touched
38
+ #
39
+ # @return [Array<Mdm::TaskHost>
40
+ has_many :hosts, :through => :task_hosts, :class_name => 'Mdm::Host'
41
+
42
+ # @!attribute [rw] task_services
43
+ # Details about services this task touched
44
+ #
45
+ # @return [Array<Mdm::TaskService>]
46
+ has_many :task_services, :dependent => :destroy, :class_name => 'Mdm::TaskService'
47
+
48
+ # @!attribute [rw] services
49
+ # Services this task touched
50
+ #
51
+ # @return [Array<Mdm::TaskHost>
52
+ has_many :services, :through => :task_services, :class_name => 'Mdm::Service'
13
53
 
14
54
  #
15
55
  # Scopes
@@ -0,0 +1,10 @@
1
+ class Mdm::TaskCred < ActiveRecord::Base
2
+ # attr_accessible :title, :body
3
+ belongs_to :cred, :class_name => 'Mdm::Cred'
4
+ belongs_to :task, :class_name => 'Mdm::Task'
5
+
6
+ validates :cred_id,
7
+ :uniqueness => {
8
+ :scope => :task_id
9
+ }
10
+ end
@@ -0,0 +1,10 @@
1
+ class Mdm::TaskHost < ActiveRecord::Base
2
+ # attr_accessible :title, :body
3
+ belongs_to :host, :class_name => 'Mdm::Host'
4
+ belongs_to :task, :class_name => 'Mdm::Task'
5
+
6
+ validates :host_id,
7
+ :uniqueness => {
8
+ :scope => :task_id
9
+ }
10
+ end
@@ -0,0 +1,10 @@
1
+ class Mdm::TaskService < ActiveRecord::Base
2
+ # attr_accessible :title, :body
3
+ belongs_to :service, :class_name => 'Mdm::Service'
4
+ belongs_to :task, :class_name => 'Mdm::Task'
5
+
6
+ validates :service_id,
7
+ :uniqueness => {
8
+ :scope => :task_id
9
+ }
10
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaskCreds < ActiveRecord::Migration
2
+ def change
3
+ create_table :task_creds do |t|
4
+ t.references :task, :null => false
5
+ t.references :cred, :null => false
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaskHosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :task_hosts do |t|
4
+ t.references :task, :null => false
5
+ t.references :host, :null => false
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaskServices < ActiveRecord::Migration
2
+ def change
3
+ create_table :task_services do |t|
4
+ t.references :task, :null => false
5
+ t.references :service, :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.14.4'
7
+ VERSION = '0.15.1'
8
8
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::Cred do
4
+
5
+ context "Associations" do
6
+ it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
7
+ it { should have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
8
+ it { should belong_to(:service).class_name('Mdm::Service') }
9
+ end
10
+
11
+
12
+
13
+ end
@@ -44,6 +44,8 @@ describe Mdm::Host do
44
44
  it { should have_many(:host_details).class_name('Mdm::HostDetail').dependent(:destroy) }
45
45
  it { should have_many(:hosts_tags).class_name('Mdm::HostTag') }
46
46
  it { should have_many(:loots).class_name('Mdm::Loot').dependent(:destroy).order('loots.created_at DESC') }
47
+ it { should have_many(:task_hosts).class_name('Mdm::TaskHost').dependent(:destroy) }
48
+ it { should have_many(:tasks).class_name('Mdm::Task').through(:task_hosts) }
47
49
 
48
50
  context 'module_details' do
49
51
  it { should have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::Service do
4
+
5
+ context "Associations" do
6
+
7
+ it { should have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
8
+ it { should have_many(:tasks).class_name('Mdm::Task').through(:task_services) }
9
+ it { should have_many(:creds).class_name('Mdm::Cred').dependent(:destroy) }
10
+ it { should have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').dependent(:destroy) }
11
+ it { should have_many(:notes).class_name('Mdm::Note').dependent(:destroy) }
12
+ it { should have_many(:vulns).class_name('Mdm::Vuln').dependent(:destroy) }
13
+ it { should have_many(:web_sites).class_name('Mdm::WebSite').dependent(:destroy) }
14
+ it { should have_many(:web_pages).class_name('Mdm::WebPage').through(:web_sites) }
15
+ it { should have_many(:web_forms).class_name('Mdm::WebForm').through(:web_sites) }
16
+ it { should have_many(:web_vulns).class_name('Mdm::WebVuln').through(:web_sites) }
17
+ it { should belong_to(:host).class_name('Mdm::Host') }
18
+ end
19
+
20
+ context "inactive" do
21
+ it "should exclude open services" do
22
+ open_service = FactoryGirl.create(:mdm_service, :state => 'open')
23
+ Mdm::Service.inactive.should_not include(open_service)
24
+ end
25
+ end
26
+
27
+ context "with_state open" do
28
+ it "should exclude closed services" do
29
+ closed_service = FactoryGirl.create(:mdm_service, :state => 'closed')
30
+ Mdm::Service.with_state('open').should_not include(closed_service)
31
+ end
32
+ end
33
+
34
+ context "search for 'snmp'" do
35
+ it "should find only services that match" do
36
+ snmp_service = FactoryGirl.create(:mdm_service)
37
+ ftp_service = FactoryGirl.create(:mdm_service, :proto => 'ftp')
38
+ search_results = Mdm::Service.search('snmp')
39
+ search_results.should include(snmp_service)
40
+ search_results.should_not include(ftp_service)
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::TaskCred do
4
+
5
+ context "Associations" do
6
+ it { should belong_to(:task).class_name('Mdm::Task') }
7
+ it { should belong_to(:cred).class_name('Mdm::Cred') }
8
+ end
9
+
10
+ context "validations" do
11
+ it "should not allow duplicate associations" do
12
+ task = FactoryGirl.build(:mdm_task)
13
+ cred = FactoryGirl.build(:mdm_cred)
14
+ FactoryGirl.create(:mdm_task_cred, :task => task, :cred => cred)
15
+ task_cred2 = FactoryGirl.build(:mdm_task_cred, :task => task, :cred => cred)
16
+ task_cred2.should_not be_valid
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::TaskHost do
4
+ context "Associations" do
5
+ it { should belong_to(:task).class_name('Mdm::Task') }
6
+ it { should belong_to(:host).class_name('Mdm::Host') }
7
+ end
8
+
9
+ context "validations" do
10
+ it "should not allow duplicate associations" do
11
+ task = FactoryGirl.build(:mdm_task)
12
+ host = FactoryGirl.build(:mdm_host)
13
+ FactoryGirl.create(:mdm_task_host, :task => task, :host => host)
14
+ task_host2 = FactoryGirl.build(:mdm_task_host, :task => task, :host => host)
15
+ task_host2.should_not be_valid
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::TaskService do
4
+ context "Associations" do
5
+ it { should belong_to(:task).class_name('Mdm::Task') }
6
+ it { should belong_to(:service).class_name('Mdm::Service') }
7
+ end
8
+
9
+ context "validations" do
10
+ it "should not allow duplicate associations" do
11
+ task = FactoryGirl.build(:mdm_task)
12
+ service = FactoryGirl.build(:mdm_service)
13
+ FactoryGirl.create(:mdm_task_service, :task => task, :service => service)
14
+ task_service2 = FactoryGirl.build(:mdm_task_service, :task => task, :service => service)
15
+ task_service2.should_not be_valid
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::Task do
4
+
5
+ context "Associations" do
6
+
7
+ it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
8
+ it { should have_many(:creds).class_name('Mdm::Cred').through(:task_creds) }
9
+ it { should have_many(:task_hosts).class_name('Mdm::TaskHost').dependent(:destroy) }
10
+ it { should have_many(:hosts).class_name('Mdm::Host').through(:task_hosts) }
11
+ it { should have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
12
+ it { should have_many(:services).class_name('Mdm::Service').through(:task_services) }
13
+ it { should belong_to(:workspace).class_name('Mdm::Workspace') }
14
+ end
15
+
16
+ context "running" do
17
+ it "should exclude completed tasks" do
18
+ task = FactoryGirl.create(:mdm_task, :completed_at => Time.now)
19
+ Mdm::Task.running.should_not include(task)
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -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 => 20130516204810) do
14
+ ActiveRecord::Schema.define(:version => 20130522041110) do
15
15
 
16
16
  create_table "api_keys", :force => true do |t|
17
17
  t.text "token"
@@ -427,6 +427,27 @@ ActiveRecord::Schema.define(:version => 20130516204810) do
427
427
  t.datetime "updated_at", :null => false
428
428
  end
429
429
 
430
+ create_table "task_creds", :force => true do |t|
431
+ t.integer "task_id", :null => false
432
+ t.integer "cred_id", :null => false
433
+ t.datetime "created_at", :null => false
434
+ t.datetime "updated_at", :null => false
435
+ end
436
+
437
+ create_table "task_hosts", :force => true do |t|
438
+ t.integer "task_id", :null => false
439
+ t.integer "host_id", :null => false
440
+ t.datetime "created_at", :null => false
441
+ t.datetime "updated_at", :null => false
442
+ end
443
+
444
+ create_table "task_services", :force => true do |t|
445
+ t.integer "task_id", :null => false
446
+ t.integer "service_id", :null => false
447
+ t.datetime "created_at", :null => false
448
+ t.datetime "updated_at", :null => false
449
+ end
450
+
430
451
  create_table "tasks", :force => true do |t|
431
452
  t.integer "workspace_id", :default => 1, :null => false
432
453
  t.string "created_by"
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :mdm_cred, :aliases => [:cred], :class => Mdm::Cred do
3
+ #
4
+ # Associations
5
+ #
6
+ association :service, :factory => :mdm_service
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ FactoryGirl.define do
2
+ factory :mdm_task, :aliases => [:task], :class => 'Mdm::Task' do
3
+ #
4
+ # Associations
5
+ #
6
+ association :workspace, :factory => :mdm_workspace
7
+
8
+ #
9
+ # Attributes
10
+ #
11
+ created_at { Time.now }
12
+ updated_at { Time.now }
13
+
14
+
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mdm_task_cred, :class => 'Mdm::TaskCred' do
5
+
6
+ association :task, :factory => :mdm_task
7
+ association :cred, :factory => :mdm_cred
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mdm_task_host, :class => 'Mdm::TaskHost' do
5
+
6
+ association :task, :factory => :mdm_task
7
+ association :host, :factory => :mdm_host
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mdm_task_service, :class => 'Mdm::TaskService' do
5
+ association :task, :factory => :mdm_task
6
+ association :service, :factory => :mdm_service
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.14.4
5
+ version: 0.15.1
6
6
  platform: java
7
7
  authors:
8
8
  - Samuel Huckins
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-05-21 00:00:00.000000000 Z
15
+ date: 2013-05-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -210,6 +210,9 @@ files:
210
210
  - app/models/mdm/session_event.rb
211
211
  - app/models/mdm/tag.rb
212
212
  - app/models/mdm/task.rb
213
+ - app/models/mdm/task_cred.rb
214
+ - app/models/mdm/task_host.rb
215
+ - app/models/mdm/task_service.rb
213
216
  - app/models/mdm/user.rb
214
217
  - app/models/mdm/vuln.rb
215
218
  - app/models/mdm/vuln_attempt.rb
@@ -325,6 +328,9 @@ files:
325
328
  - db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
326
329
  - db/migrate/20130515172727_valid_mdm_web_vuln_params.rb
327
330
  - db/migrate/20130516204810_making_vulns_refs_a_real_ar_model.rb
331
+ - db/migrate/20130522001343_create_task_creds.rb
332
+ - db/migrate/20130522032517_create_task_hosts.rb
333
+ - db/migrate/20130522041110_create_task_services.rb
328
334
  - lib/mdm.rb
329
335
  - lib/mdm/host/operating_system_normalization.rb
330
336
  - lib/mdm/module.rb
@@ -339,6 +345,7 @@ files:
339
345
  - lib/tasks/yard.rake
340
346
  - metasploit_data_models.gemspec
341
347
  - script/rails
348
+ - spec/app/models/mdm/cred_spec.rb
342
349
  - spec/app/models/mdm/host_spec.rb
343
350
  - spec/app/models/mdm/host_tag_spec.rb
344
351
  - spec/app/models/mdm/module/action_spec.rb
@@ -350,7 +357,12 @@ files:
350
357
  - spec/app/models/mdm/module/ref_spec.rb
351
358
  - spec/app/models/mdm/module/target_spec.rb
352
359
  - spec/app/models/mdm/ref_spec.rb
360
+ - spec/app/models/mdm/service_spec.rb
353
361
  - spec/app/models/mdm/tag_spec.rb
362
+ - spec/app/models/mdm/task_creds_spec.rb
363
+ - spec/app/models/mdm/task_host_spec.rb
364
+ - spec/app/models/mdm/task_service_spec.rb
365
+ - spec/app/models/mdm/task_spec.rb
354
366
  - spec/app/models/mdm/vuln_ref_spec.rb
355
367
  - spec/app/models/mdm/vuln_spec.rb
356
368
  - spec/app/models/mdm/web_vuln_spec.rb
@@ -388,6 +400,7 @@ files:
388
400
  - spec/dummy/public/favicon.ico
389
401
  - spec/dummy/script/rails
390
402
  - spec/factories/mdm/addresses.rb
403
+ - spec/factories/mdm/creds.rb
391
404
  - spec/factories/mdm/host_tags.rb
392
405
  - spec/factories/mdm/hosts.rb
393
406
  - spec/factories/mdm/module/actions.rb
@@ -401,6 +414,10 @@ files:
401
414
  - spec/factories/mdm/refs.rb
402
415
  - spec/factories/mdm/services.rb
403
416
  - spec/factories/mdm/tags.rb
417
+ - spec/factories/mdm/task.rb
418
+ - spec/factories/mdm/task_creds.rb
419
+ - spec/factories/mdm/task_hosts.rb
420
+ - spec/factories/mdm/task_services.rb
404
421
  - spec/factories/mdm/users.rb
405
422
  - spec/factories/mdm/vuln_refs.rb
406
423
  - spec/factories/mdm/vulns.rb
@@ -444,6 +461,7 @@ signing_key:
444
461
  specification_version: 3
445
462
  summary: Database code for MSF and Metasploit Pro
446
463
  test_files:
464
+ - spec/app/models/mdm/cred_spec.rb
447
465
  - spec/app/models/mdm/host_spec.rb
448
466
  - spec/app/models/mdm/host_tag_spec.rb
449
467
  - spec/app/models/mdm/module/action_spec.rb
@@ -455,7 +473,12 @@ test_files:
455
473
  - spec/app/models/mdm/module/ref_spec.rb
456
474
  - spec/app/models/mdm/module/target_spec.rb
457
475
  - spec/app/models/mdm/ref_spec.rb
476
+ - spec/app/models/mdm/service_spec.rb
458
477
  - spec/app/models/mdm/tag_spec.rb
478
+ - spec/app/models/mdm/task_creds_spec.rb
479
+ - spec/app/models/mdm/task_host_spec.rb
480
+ - spec/app/models/mdm/task_service_spec.rb
481
+ - spec/app/models/mdm/task_spec.rb
459
482
  - spec/app/models/mdm/vuln_ref_spec.rb
460
483
  - spec/app/models/mdm/vuln_spec.rb
461
484
  - spec/app/models/mdm/web_vuln_spec.rb
@@ -493,6 +516,7 @@ test_files:
493
516
  - spec/dummy/public/favicon.ico
494
517
  - spec/dummy/script/rails
495
518
  - spec/factories/mdm/addresses.rb
519
+ - spec/factories/mdm/creds.rb
496
520
  - spec/factories/mdm/host_tags.rb
497
521
  - spec/factories/mdm/hosts.rb
498
522
  - spec/factories/mdm/module/actions.rb
@@ -506,6 +530,10 @@ test_files:
506
530
  - spec/factories/mdm/refs.rb
507
531
  - spec/factories/mdm/services.rb
508
532
  - spec/factories/mdm/tags.rb
533
+ - spec/factories/mdm/task.rb
534
+ - spec/factories/mdm/task_creds.rb
535
+ - spec/factories/mdm/task_hosts.rb
536
+ - spec/factories/mdm/task_services.rb
509
537
  - spec/factories/mdm/users.rb
510
538
  - spec/factories/mdm/vuln_refs.rb
511
539
  - spec/factories/mdm/vulns.rb