metasploit-credential 0.14.7 → 0.14.8

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/CONTRIBUTING.md +41 -9
  3. data/lib/metasploit/credential/exporter/core.rb +2 -2
  4. data/lib/metasploit/credential/exporter/pwdump.rb +2 -2
  5. data/lib/metasploit/credential/migrator.rb +1 -1
  6. data/lib/metasploit/credential/version.rb +12 -21
  7. data/spec/dummy/db/structure.sql +0 -1
  8. data/spec/lib/metasploit/credential/creation_spec.rb +8 -6
  9. data/spec/lib/metasploit/credential/exporter/core_spec.rb +85 -100
  10. data/spec/lib/metasploit/credential/exporter/pwdump_spec.rb +16 -14
  11. data/spec/lib/metasploit/credential/importer/core_spec.rb +12 -10
  12. data/spec/lib/metasploit/credential/importer/multi_spec.rb +6 -4
  13. data/spec/lib/metasploit/credential/importer/pwdump_spec.rb +13 -11
  14. data/spec/lib/metasploit/credential/importer/zip_spec.rb +7 -5
  15. data/spec/lib/metasploit/credential/migrator_spec.rb +13 -13
  16. data/spec/lib/metasploit/credential/version_spec.rb +141 -3
  17. data/spec/lib/metasploit/credential_spec.rb +15 -4
  18. data/spec/models/mdm/service_spec.rb +5 -3
  19. data/spec/models/mdm/session_spec.rb +4 -2
  20. data/spec/models/mdm/task_spec.rb +6 -4
  21. data/spec/models/mdm/user_spec.rb +4 -2
  22. data/spec/models/mdm/workspace_spec.rb +4 -2
  23. data/spec/models/metasploit/credential/blank_username_spec.rb +7 -5
  24. data/spec/models/metasploit/credential/core_spec.rb +45 -43
  25. data/spec/models/metasploit/credential/login/status_spec.rb +21 -19
  26. data/spec/models/metasploit/credential/login_spec.rb +38 -36
  27. data/spec/models/metasploit/credential/nonreplayable_hash_spec.rb +5 -3
  28. data/spec/models/metasploit/credential/ntlm_hash_spec.rb +15 -13
  29. data/spec/models/metasploit/credential/origin/cracked_password_spec.rb +7 -5
  30. data/spec/models/metasploit/credential/origin/import_spec.rb +10 -8
  31. data/spec/models/metasploit/credential/origin/manual_spec.rb +9 -7
  32. data/spec/models/metasploit/credential/origin/service_spec.rb +12 -10
  33. data/spec/models/metasploit/credential/origin/session_spec.rb +13 -11
  34. data/spec/models/metasploit/credential/password_hash_spec.rb +6 -4
  35. data/spec/models/metasploit/credential/password_spec.rb +5 -3
  36. data/spec/models/metasploit/credential/postgres_md5_spec.rb +6 -4
  37. data/spec/models/metasploit/credential/private_spec.rb +10 -8
  38. data/spec/models/metasploit/credential/public_spec.rb +7 -5
  39. data/spec/models/metasploit/credential/realm_spec.rb +16 -14
  40. data/spec/models/metasploit/credential/replayable_hash_spec.rb +5 -3
  41. data/spec/models/metasploit/credential/ssh_key_spec.rb +17 -15
  42. data/spec/models/metasploit/credential/username_spec.rb +8 -6
  43. data/spec/models/metasploit_data_models/search/visitor/relation_spec.rb +3 -1
  44. data/spec/spec_helper.rb +25 -95
  45. data/spec/support/shared/contexts/mdm/workspace.rb +1 -1
  46. data/spec/support/shared/examples/core_validations.rb +42 -117
  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 +8 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa144979c299b0a5f2106efdcf0a27ce27a6238c
4
- data.tar.gz: 798207915ad34014125264ed3852ae34d38bbcc3
3
+ metadata.gz: 895352ea1fdface54872f23f7ef803a5733cd3c2
4
+ data.tar.gz: ff8bb3e6f773ec263c99459fe8618db96fa66855
5
5
  SHA512:
6
- metadata.gz: 9fc16422c984eb40a14b9eec56297590b8c4a5309acdca87ddb240f6151f68c45606988a3ddfe8488fc074f28a69ed06627493712f6f8241d79fc57e044ba529
7
- data.tar.gz: b84875b6fb285621d6171e3cc7b9cdb502e10d79d497305651e1e3f43d0e2bccc349892fe8db23847310452b3ed027c10565c100fb0762042350d04fece97a4d
6
+ metadata.gz: f13f43bae66ba9283939559732ffef33303215e06146ee78ccb0ba14fb1c8d7b1cc3f9be1fe424ba519ef499cab9d666ac877cb30ff17b19d1183b13d54962a7
7
+ data.tar.gz: fa0396f86e9f469da28eb4875c57f70719d1b0aa177cde5bc06b69848b53438b80414ed10b4522ead6c732a1b2ea53778f11769259b8a703e158851b7e162bf5
@@ -25,9 +25,9 @@ issue tracking software.
25
25
 
26
26
  ### `PRERELEASE`
27
27
 
28
- 1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit/credential/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
28
+ 1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit/credential/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
29
29
  ```
30
- # The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version number.
30
+ # The prerelease version, scoped to the {PATCH} version number.
31
31
  PRERELEASE = '<SUMMARY>'
32
32
  ```
33
33
  2. `rake spec`
@@ -36,7 +36,7 @@ PRERELEASE = '<SUMMARY>'
36
36
 
37
37
  ### Your changes
38
38
 
39
- Make your changes or however many commits you like, committing each with `git commit`.
39
+ Make your changes or however many commits you like, commiting each with `git commit`.
40
40
 
41
41
  ### Pre-Pull Request Testing
42
42
 
@@ -45,12 +45,12 @@ Make your changes or however many commits you like, committing each with `git co
45
45
 
46
46
  ### Push
47
47
 
48
- Push your branch to your fork on github: `git push TYPE/ISSUE/SUMMARY`
48
+ Push your branch to your fork on gitub: `git push push TYPE/ISSUE/SUMMARY`
49
49
 
50
50
  ### Pull Request
51
51
 
52
52
  * [Create new Pull Request](https://github.com/rapid7/metasploit-credential/compare/)
53
- * Add a Verification Steps to the description comment
53
+ * Add a Verification Steps comment
54
54
 
55
55
  ```
56
56
  # Verification Steps
@@ -61,7 +61,6 @@ Push your branch to your fork on github: `git push TYPE/ISSUE/SUMMARY`
61
61
  - [ ] `rake spec`
62
62
  - [ ] VERIFY no failures
63
63
  ```
64
-
65
64
  You should also include at least one scenario to manually check the changes outside of specs.
66
65
 
67
66
  * Add a Post-merge Steps comment
@@ -106,7 +105,7 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
106
105
  - [ ] Change `PRERELEASE` from `SOURCE_SUMMARY` to `DESTINATION_SUMMARY` to match the branch (DESTINATION) summary (DESTINATION_SUMMARY)
107
106
 
108
107
  ## Gem build
109
- - [ ] gem build metasploit-credential.gemspec
108
+ - [ ] gem build *.gemspec
110
109
  - [ ] VERIFY the prerelease suffix has change on the gem.
111
110
 
112
111
  ## RSpec
@@ -118,5 +117,38 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
118
117
  - [ ] `git push origin DESTINATION`
119
118
  ```
120
119
 
121
- To update the [CHANGELOG.md](CHANGELOG.md) with the merged changes or release the merged code see
122
- [RELEASING.md](RELEASING.md)
120
+ * Add a 'Release Steps' comment
121
+
122
+ The 'Release Steps' are a reminder to the reviewer of the Pull Request of how to release the gem.
123
+
124
+ ```
125
+ # Release
126
+
127
+ Complete these steps on DESTINATION
128
+
129
+ ## `VERSION`
130
+
131
+ ### Compatible changes
132
+
133
+ If your change are compatible with the previous branch's API, then increment [`PATCH`](lib/metasploit/credential/version.rb).
134
+
135
+ ### Incompatible changes
136
+
137
+ If your changes are incompatible with the previous branch's API, then increment [`MINOR`](lib/metasploit/credential/version.rb) and reset [`PATCH`](lib/metasploit/credential/version.rb) to `0`.
138
+
139
+ - [ ] Following the rules for [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html), update [`MINOR`](lib/metasploit/credential/version.rb) and [`PATCH`](lib/metasploit/credential/version.rb) and commit the changes.
140
+
141
+ ## MRI Ruby
142
+ - [ ] `rvm use ruby-2.1@metasploit_data_models`
143
+ - [ ] `rm Gemfile.lock`
144
+ - [ ] `bundle install`
145
+ - [ ] `rake release`
146
+ ```
147
+
148
+ ### Downstream dependencies
149
+
150
+ When releasing new versions, the following projects may need to be updated:
151
+
152
+ * [metasploit-framework](https://github.com/rapid7/metasploit-framework)
153
+ * [metasploit-pro-ui](https://github.com/rapid7/pro/tree/master/ui)
154
+ * [metasploit-pro-engine](https://github.com/rapid7/pro/tree/master/engine)
@@ -49,10 +49,10 @@ class Metasploit::Credential::Exporter::Core
49
49
  # Attributes
50
50
  #
51
51
 
52
- # @!attribute [rw] export_data
52
+ # @!attribute export_data
53
53
  # Holds the raw information from the database before it is formatted into the {#data} attribute
54
54
  # @return [Array]
55
- attr_writer :export_data
55
+ attr_accessor :export_data
56
56
 
57
57
  # @!attribute finalized_zip_file
58
58
  # The final output artifacts, zipped
@@ -70,10 +70,10 @@ class Metasploit::Credential::Exporter::Pwdump
70
70
  # Attributes
71
71
  #
72
72
 
73
- # @!attribute [rw] logins
73
+ # @!attribute logins
74
74
  # Holds the raw information from the database before it is formatted into the {#data} attribute
75
75
  # @return [Array<Metasploit::Credential::Login>]
76
- attr_writer :logins
76
+ attr_accessor :logins
77
77
 
78
78
 
79
79
  #
@@ -104,7 +104,7 @@ class Metasploit::Credential::Migrator
104
104
  # @return [String]
105
105
  def key_data_from_file(path)
106
106
  # Sometimes we will set the :pass attribute to a file path containing the key
107
- if File.exist?(path)
107
+ if File.exists?(path)
108
108
  File.read(path)
109
109
  # In other cases we store the entire SSH key directly in the :pass attribute
110
110
  elsif Metasploit::Credential::SSHKey.new(data: path).private?
@@ -4,26 +4,20 @@ module Metasploit
4
4
  module Credential
5
5
  # Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
6
6
  module Version
7
- #
8
- # CONSTANTS
9
- #
10
-
11
7
  # The major version number.
12
8
  MAJOR = 0
13
9
  # The minor version number, scoped to the {MAJOR} version number.
14
10
  MINOR = 14
15
- # The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
16
- PATCH = 7
11
+ # The patch number, scoped to the {MAJOR} and {MINOR} version number.
12
+ PATCH = 8
13
+ # The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version number.
14
+ # PRERELEASE =
17
15
 
18
- # The full version string, including the {Metasploit::Credential::Version::MAJOR},
19
- # {Metasploit::Credential::Version::MINOR}, {Metasploit::Credential::Version::PATCH}, and optionally, the
20
- # `Metasploit::Credential::Version::PRERELEASE` in the
16
+ # The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
21
17
  # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
22
18
  #
23
- # @return [String] '{Metasploit::Credential::Version::MAJOR}.{Metasploit::Credential::Version::MINOR}.{Metasploit::Credential::Version::PATCH}'
24
- # on master.
25
- # '{Metasploit::Credential::Version::MAJOR}.{Metasploit::Credential::Version::MINOR}.{Metasploit::Credential::Version::PATCH}-PRERELEASE'
26
- # on any branch other than master.
19
+ # @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
20
+ # other than master.
27
21
  def self.full
28
22
  version = "#{MAJOR}.#{MINOR}.#{PATCH}"
29
23
 
@@ -34,23 +28,20 @@ module Metasploit
34
28
  version
35
29
  end
36
30
 
37
- # The full gem version string, including the {Metasploit::Credential::Version::MAJOR},
38
- # {Metasploit::Credential::Version::MINOR}, {Metasploit::Credential::Version::PATCH}, and optionally, the
39
- # `Metasploit::Credential::Version::PRERELEASE` in the
31
+ # The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
40
32
  # {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
41
33
  #
42
- # @return [String] '{Metasploit::Credential::Version::MAJOR}.{Metasploit::Credential::Version::MINOR}.{Metasploit::Credential::Version::PATCH}'
43
- # on master. '{Metasploit::Credential::Version::MAJOR}.{Metasploit::Credential::Version::MINOR}.{Metasploit::Credential::Version::PATCH}.PRERELEASE'
44
- # on any branch other than master.
34
+ # @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
35
+ # other than master.
45
36
  def self.gem
46
37
  full.gsub('-', '.pre.')
47
38
  end
48
39
  end
49
40
 
50
- # (see Version.gem)
41
+ # @see Version.gem
51
42
  GEM_VERSION = Version.gem
52
43
 
53
- # (see Version.full)
44
+ # @see Version.full
54
45
  VERSION = Version.full
55
46
  end
56
47
  end
@@ -3,7 +3,6 @@
3
3
  --
4
4
 
5
5
  SET statement_timeout = 0;
6
- SET lock_timeout = 0;
7
6
  SET client_encoding = 'UTF8';
8
7
  SET standard_conforming_strings = on;
9
8
  SET check_function_bodies = false;
@@ -1,4 +1,6 @@
1
- RSpec.describe Metasploit::Credential::Creation do
1
+ require 'spec_helper'
2
+
3
+ describe Metasploit::Credential::Creation do
2
4
  include_context 'Mdm::Workspace'
3
5
  let(:dummy_class) {
4
6
  Class.new do
@@ -40,7 +42,7 @@ RSpec.describe Metasploit::Credential::Creation do
40
42
 
41
43
  it 'replicates realm in new credential' do
42
44
  expect {
43
- test_object.create_cracked_credential(
45
+ core = test_object.create_cracked_credential(
44
46
  core_id: old_core.id,
45
47
  workspace_id: workspace.id,
46
48
  username: public.username,
@@ -158,7 +160,7 @@ RSpec.describe Metasploit::Credential::Creation do
158
160
 
159
161
  it 'should create an Mdm::Service in state "open"' do
160
162
  service = test_object.create_credential_service opts
161
- expect(service.state).to eq("open")
163
+ service.state.should == "open"
162
164
  end
163
165
  end
164
166
 
@@ -481,7 +483,7 @@ RSpec.describe Metasploit::Credential::Creation do
481
483
  task_id: task.id
482
484
  }
483
485
  core = test_object.create_credential(opts)
484
- expect(core.tasks).to include(task)
486
+ core.tasks.should include(task)
485
487
  end
486
488
 
487
489
  end
@@ -524,7 +526,7 @@ RSpec.describe Metasploit::Credential::Creation do
524
526
  task_id: task.id
525
527
  }
526
528
  core = test_object.create_credential_core(opts)
527
- expect(core.tasks).to include(task)
529
+ core.tasks.should include(task)
528
530
  end
529
531
 
530
532
  end
@@ -561,7 +563,7 @@ RSpec.describe Metasploit::Credential::Creation do
561
563
  status: Metasploit::Model::Login::Status::SUCCESSFUL,
562
564
  }
563
565
  login = test_object.create_credential_login(login_data)
564
- expect(login.tasks).to include(task)
566
+ login.tasks.should include(task)
565
567
 
566
568
  end
567
569
 
@@ -1,4 +1,6 @@
1
- RSpec.describe Metasploit::Credential::Exporter::Core do
1
+ require 'spec_helper'
2
+
3
+ describe Metasploit::Credential::Exporter::Core do
2
4
  include_context 'Mdm::Workspace'
3
5
  include_context 'export objects'
4
6
 
@@ -22,19 +24,19 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
22
24
  end
23
25
 
24
26
  it 'should be in LOGIN_MODE by default' do
25
- expect(core_exporter.mode).to eq(Metasploit::Credential::Exporter::Core::LOGIN_MODE)
27
+ core_exporter.mode.should == Metasploit::Credential::Exporter::Core::LOGIN_MODE
26
28
  end
27
29
  end
28
30
 
29
31
  describe "#export!" do
30
32
  it 'should create the zipfile' do
31
33
  core_exporter.export!
32
- expect(File.exists?(core_exporter.output_zipfile_path)).to eq(true)
34
+ File.exists?(core_exporter.output_zipfile_path).should be_true
33
35
  end
34
36
 
35
37
  it 'should output to a directory whose name contains the standardized identifier' do
36
38
  core_exporter.export!
37
- expect(core_exporter.output_final_directory_path).to include(Metasploit::Credential::Exporter::Core::CREDS_DUMP_FILE_IDENTIFIER)
39
+ core_exporter.output_final_directory_path.should include(Metasploit::Credential::Exporter::Core::CREDS_DUMP_FILE_IDENTIFIER)
38
40
  end
39
41
  end
40
42
 
@@ -44,14 +46,14 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
44
46
  describe "when the argument is a Core" do
45
47
  it 'should be formed from the Public#username and the Private#id' do
46
48
  key_path = core_exporter.path_for_key(core)
47
- expect(Pathname.new(key_path).basename.to_s).to eq(key_path_basename_string)
49
+ Pathname.new(key_path).basename.to_s.should == key_path_basename_string
48
50
  end
49
51
  end
50
52
 
51
53
  describe "when the argument is a Login" do
52
54
  it 'should be formed from the Public#username and the Private#id' do
53
55
  key_path = core_exporter.path_for_key(login)
54
- expect(Pathname.new(key_path).basename.to_s).to eq(key_path_basename_string)
56
+ Pathname.new(key_path).basename.to_s.should == key_path_basename_string
55
57
  end
56
58
  end
57
59
  end
@@ -60,27 +62,20 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
60
62
  let(:result_hash) { core_exporter.line_for_core(core) }
61
63
 
62
64
  it 'should produce values in the proper order' do
63
- expect(result_hash.values).to eq(
64
- [
65
- core.public.username,
66
- core.private.type,
67
- core.private.data,
68
- core.realm.key,
69
- core.realm.value
70
- ]
71
- )
65
+ result_hash.values.should == [core.public.username, core.private.type,
66
+ core.private.data, core.realm.key, core.realm.value]
72
67
  end
73
68
 
74
69
  it 'should produce a hash with the public username' do
75
- expect(result_hash[:username]).to eq(core.public.username)
70
+ result_hash[:username].should == core.public.username
76
71
  end
77
72
 
78
73
  it 'should produce a hash with the private data' do
79
- expect(result_hash[:private_data]).to eq(core.private.data)
74
+ result_hash[:private_data].should == core.private.data
80
75
  end
81
76
 
82
77
  it 'should produce a hash with the name of the private type' do
83
- expect(result_hash[:private_type]).to eq(core.private.type)
78
+ result_hash[:private_type].should == core.private.type
84
79
  end
85
80
  end
86
81
 
@@ -89,94 +84,84 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
89
84
  let(:result_hash) { core_exporter.line_for_login(login) }
90
85
 
91
86
  it 'should produce values in the proper order' do
92
- expect(result_hash.values).to eq(
93
- [
94
- core.public.username,
95
- core.private.type,
96
- core.private.data,
97
- core.realm.key,
98
- core.realm.value,
99
- login.service.host.address,
100
- login.service.port,
101
- login.service.name,
102
- login.service.proto,
103
- login.status,
104
- login.access_level,
105
- login.last_attempted_at
106
- ]
107
- )
87
+ result_hash.values.should == [core.public.username, core.private.type,
88
+ core.private.data, core.realm.key, core.realm.value,
89
+ login.service.host.address, login.service.port,
90
+ login.service.name, login.service.proto,
91
+ login.status, login.access_level, login.last_attempted_at
92
+ ]
108
93
  end
109
94
 
110
95
  it 'should produce a hash with the service host address' do
111
- expect(result_hash[:host_address]).to eq(login.service.host.address)
96
+ result_hash[:host_address].should == login.service.host.address
112
97
  end
113
98
 
114
99
  it 'should produce a hash with the service port' do
115
- expect(result_hash[:service_port]).to eq(login.service.port)
100
+ result_hash[:service_port].should == login.service.port
116
101
  end
117
102
 
118
103
  it 'should produce a hash with the service name' do
119
- expect(result_hash[:service_name]).to eq(login.service.name)
104
+ result_hash[:service_name].should == login.service.name
120
105
  end
121
106
 
122
107
  it 'should produce a hash with the service protocol' do
123
- expect(result_hash[:service_protocol]).to eq(login.service.proto)
108
+ result_hash[:service_protocol].should == login.service.proto
124
109
  end
125
110
 
126
111
  it 'should produce a hash with the login status' do
127
- expect(result_hash[:status]).to eq(login.status)
112
+ result_hash[:status].should == login.status
128
113
  end
129
114
 
130
115
  it 'should produce a hash with the login access_level' do
131
- expect(result_hash[:access_level]).to eq(login.access_level)
116
+ result_hash[:access_level].should == login.access_level
132
117
  end
133
118
 
134
119
  it 'should produce a hash with the login last_attempted_at' do
135
- expect(result_hash[:last_attempted_at]).to eq(login.last_attempted_at)
120
+ result_hash[:last_attempted_at].should == login.last_attempted_at
136
121
  end
137
122
 
138
123
  it 'should produce a hash with the public information' do
139
- expect(result_hash[:username]).to eq(login.core.public.username)
124
+ result_hash[:username].should == login.core.public.username
140
125
  end
141
126
 
142
127
  it 'should produce a hash with the private data' do
143
- expect(result_hash[:private_data]).to eq(login.core.private.data)
128
+ result_hash[:private_data].should == login.core.private.data
144
129
  end
145
130
 
146
131
  it 'should produce a hash with the demodulized name of the private type' do
147
- expect(result_hash[:private_type]).to eq(login.core.private.type)
132
+ result_hash[:private_type].should == login.core.private.type
148
133
  end
149
134
  end
150
135
 
151
136
  describe "#output" do
152
137
  it 'should be a writable File' do
153
138
  file_stat = core_exporter.output.stat
154
- expect(file_stat).to be_writable
139
+ file_stat.should be_writable
155
140
  end
156
141
 
157
142
  it 'should not be opened in binmode' do
158
- expect(core_exporter.output).not_to be_binmode
143
+ core_exporter.output.should_not be_binmode
159
144
  end
160
145
  end
161
146
 
162
147
  describe "#output_directory_path" do
163
148
  it 'should be in the platform-agnostic temp directory' do
164
- expect(core_exporter.output_final_directory_path).to include(Dir.tmpdir)
149
+ core_exporter.output_final_directory_path.should include(Dir.tmpdir)
165
150
  end
166
151
 
167
152
  it 'should have the set export prefix' do
168
- expect(core_exporter.output_final_directory_path).to include(Metasploit::Credential::Exporter::Core::TEMP_ZIP_PATH_PREFIX)
153
+ core_exporter.output_final_directory_path.should include(Metasploit::Credential::Exporter::Core::TEMP_ZIP_PATH_PREFIX)
169
154
  end
170
155
 
171
156
  describe "uniqueness for export" do
172
157
  let(:path_fragment){ "export-#{Time.now.to_s}" }
173
158
 
174
159
  before(:each) do
175
- allow(core_exporter).to receive(:output_final_subdirectory_name).and_return(path_fragment)
160
+ core_exporter.stub(:output_final_subdirectory_name).and_return(path_fragment)
176
161
  end
177
162
 
178
163
  it 'should include a special time-stamped directory to contain the export data being staged' do
179
- expect(core_exporter.output_final_directory_path).to include(core_exporter.output_final_subdirectory_name)
164
+ core_exporter.output_final_directory_path.should include(core_exporter.output_final_subdirectory_name)
180
165
  end
181
166
  end
182
167
  end
@@ -184,44 +169,44 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
184
169
  describe "#data" do
185
170
  describe "in LOGIN_MODE" do
186
171
  before(:each) do
187
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
172
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
188
173
  end
189
174
 
190
175
  describe "when whitelist_ids is present" do
191
176
  before(:each) do
192
- allow(core_exporter).to receive(:whitelist_ids).and_return([login1.id])
177
+ core_exporter.stub(:whitelist_ids).and_return([login1.id])
193
178
  end
194
179
 
195
180
  it 'should contain only those objects whose IDs are in the whitelist' do
196
- expect(core_exporter.data).not_to include(login2)
181
+ core_exporter.data.should_not include(login2)
197
182
  end
198
183
  end
199
184
 
200
185
  describe "when whitelist_ids is blank" do
201
186
  it 'should be the same as #export_data' do
202
- expect(core_exporter.data).to eq(core_exporter.export_data)
187
+ core_exporter.data.should == core_exporter.export_data
203
188
  end
204
189
  end
205
190
  end
206
191
 
207
192
  describe "in CORE_MODE" do
208
193
  before(:each) do
209
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
194
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
210
195
  end
211
196
 
212
197
  describe "when whitelist_ids is present" do
213
198
  before(:each) do
214
- allow(core_exporter).to receive(:whitelist_ids).and_return([core1.id])
199
+ core_exporter.stub(:whitelist_ids).and_return([core1.id])
215
200
  end
216
201
 
217
202
  it 'should contain only those objects whose IDs are in the whitelist' do
218
- expect(core_exporter.data).not_to include(core2)
203
+ core_exporter.data.should_not include(core2)
219
204
  end
220
205
  end
221
206
 
222
207
  describe "when whitelist_ids is blank" do
223
208
  it 'should be the same as #export_data' do
224
- expect(core_exporter.data).to eq(core_exporter.export_data)
209
+ core_exporter.data.should == core_exporter.export_data
225
210
  end
226
211
  end
227
212
  end
@@ -230,22 +215,22 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
230
215
  describe "#export_data" do
231
216
  describe "in CORE_MODE" do
232
217
  before(:each) do
233
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
218
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
234
219
  end
235
220
 
236
221
  it 'should grab data using the proper scope' do
237
- expect(Metasploit::Credential::Core).to receive(:workspace_id).with(core_exporter.workspace.id)
222
+ Metasploit::Credential::Core.should_receive(:workspace_id).with(core_exporter.workspace.id)
238
223
  core_exporter.export_data
239
224
  end
240
225
  end
241
226
 
242
227
  describe "in LOGIN_MODE" do
243
228
  before(:each) do
244
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
229
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
245
230
  end
246
231
 
247
232
  it 'should grab data using the proper scope' do
248
- expect(Metasploit::Credential::Login).to receive(:in_workspace_including_hosts_and_services).with(core_exporter.workspace)
233
+ Metasploit::Credential::Login.should_receive(:in_workspace_including_hosts_and_services).with(core_exporter.workspace)
249
234
  core_exporter.export_data
250
235
  end
251
236
  end
@@ -255,7 +240,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
255
240
  describe "#render_manifest_and_output_keys" do
256
241
  describe "in CORE_MODE" do
257
242
  before(:each) do
258
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
243
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
259
244
  core_exporter.render_manifest_output_and_keys
260
245
  path = core_exporter.output_final_directory_path + '/' + Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME
261
246
 
@@ -275,34 +260,34 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
275
260
  end
276
261
 
277
262
  it 'should contain the Public#username for all Core objects' do
278
- expect(@core_publics).to include(core1.public.username)
279
- expect(@core_publics).to include(core2.public.username)
263
+ @core_publics.should include(core1.public.username)
264
+ @core_publics.should include(core2.public.username)
280
265
  end
281
266
 
282
267
  it 'should contain the Private#type for all Core objects' do
283
- expect(@core_private_types).to include(core1.private.type)
284
- expect(@core_private_types).to include(core2.private.type)
268
+ @core_private_types.should include(core1.private.type)
269
+ @core_private_types.should include(core2.private.type)
285
270
  end
286
271
 
287
272
  it 'should contain the Private#data for all Core objects' do
288
- expect(@core_private_data).to include(core1.private.data)
289
- expect(@core_private_data).to include(core2.private.data)
273
+ @core_private_data.should include(core1.private.data)
274
+ @core_private_data.should include(core2.private.data)
290
275
  end
291
276
 
292
277
  it 'should contain the Realm#key for all Core objects' do
293
- expect(@core_realm_keys).to include(core1.realm.key)
294
- expect(@core_realm_keys).to include(core2.realm.key)
278
+ @core_realm_keys.should include(core1.realm.key)
279
+ @core_realm_keys.should include(core2.realm.key)
295
280
  end
296
281
 
297
282
  it 'should contain the Realm#value for all Core objects' do
298
- expect(@core_realm_values).to include(core1.realm.value)
299
- expect(@core_realm_values).to include(core2.realm.value)
283
+ @core_realm_values.should include(core1.realm.value)
284
+ @core_realm_values.should include(core2.realm.value)
300
285
  end
301
286
  end
302
287
 
303
288
  describe "in LOGIN_MODE" do
304
289
  before(:each) do
305
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
290
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
306
291
  core_exporter.render_manifest_output_and_keys
307
292
  path = core_exporter.output_final_directory_path + '/' + Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME
308
293
 
@@ -331,48 +316,48 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
331
316
 
332
317
 
333
318
  it 'should contain the Public#username for all Login objects' do
334
- expect(@login_publics).to include(login1.core.public.username)
335
- expect(@login_publics).to include(login2.core.public.username)
319
+ @login_publics.should include(login1.core.public.username)
320
+ @login_publics.should include(login2.core.public.username)
336
321
  end
337
322
 
338
323
  it 'should contain the Private#type for all Login objects' do
339
- expect(@login_private_types).to include(login1.core.private.type)
340
- expect(@login_private_types).to include(login2.core.private.type)
324
+ @login_private_types.should include(login1.core.private.type)
325
+ @login_private_types.should include(login2.core.private.type)
341
326
  end
342
327
 
343
328
  it 'should contain the Private#data for all Login objects' do
344
- expect(@login_private_data).to include(login1.core.private.data)
345
- expect(@login_private_data).to include(login2.core.private.data)
329
+ @login_private_data.should include(login1.core.private.data)
330
+ @login_private_data.should include(login2.core.private.data)
346
331
  end
347
332
 
348
333
  it 'should contain the Realm#key for all Login objects' do
349
- expect(@login_realm_keys).to include(login1.core.realm.key)
350
- expect(@login_realm_keys).to include(login2.core.realm.key)
334
+ @login_realm_keys.should include(login1.core.realm.key)
335
+ @login_realm_keys.should include(login2.core.realm.key)
351
336
  end
352
337
 
353
338
  it 'should contain the Realm#value for all Login objects' do
354
- expect(@login_realm_values).to include(login1.core.realm.value)
355
- expect(@login_realm_values).to include(login2.core.realm.value)
339
+ @login_realm_values.should include(login1.core.realm.value)
340
+ @login_realm_values.should include(login2.core.realm.value)
356
341
  end
357
342
 
358
343
  it 'should contain the associated Mdm::Host#address for all Login objects' do
359
- expect(@login_host_addresses).to include(login1.service.host.address)
360
- expect(@login_host_addresses).to include(login2.service.host.address)
344
+ @login_host_addresses.should include(login1.service.host.address)
345
+ @login_host_addresses.should include(login2.service.host.address)
361
346
  end
362
347
 
363
348
  it 'should contain the associated Mdm::Service#port (stringified) for all Login objects' do
364
- expect(@login_service_ports).to include(login1.service.port.to_s)
365
- expect(@login_service_ports).to include(login2.service.port.to_s)
349
+ @login_service_ports.should include(login1.service.port.to_s)
350
+ @login_service_ports.should include(login2.service.port.to_s)
366
351
  end
367
352
 
368
353
  it 'should contain the associated Mdm::Service#name for all Login objects' do
369
- expect(@login_service_names).to include(login1.service.name)
370
- expect(@login_service_names).to include(login2.service.name)
354
+ @login_service_names.should include(login1.service.name)
355
+ @login_service_names.should include(login2.service.name)
371
356
  end
372
357
 
373
358
  it 'should contain the associated Mdm::Service#proto for all Login objects' do
374
- expect(@login_service_protocols).to include(login1.service.proto)
375
- expect(@login_service_protocols).to include(login2.service.proto)
359
+ @login_service_protocols.should include(login1.service.proto)
360
+ @login_service_protocols.should include(login2.service.proto)
376
361
  end
377
362
  end
378
363
  end
@@ -380,7 +365,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
380
365
  describe "#render_zip" do
381
366
  describe "when there are no SSH keys in the dataset" do
382
367
  before(:each) do
383
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
368
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
384
369
  core_exporter.render_manifest_output_and_keys
385
370
  core_exporter.render_zip
386
371
  end
@@ -390,7 +375,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
390
375
  Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
391
376
  manifest_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME).first
392
377
  end
393
- expect(manifest_entry).not_to be_blank
378
+ manifest_entry.should_not be_blank
394
379
  end
395
380
 
396
381
  it 'should not contain a keys directory' do
@@ -398,7 +383,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
398
383
  Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
399
384
  keys_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME).first
400
385
  end
401
- expect(keys_entry).to be_blank
386
+ keys_entry.should be_blank
402
387
  end
403
388
  end
404
389
 
@@ -411,7 +396,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
411
396
  workspace: workspace)}
412
397
 
413
398
  before(:each) do
414
- allow(core_exporter).to receive(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
399
+ core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
415
400
  core_exporter.render_manifest_output_and_keys
416
401
  core_exporter.render_zip
417
402
  end
@@ -421,7 +406,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
421
406
  Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
422
407
  manifest_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME).first
423
408
  end
424
- expect(manifest_entry).not_to be_blank
409
+ manifest_entry.should_not be_blank
425
410
  end
426
411
 
427
412
  it 'should contain a keys directory' do
@@ -429,7 +414,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
429
414
  Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
430
415
  keys_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME).first
431
416
  end
432
- expect(keys_entry).not_to be_blank
417
+ keys_entry.should_not be_blank
433
418
  end
434
419
 
435
420
  describe "the keys directory" do
@@ -441,12 +426,12 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
441
426
  end
442
427
 
443
428
  it 'should contain a key for each SSH private in the export' do
444
- expect(@key_entries.size).to eq(core_exporter.data[:core].select{ |d| d.private.type == Metasploit::Credential::SSHKey.name }.size)
429
+ @key_entries.size.should == core_exporter.data[:core].select{ |d| d.private.type == Metasploit::Credential::SSHKey.name }.size
445
430
  end
446
431
 
447
432
  it 'should contain key files named with Public#username and Private#id for each Core that uses an SSHKey' do
448
433
  key_names = @key_entries.map{ |e| e.to_s.gsub("#{Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME}/", '') }
449
- expect(key_names).to include("#{core_with_key.public.username}-#{core_with_key.private.id}")
434
+ key_names.should include("#{core_with_key.public.username}-#{core_with_key.private.id}")
450
435
  end
451
436
 
452
437
  end