metasploit-credential 5.0.1 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b932c2f8d79211f33e2c9bd9f2a204ec7125643c947b7c12a421ee109ca1e59f
4
- data.tar.gz: fef429c0afa6ff9e3a26687f807818b8f81960c10355d30d2dc06393b307abc2
3
+ metadata.gz: f619d2601985401f78215f264a5ca6b35e30395e76e118f00fbb2a19ff0be1d6
4
+ data.tar.gz: b85fbfcc6cb48a360b0baff638f79573c307cb1e6efd81f82ed8d2eb505fc998
5
5
  SHA512:
6
- metadata.gz: 17f14fb888f0c03a0241238b9a2163e4ca4b5541d113177129039c6854571049e888770e8365eb70d372e0bee44d1a63ce8001dbf3d4b3e45332cef1ac552d17
7
- data.tar.gz: e196fb2ec75ef16e337d80fde2a589d12c86c425e63b38561624650441941d68c548b7fbd95159e4939aa6cdfffe1ea816cc44ca8fde78130b25a20cc539aaef
6
+ metadata.gz: e4b97eda489cf82ea347c190bb152aa04a33760bcfb2c77c898b82d378beadb3ad5ece4306acdc9b7c305b01a7c2ef25aed233eb46621a8e2495adb2d49b67de
7
+ data.tar.gz: 93ef61cbb0e3735e39dff2e91d21c8d28f09d0d9261150f199c38288fd5c66114966194db54a14386096b1db7b1ef735fd9c225ee8a2f9392daee646993f8526
checksums.yaml.gz.sig CHANGED
Binary file
@@ -52,6 +52,7 @@ class Metasploit::Credential::Core < ApplicationRecord
52
52
  # @return [Metasploit::Credential::Private, nil]
53
53
  belongs_to :private,
54
54
  class_name: 'Metasploit::Credential::Private',
55
+ optional: true,
55
56
  inverse_of: :cores
56
57
 
57
58
  # @!attribute public
@@ -60,6 +61,7 @@ class Metasploit::Credential::Core < ApplicationRecord
60
61
  # @return [Metasploit::Credential::Public, nil]
61
62
  belongs_to :public,
62
63
  class_name: 'Metasploit::Credential::Public',
64
+ optional: true,
63
65
  inverse_of: :cores
64
66
 
65
67
  # @!attribute realm
@@ -69,6 +71,7 @@ class Metasploit::Credential::Core < ApplicationRecord
69
71
  # @return [Metasploit::Credential::Realm, nil]
70
72
  belongs_to :realm,
71
73
  class_name: 'Metasploit::Credential::Realm',
74
+ optional: true,
72
75
  inverse_of: :cores
73
76
 
74
77
  # @!attribute workspace
@@ -205,7 +208,7 @@ class Metasploit::Credential::Core < ApplicationRecord
205
208
  scope :originating_host_id, ->(host_id) {
206
209
  where(
207
210
  Metasploit::Credential::Core[:id].in(
208
- Metasploit::Credential::Core.cores_from_host(host_id)
211
+ self.cores_from_host(host_id)
209
212
  )
210
213
  )
211
214
  }
@@ -19,6 +19,7 @@ class Metasploit::Credential::Origin::Import < ApplicationRecord
19
19
  # @return [Mdm::Task]
20
20
  belongs_to :task,
21
21
  class_name: 'Mdm::Task',
22
+ optional: true,
22
23
  inverse_of: :import_credential_origins
23
24
 
24
25
  #
@@ -110,7 +110,7 @@ class Metasploit::Credential::SSHKey < Metasploit::Credential::Private
110
110
  begin
111
111
  openssl_pkey_pkey
112
112
  rescue ArgumentError, OpenSSL::PKey::PKeyError => error
113
- errors[:data] << "#{error.class} #{error}"
113
+ errors.add(:data, "#{error.class} #{error}")
114
114
  end
115
115
  end
116
116
  end
@@ -224,7 +224,7 @@ class Metasploit::Credential::Importer::Core
224
224
  end
225
225
  if all_creds_valid
226
226
  core_opts.each do |item|
227
- if Metasploit::Credential::Core.where(public: item[:public], private: item[:private]).blank?
227
+ if Metasploit::Credential::Core.where(origin: item[:origin], workspace_id: item[:workspace_id], public: item[:public], private: item[:private]).blank?
228
228
  create_credential_core(item)
229
229
  end
230
230
  end
@@ -3,7 +3,7 @@
3
3
  module Metasploit
4
4
  module Credential
5
5
  # VERSION is managed by GemRelease
6
- VERSION = '5.0.1'
6
+ VERSION = '5.0.5'
7
7
 
8
8
  # @return [String]
9
9
  #
@@ -1,6 +1,6 @@
1
1
  development: &pgsql
2
2
  adapter: postgresql
3
- database: metasploit-credential_development2
3
+ database: metasploit-credential_development0
4
4
  username: msf
5
5
  password: pass123
6
6
  host: localhost
@@ -10,4 +10,4 @@ development: &pgsql
10
10
  min_messages: warning
11
11
  test:
12
12
  <<: *pgsql
13
- database: metasploit-credential_test2
13
+ database: metasploit-credential_test0
@@ -215,6 +215,31 @@ RSpec.describe Metasploit::Credential::Importer::Core do
215
215
  expect{core_csv_importer.import!}.to change(Metasploit::Credential::Core, :count).from(1).to(2)
216
216
  end
217
217
  end
218
+
219
+ describe "when the data in the CSV contains a duplicate from another workspace" do
220
+ let(:preexisting_cred_data) do
221
+ core_csv_importer.csv_object.gets
222
+ row = core_csv_importer.csv_object.first
223
+ core_csv_importer.csv_object.rewind
224
+ {
225
+ username: row['username'],
226
+ private_data: row['private_data'],
227
+ }
228
+ end
229
+
230
+ before(:example) do
231
+ core = Metasploit::Credential::Core.new
232
+ core.public = FactoryBot.create(:metasploit_credential_username, username: preexisting_cred_data[:username])
233
+ core.private = FactoryBot.create(:metasploit_credential_password, data: preexisting_cred_data[:private_data])
234
+ core.origin = FactoryBot.create(:metasploit_credential_origin_import)
235
+ core.workspace = FactoryBot.create(:mdm_workspace)
236
+ core.save!
237
+ end
238
+
239
+ it 'should create a new Metasploit::Credential::Core for each row in the import' do
240
+ expect{core_csv_importer.import!}.to change(Metasploit::Credential::Core, :count).from(1).to(3)
241
+ end
242
+ end
218
243
  end
219
244
  end
220
245
 
@@ -72,9 +72,9 @@ RSpec.describe Metasploit::Credential::Core, type: :model do
72
72
  it { is_expected.to have_and_belong_to_many(:tasks).class_name('Mdm::Task') }
73
73
  it { is_expected.to have_many(:logins).class_name('Metasploit::Credential::Login').dependent(:destroy) }
74
74
  it { is_expected.to belong_to(:origin) }
75
- it { is_expected.to belong_to(:private).class_name('Metasploit::Credential::Private') }
76
- it { is_expected.to belong_to(:public).class_name('Metasploit::Credential::Public') }
77
- it { is_expected.to belong_to(:realm).class_name('Metasploit::Credential::Realm') }
75
+ it { is_expected.to belong_to(:private).optional.class_name('Metasploit::Credential::Private') }
76
+ it { is_expected.to belong_to(:public).optional.class_name('Metasploit::Credential::Public') }
77
+ it { is_expected.to belong_to(:realm).optional.class_name('Metasploit::Credential::Realm') }
78
78
  it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
79
79
  end
80
80
 
@@ -3,7 +3,7 @@ RSpec.describe Metasploit::Credential::Origin::Import, type: :model do
3
3
 
4
4
  context 'associations' do
5
5
  it { is_expected.to have_many(:cores).class_name('Metasploit::Credential::Core').dependent(:destroy) }
6
- it { is_expected.to belong_to(:task).class_name('Mdm::Task') }
6
+ it { is_expected.to belong_to(:task).optional.class_name('Mdm::Task') }
7
7
  end
8
8
 
9
9
  context 'database' do
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit-credential
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2021-05-11 00:00:00.000000000 Z
96
+ date: 2021-09-27 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: metasploit-concern
metadata.gz.sig CHANGED
Binary file