metasploit-credential 0.14.5 → 0.14.6

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metasploit/credential/exporter/core.rb +2 -2
  3. data/lib/metasploit/credential/exporter/pwdump.rb +2 -2
  4. data/lib/metasploit/credential/migrator.rb +1 -1
  5. data/lib/metasploit/credential/version.rb +1 -3
  6. data/spec/dummy/config/database.yml +13 -11
  7. data/spec/dummy/db/structure.sql +1 -0
  8. data/spec/lib/metasploit/credential/creation_spec.rb +6 -8
  9. data/spec/lib/metasploit/credential/exporter/core_spec.rb +100 -85
  10. data/spec/lib/metasploit/credential/exporter/pwdump_spec.rb +14 -16
  11. data/spec/lib/metasploit/credential/importer/core_spec.rb +10 -12
  12. data/spec/lib/metasploit/credential/importer/multi_spec.rb +4 -6
  13. data/spec/lib/metasploit/credential/importer/pwdump_spec.rb +11 -13
  14. data/spec/lib/metasploit/credential/importer/zip_spec.rb +5 -7
  15. data/spec/lib/metasploit/credential/migrator_spec.rb +13 -13
  16. data/spec/lib/metasploit/credential/version_spec.rb +3 -5
  17. data/spec/lib/metasploit/credential_spec.rb +1 -3
  18. data/spec/models/mdm/service_spec.rb +3 -5
  19. data/spec/models/mdm/session_spec.rb +2 -4
  20. data/spec/models/mdm/task_spec.rb +4 -6
  21. data/spec/models/mdm/user_spec.rb +2 -4
  22. data/spec/models/mdm/workspace_spec.rb +2 -4
  23. data/spec/models/metasploit/credential/blank_username_spec.rb +5 -7
  24. data/spec/models/metasploit/credential/core_spec.rb +43 -45
  25. data/spec/models/metasploit/credential/login/status_spec.rb +19 -21
  26. data/spec/models/metasploit/credential/login_spec.rb +36 -38
  27. data/spec/models/metasploit/credential/nonreplayable_hash_spec.rb +3 -5
  28. data/spec/models/metasploit/credential/ntlm_hash_spec.rb +13 -15
  29. data/spec/models/metasploit/credential/origin/cracked_password_spec.rb +5 -7
  30. data/spec/models/metasploit/credential/origin/import_spec.rb +8 -10
  31. data/spec/models/metasploit/credential/origin/manual_spec.rb +7 -9
  32. data/spec/models/metasploit/credential/origin/service_spec.rb +10 -12
  33. data/spec/models/metasploit/credential/origin/session_spec.rb +11 -13
  34. data/spec/models/metasploit/credential/password_hash_spec.rb +4 -6
  35. data/spec/models/metasploit/credential/password_spec.rb +3 -5
  36. data/spec/models/metasploit/credential/postgres_md5_spec.rb +4 -6
  37. data/spec/models/metasploit/credential/private_spec.rb +8 -10
  38. data/spec/models/metasploit/credential/public_spec.rb +5 -7
  39. data/spec/models/metasploit/credential/realm_spec.rb +14 -16
  40. data/spec/models/metasploit/credential/replayable_hash_spec.rb +3 -5
  41. data/spec/models/metasploit/credential/ssh_key_spec.rb +15 -17
  42. data/spec/models/metasploit/credential/username_spec.rb +6 -8
  43. data/spec/models/metasploit_data_models/search/visitor/relation_spec.rb +1 -3
  44. data/spec/spec_helper.rb +83 -18
  45. data/spec/support/shared/contexts/mdm/workspace.rb +1 -1
  46. data/spec/support/shared/examples/core_validations.rb +117 -42
  47. data/spec/support/shared/examples/single_table_inheritance_database_columns.rb +2 -2
  48. data/spec/support/shared/examples/timestamp_database_column.rb +2 -2
  49. metadata +9 -9
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Service do
1
+ RSpec.describe Mdm::Service, type: :model do
4
2
  context 'associations' do
5
- it { should have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Service').dependent(:destroy) }
6
- it { should have_many(:logins).class_name('Metasploit::Credential::Login').dependent(:destroy) }
3
+ it { is_expected.to have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Service').dependent(:destroy) }
4
+ it { is_expected.to have_many(:logins).class_name('Metasploit::Credential::Login').dependent(:destroy) }
7
5
  end
8
6
  end
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Session do
1
+ RSpec.describe Mdm::Session, type: :model do
4
2
  context 'associations' do
5
- it { should have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Session').dependent(:destroy) }
3
+ it { is_expected.to have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Session').dependent(:destroy) }
6
4
  end
7
5
  end
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Task do
1
+ RSpec.describe Mdm::Task, type: :model do
4
2
  context 'associations' do
5
- it { should have_many(:import_credential_origins).class_name('Metasploit::Credential::Origin::Import').dependent(:destroy) }
6
- it { should have_and_belong_to_many(:credential_cores).class_name('Metasploit::Credential::Core') }
7
- it { should have_and_belong_to_many(:credential_logins).class_name('Metasploit::Credential::Login') }
3
+ it { is_expected.to have_many(:import_credential_origins).class_name('Metasploit::Credential::Origin::Import').dependent(:destroy) }
4
+ it { is_expected.to have_and_belong_to_many(:credential_cores).class_name('Metasploit::Credential::Core') }
5
+ it { is_expected.to have_and_belong_to_many(:credential_logins).class_name('Metasploit::Credential::Login') }
8
6
  end
9
7
  end
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::User do
1
+ RSpec.describe Mdm::User, type: :model do
4
2
  context 'associations' do
5
- it { should have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Manual').dependent(:destroy) }
3
+ it { is_expected.to have_many(:credential_origins).class_name('Metasploit::Credential::Origin::Manual').dependent(:destroy) }
6
4
  end
7
5
  end
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Workspace do
1
+ RSpec.describe Mdm::Workspace, type: :model do
4
2
  context 'associations' do
5
- it { should have_many(:core_credentials).class_name('Metasploit::Credential::Core').dependent(:destroy) }
3
+ it { is_expected.to have_many(:core_credentials).class_name('Metasploit::Credential::Core').dependent(:destroy) }
6
4
  end
7
5
  end
@@ -1,25 +1,23 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Credential::BlankUsername do
1
+ RSpec.describe Metasploit::Credential::BlankUsername, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'database' do
7
5
  context 'columns' do
8
6
  it_should_behave_like 'timestamp database columns'
9
7
 
10
- it { should have_db_column(:username).of_type(:string).with_options(null: false) }
11
- it { should have_db_column(:type).of_type(:string).with_options(null: false) }
8
+ it { is_expected.to have_db_column(:username).of_type(:string).with_options(null: false) }
9
+ it { is_expected.to have_db_column(:type).of_type(:string).with_options(null: false) }
12
10
  end
13
11
 
14
12
  context 'indices' do
15
- it { should have_db_index(:username).unique(true) }
13
+ it { is_expected.to have_db_index(:username).unique(true) }
16
14
  end
17
15
  end
18
16
 
19
17
  context 'mass assignment security' do
20
18
  it { should_not allow_mass_assignment_of(:created_at) }
21
19
  it { should_not allow_mass_assignment_of(:updated_at) }
22
- it { should allow_mass_assignment_of(:username) }
20
+ it { is_expected.to allow_mass_assignment_of(:username) }
23
21
  end
24
22
 
25
23
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  # Test plan for unique indexes and uniqueness validators
4
2
  #
5
3
  # Index | First Metasploit::Credential::Core | | | | Second Metasploit::Credential::Core | | | | Collision |
@@ -54,7 +52,7 @@ require 'spec_helper'
54
52
  # complete | non-nil | non-nil | non-nil | non-nil | different | different | different | same | FALSE |
55
53
  # complete | non-nil | non-nil | non-nil | non-nil | different | different | different | different | FALSE |
56
54
  #
57
- describe Metasploit::Credential::Core do
55
+ RSpec.describe Metasploit::Credential::Core, type: :model do
58
56
  include_context 'Mdm::Workspace'
59
57
 
60
58
  subject(:core) do
@@ -71,27 +69,27 @@ describe Metasploit::Credential::Core do
71
69
  it_should_behave_like 'Metasploit::Concern.run'
72
70
 
73
71
  context 'associations' do
74
- it { should have_and_belong_to_many(:tasks).class_name('Mdm::Task') }
75
- it { should have_many(:logins).class_name('Metasploit::Credential::Login').dependent(:destroy) }
76
- it { should belong_to(:origin) }
77
- it { should belong_to(:private).class_name('Metasploit::Credential::Private') }
78
- it { should belong_to(:public).class_name('Metasploit::Credential::Public') }
79
- it { should belong_to(:realm).class_name('Metasploit::Credential::Realm') }
80
- it { should belong_to(:workspace).class_name('Mdm::Workspace') }
72
+ it { is_expected.to have_and_belong_to_many(:tasks).class_name('Mdm::Task') }
73
+ it { is_expected.to have_many(:logins).class_name('Metasploit::Credential::Login').dependent(:destroy) }
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') }
78
+ it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
81
79
  end
82
80
 
83
81
  context 'database' do
84
82
  context 'columns' do
85
83
  context 'foreign keys' do
86
84
  context 'polymorphic origin' do
87
- it { should have_db_column(:origin_id).of_type(:integer).with_options(null: false) }
88
- it { should have_db_column(:origin_type).of_type(:string).with_options(null: false) }
85
+ it { is_expected.to have_db_column(:origin_id).of_type(:integer).with_options(null: false) }
86
+ it { is_expected.to have_db_column(:origin_type).of_type(:string).with_options(null: false) }
89
87
  end
90
88
 
91
- it { should have_db_column(:private_id).of_type(:integer).with_options(null: true) }
92
- it { should have_db_column(:public_id).of_type(:integer).with_options(null: true) }
93
- it { should have_db_column(:realm_id).of_type(:integer).with_options(null: true) }
94
- it { should have_db_column(:workspace_id).of_type(:integer).with_options(null: false) }
89
+ it { is_expected.to have_db_column(:private_id).of_type(:integer).with_options(null: true) }
90
+ it { is_expected.to have_db_column(:public_id).of_type(:integer).with_options(null: true) }
91
+ it { is_expected.to have_db_column(:realm_id).of_type(:integer).with_options(null: true) }
92
+ it { is_expected.to have_db_column(:workspace_id).of_type(:integer).with_options(null: false) }
95
93
  end
96
94
 
97
95
  it_should_behave_like 'timestamp database columns'
@@ -100,11 +98,11 @@ describe Metasploit::Credential::Core do
100
98
  context 'indices' do
101
99
  context 'foreign keys' do
102
100
 
103
- it { should have_db_index([:origin_type, :origin_id]) }
104
- it { should have_db_index(:private_id) }
105
- it { should have_db_index(:public_id) }
106
- it { should have_db_index(:realm_id) }
107
- it { should have_db_index(:workspace_id) }
101
+ it { is_expected.to have_db_index([:origin_type, :origin_id]) }
102
+ it { is_expected.to have_db_index(:private_id) }
103
+ it { is_expected.to have_db_index(:public_id) }
104
+ it { is_expected.to have_db_index(:realm_id) }
105
+ it { is_expected.to have_db_index(:workspace_id) }
108
106
 
109
107
 
110
108
  end
@@ -295,7 +293,7 @@ describe Metasploit::Credential::Core do
295
293
  metasploit_credential_core.origin
296
294
  end
297
295
 
298
- it { should be_valid }
296
+ it { is_expected.to be_valid }
299
297
 
300
298
  context 'with origin_factory' do
301
299
  subject(:metasploit_credential_core) do
@@ -310,7 +308,7 @@ describe Metasploit::Credential::Core do
310
308
  :metasploit_credential_origin_import
311
309
  end
312
310
 
313
- it { should be_valid }
311
+ it { is_expected.to be_valid }
314
312
  end
315
313
 
316
314
  context ':metasploit_credential_origin_manual' do
@@ -318,14 +316,14 @@ describe Metasploit::Credential::Core do
318
316
  :metasploit_credential_origin_manual
319
317
  end
320
318
 
321
- it { should be_valid }
319
+ it { is_expected.to be_valid }
322
320
 
323
321
  context '#origin' do
324
322
  subject(:origin) do
325
323
  metasploit_credential_core.origin
326
324
  end
327
325
 
328
- it { should be_a Metasploit::Credential::Origin::Manual }
326
+ it { is_expected.to be_a Metasploit::Credential::Origin::Manual }
329
327
  end
330
328
 
331
329
  context '#workspace' do
@@ -342,7 +340,7 @@ describe Metasploit::Credential::Core do
342
340
  :metasploit_credential_origin_service
343
341
  end
344
342
 
345
- it { should be_valid }
343
+ it { is_expected.to be_valid }
346
344
 
347
345
  context '#workspace' do
348
346
  subject(:workspace) do
@@ -361,7 +359,7 @@ describe Metasploit::Credential::Core do
361
359
  :metasploit_credential_origin_session
362
360
  end
363
361
 
364
- it { should be_valid }
362
+ it { is_expected.to be_valid }
365
363
 
366
364
  context '#workspace' do
367
365
  subject(:workspace) do
@@ -382,7 +380,7 @@ describe Metasploit::Credential::Core do
382
380
  FactoryGirl.build(:metasploit_credential_core_import)
383
381
  end
384
382
 
385
- it { should be_valid }
383
+ it { is_expected.to be_valid }
386
384
  end
387
385
 
388
386
  context 'metasploit_credential_core_manual' do
@@ -390,7 +388,7 @@ describe Metasploit::Credential::Core do
390
388
  FactoryGirl.build(:metasploit_credential_core_manual)
391
389
  end
392
390
 
393
- it { should be_valid }
391
+ it { is_expected.to be_valid }
394
392
 
395
393
  context '#workspace' do
396
394
  subject(:workspace) do
@@ -406,7 +404,7 @@ describe Metasploit::Credential::Core do
406
404
  FactoryGirl.build(:metasploit_credential_core_service)
407
405
  end
408
406
 
409
- it { should be_valid }
407
+ it { is_expected.to be_valid }
410
408
 
411
409
  context '#workspace' do
412
410
  subject(:workspace) do
@@ -429,7 +427,7 @@ describe Metasploit::Credential::Core do
429
427
  FactoryGirl.build(:metasploit_credential_core_session)
430
428
  end
431
429
 
432
- it { should be_valid }
430
+ it { is_expected.to be_valid }
433
431
 
434
432
  context '#workspace' do
435
433
  subject(:workspace) do
@@ -449,7 +447,7 @@ describe Metasploit::Credential::Core do
449
447
  end
450
448
 
451
449
  context 'validations' do
452
- it { should validate_presence_of :origin }
450
+ it { is_expected.to validate_presence_of :origin }
453
451
 
454
452
 
455
453
  context '#consistent_workspaces' do
@@ -538,7 +536,7 @@ describe Metasploit::Credential::Core do
538
536
  end
539
537
 
540
538
  context 'without #workspace in Mdm::User#workspaces' do
541
- it { should include error }
539
+ it { is_expected.to include error }
542
540
  end
543
541
  end
544
542
  end
@@ -548,7 +546,7 @@ describe Metasploit::Credential::Core do
548
546
  nil
549
547
  end
550
548
 
551
- it { should include error }
549
+ it { is_expected.to include error }
552
550
  end
553
551
  end
554
552
 
@@ -593,7 +591,7 @@ describe Metasploit::Credential::Core do
593
591
  FactoryGirl.create(:mdm_workspace)
594
592
  end
595
593
 
596
- it { should include error }
594
+ it { is_expected.to include error }
597
595
  end
598
596
  end
599
597
 
@@ -602,7 +600,7 @@ describe Metasploit::Credential::Core do
602
600
  nil
603
601
  end
604
602
 
605
- it { should include error }
603
+ it { is_expected.to include error }
606
604
  end
607
605
  end
608
606
 
@@ -611,7 +609,7 @@ describe Metasploit::Credential::Core do
611
609
  nil
612
610
  end
613
611
 
614
- it { should include error }
612
+ it { is_expected.to include error }
615
613
  end
616
614
  end
617
615
 
@@ -657,7 +655,7 @@ describe Metasploit::Credential::Core do
657
655
  FactoryGirl.create(:mdm_workspace)
658
656
  end
659
657
 
660
- it { should include error }
658
+ it { is_expected.to include error }
661
659
  end
662
660
  end
663
661
 
@@ -666,7 +664,7 @@ describe Metasploit::Credential::Core do
666
664
  nil
667
665
  end
668
666
 
669
- it { should include error }
667
+ it { is_expected.to include error }
670
668
  end
671
669
  end
672
670
 
@@ -675,7 +673,7 @@ describe Metasploit::Credential::Core do
675
673
  nil
676
674
  end
677
675
 
678
- it { should include error }
676
+ it { is_expected.to include error }
679
677
  end
680
678
  end
681
679
 
@@ -684,7 +682,7 @@ describe Metasploit::Credential::Core do
684
682
  nil
685
683
  end
686
684
 
687
- it { should include error }
685
+ it { is_expected.to include error }
688
686
  end
689
687
  end
690
688
  end
@@ -839,7 +837,7 @@ describe Metasploit::Credential::Core do
839
837
  I18n.translate!('activerecord.errors.models.metasploit/credential/core.attributes.base.public_for_ssh_key')
840
838
  end
841
839
 
842
- let(:core) do
840
+ subject(:core) do
843
841
  FactoryGirl.build(
844
842
  :metasploit_credential_core,
845
843
  private: FactoryGirl.build(:metasploit_credential_ssh_key),
@@ -847,7 +845,7 @@ describe Metasploit::Credential::Core do
847
845
  )
848
846
  end
849
847
 
850
- it { core.should be_valid }
848
+ it { is_expected.to be_valid }
851
849
 
852
850
  context "when the Public is missing" do
853
851
  before(:each) do
@@ -855,12 +853,12 @@ describe Metasploit::Credential::Core do
855
853
  end
856
854
 
857
855
  it 'should not be valid if Private is an SSHKey and Public is missing' do
858
- core.should_not be_valid
856
+ expect(core).not_to be_valid
859
857
  end
860
858
 
861
859
  it 'should show the proper error' do
862
860
  core.valid?
863
- core.errors[:base].should include(error)
861
+ expect(core.errors[:base]).to include(error)
864
862
  end
865
863
  end
866
864
 
@@ -1,18 +1,16 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Login::Status do
1
+ RSpec.describe Metasploit::Model::Login::Status, type: :model do
4
2
  context 'CONSTANTS' do
5
3
  context 'ALL' do
6
4
  subject(:all) do
7
5
  described_class::ALL
8
6
  end
9
7
 
10
- it { should include described_class::DENIED_ACCESS }
11
- it { should include described_class::DISABLED }
12
- it { should include described_class::LOCKED_OUT }
13
- it { should include described_class::SUCCESSFUL }
14
- it { should include described_class::UNABLE_TO_CONNECT }
15
- it { should include described_class::UNTRIED }
8
+ it { is_expected.to include described_class::DENIED_ACCESS }
9
+ it { is_expected.to include described_class::DISABLED }
10
+ it { is_expected.to include described_class::LOCKED_OUT }
11
+ it { is_expected.to include described_class::SUCCESSFUL }
12
+ it { is_expected.to include described_class::UNABLE_TO_CONNECT }
13
+ it { is_expected.to include described_class::UNTRIED }
16
14
  end
17
15
 
18
16
  context 'DENIED_ACCESS' do
@@ -20,8 +18,8 @@ describe Metasploit::Model::Login::Status do
20
18
  described_class::DENIED_ACCESS
21
19
  end
22
20
 
23
- it { should == 'Denied Access' }
24
- it { should be_in described_class::ALL }
21
+ it { is_expected.to eq 'Denied Access' }
22
+ it { is_expected.to be_in described_class::ALL }
25
23
  end
26
24
 
27
25
  context 'DISABLED' do
@@ -29,8 +27,8 @@ describe Metasploit::Model::Login::Status do
29
27
  described_class::DISABLED
30
28
  end
31
29
 
32
- it { should == 'Disabled' }
33
- it { should be_in described_class::ALL }
30
+ it { is_expected.to eq 'Disabled' }
31
+ it { is_expected.to be_in described_class::ALL }
34
32
  end
35
33
 
36
34
  context 'LOCKED_OUT' do
@@ -38,8 +36,8 @@ describe Metasploit::Model::Login::Status do
38
36
  described_class::LOCKED_OUT
39
37
  end
40
38
 
41
- it { should == 'Locked Out' }
42
- it { should be_in described_class::ALL }
39
+ it { is_expected.to eq 'Locked Out' }
40
+ it { is_expected.to be_in described_class::ALL }
43
41
  end
44
42
 
45
43
  context 'SUCCESSFUL' do
@@ -47,8 +45,8 @@ describe Metasploit::Model::Login::Status do
47
45
  described_class::SUCCESSFUL
48
46
  end
49
47
 
50
- it { should == 'Successful' }
51
- it { should be_in described_class::ALL }
48
+ it { is_expected.to eq 'Successful' }
49
+ it { is_expected.to be_in described_class::ALL }
52
50
  end
53
51
 
54
52
  context 'UNABLE_TO_CONNECT' do
@@ -56,8 +54,8 @@ describe Metasploit::Model::Login::Status do
56
54
  described_class::UNABLE_TO_CONNECT
57
55
  end
58
56
 
59
- it { should == 'Unable to Connect' }
60
- it { should be_in described_class::ALL }
57
+ it { is_expected.to eq 'Unable to Connect' }
58
+ it { is_expected.to be_in described_class::ALL }
61
59
  end
62
60
 
63
61
  context 'UNTRIED' do
@@ -65,8 +63,8 @@ describe Metasploit::Model::Login::Status do
65
63
  described_class::UNTRIED
66
64
  end
67
65
 
68
- it { should == 'Untried' }
69
- it { should be_in described_class::ALL }
66
+ it { is_expected.to eq 'Untried' }
67
+ it { is_expected.to be_in described_class::ALL }
70
68
  end
71
69
  end
72
70
  end