metasploit_data_models 6.0.13 → 6.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f076fefa48fbef835f71f863254fa30d0f7c6f6b4b7cc96eb43ea4b77bf2acc5
4
- data.tar.gz: 2418ddb5ba7a144da1eee3e3953193fdcfc1b1091a576e086d735a29b5fc4067
3
+ metadata.gz: fc3667efca0c441c45d062f28f591d4cbd2a6124931a18ebfa5d72d6008479da
4
+ data.tar.gz: 810bbcddf14719ff02ac1902a53c93205218c24ceff1897b937dff11f3c6a60c
5
5
  SHA512:
6
- metadata.gz: 211fa97f496a5092bf5b4c33a7de943274b066f828518171f33cb608a28540610a6fbd416626fee89ae831f36773b7fb83d0962a49a11a88f87f5de057c4f854
7
- data.tar.gz: f7c12e620d4e9aa6ab0763887b9e5ca6627c25da54d1e063c0c547c11c3de14979cd4b68b91969bc602b0eed6966dcabc7ab2bf4147eaec279d6afc558e2dc96
6
+ metadata.gz: d0affbc2120a9667c3261c8af222ecb3f41da1a0f1ea387a322bdc23ade75470457d975523e3577ff5c725e4171953f48073fe11a9a0e6023cb318e5e5236657
7
+ data.tar.gz: 96ea1a6c5baffaed3da5aef0739789c62a45f90fca2fedd274084ea9ea0da371e268e4006fcc1795127e8cc8f4bec0c75a637f0b22b31cf5e4c23eb9e63ab849
@@ -1,6 +1,11 @@
1
1
  # A session opened on a {#host} using an {#via_exploit exploit} and controlled through a {#via_payload payload} to
2
2
  # connect back to the local host using meterpreter or a cmd shell.
3
3
  class Mdm::Session < ApplicationRecord
4
+ extend ActiveSupport::Autoload
5
+
6
+ include Metasploit::Model::Search
7
+
8
+ require_relative 'session_tag'
4
9
 
5
10
  #
6
11
  # Associations
@@ -67,6 +72,27 @@ class Mdm::Session < ApplicationRecord
67
72
  class_name: 'Mdm::VulnAttempt',
68
73
  inverse_of: :session
69
74
 
75
+ # @!attribute sessions_tags
76
+ # A join model between {Mdm::Tag} and {Mdm::Session}. Use {#tags} to get the actual {Mdm::Tag Mdm::Tags} on this host.
77
+ #
78
+ # @todo MSP-2723
79
+ # @return [ActiveRecord::Relation<Mdm::SessionTag>]
80
+ has_many :sessions_tags,
81
+ class_name: 'Mdm::SessionTag',
82
+ dependent: :destroy,
83
+ inverse_of: :session
84
+
85
+ #
86
+ # Through sessions_tags
87
+ #
88
+
89
+ # @!attribute [r] tags
90
+ # The tags on this session. Tags are used to filter sessions.
91
+ #
92
+ # @return [ActiveRecord::Relation<Mdm::Tag>]
93
+ # @see #sessions_tags
94
+ has_many :tags, :class_name => 'Mdm::Tag', :through => :sessions_tags
95
+
70
96
  #
71
97
  # Through :host
72
98
  #
@@ -0,0 +1,51 @@
1
+ # Join model between {Mdm::Host} and {Mdm::Tag}.
2
+ class Mdm::SessionTag < ApplicationRecord
3
+ self.table_name = "sessions_tags"
4
+
5
+ #
6
+ # Associations
7
+ #
8
+
9
+ # Session with {#tag}.
10
+ #
11
+ # @todo MSP-2723
12
+ belongs_to :session,
13
+ class_name: 'Mdm::Session',
14
+ inverse_of: :sessions_tags
15
+
16
+ # Tag on {#host}.
17
+ #
18
+ # @todo MSP-2723
19
+ belongs_to :tag,
20
+ class_name: 'Mdm::Tag',
21
+ inverse_of: :sessions_tags
22
+
23
+ #
24
+ # Callbacks
25
+ #
26
+
27
+ # @see http://stackoverflow.com/a/11694704
28
+ after_destroy :destroy_orphan_tag
29
+
30
+ #
31
+ # Instance Methods
32
+ #
33
+
34
+ private
35
+
36
+ # Destroys {#tag} if it is orphaned
37
+ #
38
+ # @see http://stackoverflow.com/a/11694704
39
+ # @return [void]
40
+ def destroy_orphan_tag
41
+ # ensure fresh load of tag record
42
+ # in theory this will always return one result safe navigation is just "extra"
43
+ Mdm::Tag.where(id: tag.id).first&.destroy_if_orphaned
44
+ end
45
+
46
+ # switch back to public for load hooks
47
+ public
48
+
49
+ Metasploit::Concern.run(self)
50
+ end
51
+
@@ -12,6 +12,12 @@ class Mdm::Tag < ApplicationRecord
12
12
  dependent: :destroy,
13
13
  inverse_of: :tag
14
14
 
15
+ # Joins {#sessions} to this tag.
16
+ has_many :sessions_tags,
17
+ class_name: 'Mdm::SessionTag',
18
+ dependent: :destroy,
19
+ inverse_of: :tag
20
+
15
21
  # User that created this tag.
16
22
  belongs_to :user,
17
23
  class_name: 'Mdm::User',
@@ -0,0 +1,14 @@
1
+ class AddSessionTags < ActiveRecord::Migration[7.0]
2
+
3
+ def change
4
+ create_table :sessions_tags do |t|
5
+ t.integer :session_id
6
+ t.integer :tag_id
7
+ end
8
+ add_index :sessions_tags, [:session_id, :tag_id], unique: true
9
+ end
10
+
11
+ def self.down
12
+ drop_table :sessions_tags
13
+ end
14
+ end
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '6.0.13'
3
+ VERSION = '6.0.14'
4
4
 
5
5
  # @return [String]
6
6
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.13
4
+ version: 6.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -343,6 +343,7 @@ files:
343
343
  - app/models/mdm/service_link.rb
344
344
  - app/models/mdm/session.rb
345
345
  - app/models/mdm/session_event.rb
346
+ - app/models/mdm/session_tag.rb
346
347
  - app/models/mdm/tag.rb
347
348
  - app/models/mdm/task.rb
348
349
  - app/models/mdm/task_cred.rb
@@ -528,6 +529,7 @@ files:
528
529
  - db/migrate/20250718122714_create_service_links.rb
529
530
  - db/migrate/20250720082201_drop_service_uniqueness_index2.rb
530
531
  - db/migrate/20250721114306_remove_duplicate_services3.rb
532
+ - db/migrate/20251231162000_add_session_tags.rb
531
533
  - db/migrate/20260130124052_add_sso_status_to_user.rb
532
534
  - lib/mdm.rb
533
535
  - lib/mdm/host/operating_system_normalization.rb