metasploit-model 0.27.3 → 0.27.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +8 -8
  2. data/.rspec +1 -1
  3. data/app/models/metasploit/model/association/reflection.rb +0 -3
  4. data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -3
  5. data/app/models/metasploit/model/module/class/spec/template.rb +0 -4
  6. data/app/models/metasploit/model/module/instance/spec/template.rb +0 -4
  7. data/app/models/metasploit/model/search/group/base.rb +0 -3
  8. data/app/models/metasploit/model/search/group/intersection.rb +0 -3
  9. data/app/models/metasploit/model/search/group/union.rb +0 -3
  10. data/app/models/metasploit/model/search/operation/association.rb +0 -2
  11. data/app/models/metasploit/model/search/operation/base.rb +0 -3
  12. data/app/models/metasploit/model/search/operation/boolean.rb +0 -2
  13. data/app/models/metasploit/model/search/operation/date.rb +0 -2
  14. data/app/models/metasploit/model/search/operation/group/base.rb +0 -2
  15. data/app/models/metasploit/model/search/operation/group/intersection.rb +0 -2
  16. data/app/models/metasploit/model/search/operation/group/union.rb +0 -2
  17. data/app/models/metasploit/model/search/operation/integer.rb +1 -5
  18. data/app/models/metasploit/model/search/operation/null.rb +0 -2
  19. data/app/models/metasploit/model/search/operation/set.rb +5 -2
  20. data/app/models/metasploit/model/search/operation/set/integer.rb +1 -3
  21. data/app/models/metasploit/model/search/operation/set/string.rb +1 -3
  22. data/app/models/metasploit/model/search/operation/string.rb +1 -5
  23. data/app/models/metasploit/model/search/operator/association.rb +0 -2
  24. data/app/models/metasploit/model/search/operator/attribute.rb +0 -2
  25. data/app/models/metasploit/model/search/operator/base.rb +0 -4
  26. data/app/models/metasploit/model/search/operator/delegation.rb +0 -2
  27. data/app/models/metasploit/model/search/operator/deprecated/app.rb +0 -2
  28. data/app/models/metasploit/model/search/operator/deprecated/author.rb +0 -2
  29. data/app/models/metasploit/model/search/operator/deprecated/authority.rb +0 -2
  30. data/app/models/metasploit/model/search/operator/deprecated/platform.rb +0 -2
  31. data/app/models/metasploit/model/search/operator/deprecated/ref.rb +0 -2
  32. data/app/models/metasploit/model/search/operator/deprecated/text.rb +0 -2
  33. data/app/models/metasploit/model/search/operator/group/base.rb +0 -2
  34. data/app/models/metasploit/model/search/operator/group/intersection.rb +0 -2
  35. data/app/models/metasploit/model/search/operator/group/union.rb +0 -2
  36. data/app/models/metasploit/model/search/operator/null.rb +0 -2
  37. data/app/models/metasploit/model/search/operator/single.rb +0 -2
  38. data/app/models/metasploit/model/search/query.rb +0 -3
  39. data/app/models/metasploit/model/spec/template.rb +0 -3
  40. data/app/models/metasploit/model/visitation/visitor.rb +0 -3
  41. data/lib/metasploit/model.rb +14 -8
  42. data/lib/metasploit/model/architecture.rb +320 -326
  43. data/lib/metasploit/model/association.rb +43 -46
  44. data/lib/metasploit/model/association/error.rb +29 -33
  45. data/lib/metasploit/model/association/tree.rb +119 -125
  46. data/lib/metasploit/model/author.rb +45 -51
  47. data/lib/metasploit/model/authority.rb +139 -146
  48. data/lib/metasploit/model/authority/bid.rb +0 -2
  49. data/lib/metasploit/model/authority/cve.rb +0 -2
  50. data/lib/metasploit/model/authority/msb.rb +0 -2
  51. data/lib/metasploit/model/authority/osvdb.rb +0 -2
  52. data/lib/metasploit/model/authority/pmasa.rb +0 -2
  53. data/lib/metasploit/model/authority/secunia.rb +0 -2
  54. data/lib/metasploit/model/authority/us_cert_vu.rb +0 -2
  55. data/lib/metasploit/model/authority/waraxe.rb +0 -2
  56. data/lib/metasploit/model/authority/zdi.rb +0 -2
  57. data/lib/metasploit/model/base.rb +0 -2
  58. data/lib/metasploit/model/derivation.rb +95 -99
  59. data/lib/metasploit/model/derivation/full_name.rb +16 -22
  60. data/lib/metasploit/model/email_address.rb +122 -128
  61. data/lib/metasploit/model/engine.rb +26 -21
  62. data/lib/metasploit/model/error.rb +3 -7
  63. data/lib/metasploit/model/file.rb +0 -2
  64. data/lib/metasploit/model/invalid.rb +11 -17
  65. data/lib/metasploit/model/login.rb +0 -3
  66. data/lib/metasploit/model/login/status.rb +0 -2
  67. data/lib/metasploit/model/module.rb +19 -23
  68. data/lib/metasploit/model/module/action.rb +50 -58
  69. data/lib/metasploit/model/module/ancestor.rb +456 -465
  70. data/lib/metasploit/model/module/ancestor/spec.rb +3 -2
  71. data/lib/metasploit/model/module/architecture.rb +27 -35
  72. data/lib/metasploit/model/module/author.rb +38 -47
  73. data/lib/metasploit/model/module/class.rb +358 -366
  74. data/lib/metasploit/model/module/class/spec.rb +3 -2
  75. data/lib/metasploit/model/module/handler.rb +28 -34
  76. data/lib/metasploit/model/module/instance.rb +586 -596
  77. data/lib/metasploit/model/module/instance/spec.rb +3 -2
  78. data/lib/metasploit/model/module/path.rb +157 -166
  79. data/lib/metasploit/model/module/platform.rb +25 -33
  80. data/lib/metasploit/model/module/rank.rb +71 -79
  81. data/lib/metasploit/model/module/reference.rb +25 -33
  82. data/lib/metasploit/model/module/stance.rb +15 -21
  83. data/lib/metasploit/model/module/target.rb +76 -84
  84. data/lib/metasploit/model/module/target/architecture.rb +27 -37
  85. data/lib/metasploit/model/module/target/platform.rb +27 -37
  86. data/lib/metasploit/model/module/type.rb +35 -41
  87. data/lib/metasploit/model/nilify_blanks.rb +39 -43
  88. data/lib/metasploit/model/platform.rb +231 -237
  89. data/lib/metasploit/model/real_pathname.rb +12 -16
  90. data/lib/metasploit/model/realm.rb +0 -2
  91. data/lib/metasploit/model/realm/key.rb +0 -2
  92. data/lib/metasploit/model/reference.rb +102 -108
  93. data/lib/metasploit/model/search.rb +94 -97
  94. data/lib/metasploit/model/search/association.rb +163 -169
  95. data/lib/metasploit/model/search/attribute.rb +131 -139
  96. data/lib/metasploit/model/search/group.rb +5 -2
  97. data/lib/metasploit/model/search/operation.rb +32 -29
  98. data/lib/metasploit/model/search/operation/group.rb +5 -2
  99. data/lib/metasploit/model/search/operation/value.rb +7 -0
  100. data/lib/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +1 -1
  101. data/lib/metasploit/model/search/operation/{string/value.rb → value/string.rb} +1 -1
  102. data/lib/metasploit/model/search/operator.rb +65 -65
  103. data/lib/metasploit/model/search/operator/deprecated.rb +8 -2
  104. data/lib/metasploit/model/search/operator/group.rb +5 -2
  105. data/lib/metasploit/model/search/operator/help.rb +71 -79
  106. data/lib/metasploit/model/search/with.rb +72 -78
  107. data/lib/metasploit/model/spec.rb +133 -136
  108. data/lib/metasploit/model/spec/error.rb +3 -9
  109. data/lib/metasploit/model/spec/i18n_exception_handler.rb +0 -2
  110. data/lib/metasploit/model/spec/pathname_collision.rb +19 -27
  111. data/lib/metasploit/model/spec/template/write.rb +0 -2
  112. data/lib/metasploit/model/spec/temporary_pathname.rb +47 -56
  113. data/lib/metasploit/model/translation.rb +0 -2
  114. data/lib/metasploit/model/version.rb +1 -1
  115. data/lib/metasploit/model/visitation.rb +7 -10
  116. data/lib/metasploit/model/visitation/visit.rb +79 -85
  117. data/metasploit-model.gemspec +1 -1
  118. data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +1 -1
  119. data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +1 -1
  120. data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +1 -1
  121. data/spec/app/models/metasploit/model/search/operation/string_spec.rb +1 -1
  122. data/spec/dummy/config/application.rb +1 -0
  123. data/spec/lib/metasploit/model/search/operation/{integer/value_spec.rb → value/integer_spec.rb} +2 -2
  124. data/spec/lib/metasploit/model/search/operation/{string/value_spec.rb → value/string_spec.rb} +2 -2
  125. data/spec/support/shared/examples/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +2 -2
  126. data/spec/support/shared/examples/metasploit/model/search/operation/{string/value.rb → value/string.rb} +2 -2
  127. metadata +16 -13
@@ -1,147 +1,144 @@
1
1
  require 'rspec/core/shared_example_group'
2
2
 
3
- module Metasploit
4
- module Model
5
- # Helper methods for running specs for metasploit-model.
6
- module Spec
7
- require 'metasploit/model/spec/temporary_pathname'
8
-
9
- extend ActiveSupport::Autoload
10
- extend Metasploit::Model::Spec::TemporaryPathname
11
- # without this, Module.shared_examples_for will be used and RSpec will count shared_examples created with
12
- # {shared_examples_for} to not be declared at the top-level.
13
- extend RSpec::Core::SharedExampleGroup::TopLevelDSL
14
-
15
- autoload :Error
16
- autoload :I18nExceptionHandler
17
- autoload :PathnameCollision
18
-
19
- # Defines a shared examples for a `Module` under the {Metasploit::Model} namespace. This `Module` is assumed to
20
- # be a mixin that can be mixed into an ActiveModel in metasploit-framework or an ActiveRecord in
21
- # metasploit_data_models. Shared examples declared using this method get access to boiler plate methods used
22
- # for all the {Metasploit::Model} mixin `Modules`:
3
+ # Helper methods for running specs for metasploit-model.
4
+ module Metasploit::Model::Spec
5
+ extend ActiveSupport::Autoload
6
+
7
+ autoload :Error
8
+ autoload :I18nExceptionHandler
9
+ autoload :PathnameCollision
10
+ autoload :Template
11
+ autoload :TemporaryPathname
12
+
13
+ extend Metasploit::Model::Spec::TemporaryPathname
14
+ # without this, Module.shared_examples_for will be used and RSpec will count shared_examples created with
15
+ # {shared_examples_for} to not be declared at the top-level.
16
+ extend RSpec::Core::SharedExampleGroup::TopLevelDSL
17
+
18
+ # Defines a shared examples for a `Module` under the {Metasploit::Model} namespace. This `Module` is assumed to
19
+ # be a mixin that can be mixed into an ActiveModel in metasploit-framework or an ActiveRecord in
20
+ # metasploit_data_models. Shared examples declared using this method get access to boiler plate methods used
21
+ # for all the {Metasploit::Model} mixin `Modules`:
22
+ #
23
+ # * <relative_variable_name>_class
24
+ # * <relative_variable_name>_factory
25
+ # * factory_namespace
26
+ # * relative_variable_name
27
+ # * #<relative_variable_name>_class
28
+ # * #<relative_variable_name>_factory
29
+ #
30
+ # @example boiler plate methods for Module::Ancestor
31
+ # # defined shared example's name will be 'Metasploit::Model::Module::Ancestor', but you only need to give the
32
+ # # name relative to 'Metasploit::Model'.
33
+ # Metasploit::Model::Spec.shared_examples_for 'Module::Ancestor' do
34
+ # module_ancestor_class # '<namespace_name>::Module::Ancestor'
35
+ # module_ancestor_factory # '<factory_namespace>_module_ancestor'
36
+ # factory_namespace # namespace_name converted to underscore with / replaced by _
37
+ # relative_variable_name # 'module_ancestor'
38
+ #
39
+ # let(:base_class) do # automatically defined for you
40
+ # module_ancestor_class # same as class method module_ancestor_class
41
+ # end
42
+ #
43
+ # context 'factories' do # have to define this yourself since not all mixins use factories.
44
+ # context module_ancestor_factory do # using class method
45
+ # subject(module_ancestor_factory) do # using class method
46
+ # FactoryGirl.build(module_ancestor_factory) # using instance method
47
+ # end
48
+ # end
49
+ # end
50
+ # end
51
+ #
52
+ # @example Using shared example
53
+ # describe Metasploit::Model::Module::Ancestor do
54
+ # it_should_behave_like 'Metasploit::Model::Module::Ancestor',
55
+ # namespace_name: 'Dummy'
56
+ # end
57
+ #
58
+ # @param relative_name [String] name relative to 'Metasploit::Model' prefix. For example, to declare
59
+ # 'Metasploit::Model::Module::Ancestor' shared example, `relative_name` would be just 'Module::Ancestor'.
60
+ # @yield Body of shared examples.
61
+ # @yieldreturn [void]
62
+ # @return [void]
63
+ def self.shared_examples_for(relative_name, &block)
64
+ fully_qualified_name = "Metasploit::Model::#{relative_name}"
65
+
66
+ relative_variable_name = relative_name.underscore.gsub('/', '_')
67
+ class_method_name = "#{relative_variable_name}_class"
68
+ factory_method_name = "#{relative_variable_name}_factory"
69
+
70
+ # capture block to pass to super so that source_location can be overridden to be block's source_location so that
71
+ # errors are reported correctly from RSpec.
72
+ wrapper = ->(options={}) {
73
+ options.assert_valid_keys(:namespace_name)
74
+ namespace_name = options.fetch(:namespace_name)
75
+
76
+ class_name = "#{namespace_name}::#{relative_name}"
77
+
23
78
  #
24
- # * <relative_variable_name>_class
25
- # * <relative_variable_name>_factory
26
- # * factory_namespace
27
- # * relative_variable_name
28
- # * #<relative_variable_name>_class
29
- # * #<relative_variable_name>_factory
79
+ # Singleton methods to emulate local variable used to define examples and lets
30
80
  #
31
- # @example boiler plate methods for Module::Ancestor
32
- # # defined shared example's name will be 'Metasploit::Model::Module::Ancestor', but you only need to give the
33
- # # name relative to 'Metasploit::Model'.
34
- # Metasploit::Model::Spec.shared_examples_for 'Module::Ancestor' do
35
- # module_ancestor_class # '<namespace_name>::Module::Ancestor'
36
- # module_ancestor_factory # '<factory_namespace>_module_ancestor'
37
- # factory_namespace # namespace_name converted to underscore with / replaced by _
38
- # relative_variable_name # 'module_ancestor'
81
+
82
+ define_singleton_method(class_method_name) do
83
+ class_name.constantize
84
+ end
85
+
86
+ define_singleton_method(factory_method_name) do
87
+ "#{factory_namespace}_#{relative_variable_name}"
88
+ end
89
+
90
+ define_singleton_method(:factory_namespace) do
91
+ namespace_name.underscore.gsub('/', '_')
92
+ end
93
+
94
+ define_singleton_method(:namespace_name) do
95
+ namespace_name
96
+ end
97
+
98
+ define_singleton_method(:relative_variable_name) do
99
+ relative_variable_name
100
+ end
101
+
39
102
  #
40
- # let(:base_class) do # automatically defined for you
41
- # module_ancestor_class # same as class method module_ancestor_class
42
- # end
103
+ # Defines to emulate local variable used inside lets
43
104
  #
44
- # context 'factories' do # have to define this yourself since not all mixins use factories.
45
- # context module_ancestor_factory do # using class method
46
- # subject(module_ancestor_factory) do # using class method
47
- # FactoryGirl.build(module_ancestor_factory) # using instance method
48
- # end
49
- # end
50
- # end
51
- # end
105
+
106
+ define_method(class_method_name) do
107
+ self.class.send(class_method_name)
108
+ end
109
+
110
+ define_method(factory_method_name) do
111
+ self.class.send(factory_method_name)
112
+ end
113
+
52
114
  #
53
- # @example Using shared example
54
- # describe Metasploit::Model::Module::Ancestor do
55
- # it_should_behave_like 'Metasploit::Model::Module::Ancestor',
56
- # namespace_name: 'Dummy'
57
- # end
115
+ # Default subject uses factory
58
116
  #
59
- # @param relative_name [String] name relative to 'Metasploit::Model' prefix. For example, to declare
60
- # 'Metasploit::Model::Module::Ancestor' shared example, `relative_name` would be just 'Module::Ancestor'.
61
- # @yield Body of shared examples.
62
- # @yieldreturn [void]
63
- # @return [void]
64
- def self.shared_examples_for(relative_name, &block)
65
- fully_qualified_name = "Metasploit::Model::#{relative_name}"
66
-
67
- relative_variable_name = relative_name.underscore.gsub('/', '_')
68
- class_method_name = "#{relative_variable_name}_class"
69
- factory_method_name = "#{relative_variable_name}_factory"
70
-
71
- # capture block to pass to super so that source_location can be overridden to be block's source_location so that
72
- # errors are reported correctly from RSpec.
73
- wrapper = ->(options={}) {
74
- options.assert_valid_keys(:namespace_name)
75
- namespace_name = options.fetch(:namespace_name)
76
-
77
- class_name = "#{namespace_name}::#{relative_name}"
78
-
79
- #
80
- # Singleton methods to emulate local variable used to define examples and lets
81
- #
82
-
83
- define_singleton_method(class_method_name) do
84
- class_name.constantize
85
- end
86
-
87
- define_singleton_method(factory_method_name) do
88
- "#{factory_namespace}_#{relative_variable_name}"
89
- end
90
-
91
- define_singleton_method(:factory_namespace) do
92
- namespace_name.underscore.gsub('/', '_')
93
- end
94
-
95
- define_singleton_method(:namespace_name) do
96
- namespace_name
97
- end
98
-
99
- define_singleton_method(:relative_variable_name) do
100
- relative_variable_name
101
- end
102
-
103
- #
104
- # Defines to emulate local variable used inside lets
105
- #
106
-
107
- define_method(class_method_name) do
108
- self.class.send(class_method_name)
109
- end
110
-
111
- define_method(factory_method_name) do
112
- self.class.send(factory_method_name)
113
- end
114
-
115
- #
116
- # Default subject uses factory
117
- #
118
-
119
- subject(relative_variable_name) do
120
- FactoryGirl.build(send(factory_method_name))
121
- end
122
-
123
- #
124
- # lets
125
- #
126
-
127
- let(:base_class) do
128
- self.class.send(class_method_name)
129
- end
130
-
131
- it_should_behave_like 'Metasploit::Model::Translation',
132
- metasploit_model_ancestor: fully_qualified_name.constantize
133
-
134
- module_eval(&block)
135
- }
136
-
137
- # Delegate source_location so that RSpec will report block's source_location as the declaration location of
138
- # the shared location instead of this method.
139
- wrapper.define_singleton_method(:source_location) do
140
- block.source_location
141
- end
142
-
143
- super(fully_qualified_name, &wrapper)
117
+
118
+ subject(relative_variable_name) do
119
+ FactoryGirl.build(send(factory_method_name))
144
120
  end
121
+
122
+ #
123
+ # lets
124
+ #
125
+
126
+ let(:base_class) do
127
+ self.class.send(class_method_name)
128
+ end
129
+
130
+ it_should_behave_like 'Metasploit::Model::Translation',
131
+ metasploit_model_ancestor: fully_qualified_name.constantize
132
+
133
+ module_eval(&block)
134
+ }
135
+
136
+ # Delegate source_location so that RSpec will report block's source_location as the declaration location of
137
+ # the shared location instead of this method.
138
+ wrapper.define_singleton_method(:source_location) do
139
+ block.source_location
145
140
  end
141
+
142
+ super(fully_qualified_name, &wrapper)
146
143
  end
147
- end
144
+ end
@@ -1,9 +1,3 @@
1
- module Metasploit
2
- module Model
3
- module Spec
4
- # Error raised by Metasploit::Model::Spec methods.
5
- class Error < StandardError
6
- end
7
- end
8
- end
9
- end
1
+ # Error raised by Metasploit::Model::Spec methods.
2
+ class Metasploit::Model::Spec::Error < StandardError
3
+ end
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/spec'
2
-
3
1
  # Raises all I18n errors as exceptions so that missing translations (or other errors) with en.yml are caught by the
4
2
  # specs.
5
3
  #
@@ -1,30 +1,22 @@
1
- require 'metasploit/model/spec/error'
2
-
3
- module Metasploit
4
- module Model
5
- module Spec
6
- # Error raised if a Pathname already exists on disk when one of the real_paths for metasploit-models factories
7
- # is generated or derived, which would indicate that a prior spec did not clean up properly.
8
- class PathnameCollision < Metasploit::Model::Spec::Error
9
- # Checks if there is a pathname collision.
10
- #
11
- # @param (see #initialize)
12
- # @return [void]
13
- # @raise [Metasploit::Model::Spec::PathnameCollision] if `pathname.exist?` is `true`.
14
- def self.check!(pathname)
15
- if pathname.exist?
16
- raise new(pathname)
17
- end
18
- end
1
+ # Error raised if a Pathname already exists on disk when one of the real_paths for metasploit-models factories
2
+ # is generated or derived, which would indicate that a prior spec did not clean up properly.
3
+ class Metasploit::Model::Spec::PathnameCollision < Metasploit::Model::Spec::Error
4
+ # Checks if there is a pathname collision.
5
+ #
6
+ # @param (see #initialize)
7
+ # @return [void]
8
+ # @raise [Metasploit::Model::Spec::PathnameCollision] if `pathname.exist?` is `true`.
9
+ def self.check!(pathname)
10
+ if pathname.exist?
11
+ raise new(pathname)
12
+ end
13
+ end
19
14
 
20
- # @param pathname [Pathname] Pathname that already exists on disk
21
- def initialize(pathname)
22
- super(
23
- "#{pathname} already exists. " \
15
+ # @param pathname [Pathname] Pathname that already exists on disk
16
+ def initialize(pathname)
17
+ super(
18
+ "#{pathname} already exists. " \
24
19
  "Metasploit::Model::Spec.remove_temporary_pathname was not called after the previous spec."
25
- )
26
- end
27
- end
28
- end
20
+ )
29
21
  end
30
- end
22
+ end
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/spec/template'
2
-
3
1
  # Extend to add a class method to create a new template and write it only if valid.
4
2
  #
5
3
  # @example extend and write
@@ -1,62 +1,53 @@
1
- # to ensure Metasploit::Model::Spec::Error is setup for autoloading
2
- require 'metasploit/model/spec'
3
-
4
- module Metasploit
5
- module Model
6
- module Spec
7
- # @example Temporary pathname creation and removal
8
- #
9
- # # spec/spec_helper.rb
10
- # RSpec.config do |config|
11
- # config.before(:suite) do
12
- # Metasploit::Model::Spec.temporary_pathname = MyApp.root.join('spec', 'tmp')
13
- # # Clean up any left over files from a previously aborted suite
14
- # Metasploit::Model::Spec.remove_temporary_pathname
15
- # end
16
- #
17
- # config.after(:each) do
18
- # Metasploit::Model::Spec.remove_temporary_pathname
19
- # end
20
- # end
21
- module TemporaryPathname
22
- # Removes {#temporary_pathname} from disk if it's been set and exists on disk.
23
- #
24
- # @return [void]
25
- def remove_temporary_pathname
26
- begin
27
- removal_pathname = temporary_pathname
28
- rescue Metasploit::Model::Spec::Error
29
- removal_pathname = nil
30
- end
1
+ # @example Temporary pathname creation and removal
2
+ #
3
+ # # spec/spec_helper.rb
4
+ # RSpec.config do |config|
5
+ # config.before(:suite) do
6
+ # Metasploit::Model::Spec.temporary_pathname = MyApp.root.join('spec', 'tmp')
7
+ # # Clean up any left over files from a previously aborted suite
8
+ # Metasploit::Model::Spec.remove_temporary_pathname
9
+ # end
10
+ #
11
+ # config.after(:each) do
12
+ # Metasploit::Model::Spec.remove_temporary_pathname
13
+ # end
14
+ # end
15
+ module Metasploit::Model::Spec::TemporaryPathname
16
+ # Removes {#temporary_pathname} from disk if it's been set and exists on disk.
17
+ #
18
+ # @return [void]
19
+ def remove_temporary_pathname
20
+ begin
21
+ removal_pathname = temporary_pathname
22
+ rescue Metasploit::Model::Spec::Error
23
+ removal_pathname = nil
24
+ end
31
25
 
32
- if removal_pathname and removal_pathname.exist?
33
- removal_pathname.rmtree
34
- end
35
- end
26
+ if removal_pathname and removal_pathname.exist?
27
+ removal_pathname.rmtree
28
+ end
29
+ end
36
30
 
37
- # Pathname to hold temporary files for metasploit-model factories and sequence. The directory must be be
38
- # safely writable and removable for specs that need to use the file system.
39
- #
40
- # @return [Pathname]
41
- # @raise [Metasploit::Model::Spec::Error] if {#temporary_pathname} is not set prior to calling this method.
42
- def temporary_pathname
43
- unless instance_variable_defined?(:@temporary_pathname)
44
- raise Metasploit::Model::Spec::Error, 'Metasploit::Model::Spec.temporary_pathname not set prior to use'
45
- end
31
+ # Pathname to hold temporary files for metasploit-model factories and sequence. The directory must be be
32
+ # safely writable and removable for specs that need to use the file system.
33
+ #
34
+ # @return [Pathname]
35
+ # @raise [Metasploit::Model::Spec::Error] if {#temporary_pathname} is not set prior to calling this method.
36
+ def temporary_pathname
37
+ unless instance_variable_defined?(:@temporary_pathname)
38
+ raise Metasploit::Model::Spec::Error, 'Metasploit::Model::Spec.temporary_pathname not set prior to use'
39
+ end
46
40
 
47
- @temporary_pathname
48
- end
41
+ @temporary_pathname
42
+ end
49
43
 
50
- # Sets the pathname to use for temporary directories and files used in metasploit_data_models factories and
51
- # sequences.
52
- #
53
- # @param pathname [Pathname] path to a directory. It does not need to exist, but need to be in a writable parent
54
- # directory so it can be removed by {#remove_temporary_pathname}.
55
- # @return [Pathname] `pathname`
56
- def temporary_pathname=(pathname)
57
- @temporary_pathname = pathname
58
- end
59
- end
60
- end
44
+ # Sets the pathname to use for temporary directories and files used in metasploit_data_models factories and
45
+ # sequences.
46
+ #
47
+ # @param pathname [Pathname] path to a directory. It does not need to exist, but need to be in a writable parent
48
+ # directory so it can be removed by {#remove_temporary_pathname}.
49
+ # @return [Pathname] `pathname`
50
+ def temporary_pathname=(pathname)
51
+ @temporary_pathname = pathname
61
52
  end
62
53
  end