metasploit-model 0.27.0.pre.dep.pre.railties → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +13 -5
  2. data/app/models/metasploit/model/association/reflection.rb +3 -0
  3. data/app/models/metasploit/model/module/ancestor/spec/template.rb +3 -0
  4. data/app/models/metasploit/model/module/class/spec/template.rb +4 -0
  5. data/app/models/metasploit/model/module/instance/spec/template.rb +4 -0
  6. data/app/models/metasploit/model/search/group/base.rb +3 -0
  7. data/app/models/metasploit/model/search/group/intersection.rb +2 -0
  8. data/app/models/metasploit/model/search/group/union.rb +2 -0
  9. data/app/models/metasploit/model/search/operation/association.rb +2 -0
  10. data/app/models/metasploit/model/search/operation/base.rb +3 -0
  11. data/app/models/metasploit/model/search/operation/boolean.rb +2 -0
  12. data/app/models/metasploit/model/search/operation/date.rb +2 -0
  13. data/app/models/metasploit/model/search/operation/group/base.rb +2 -0
  14. data/app/models/metasploit/model/search/operation/group/intersection.rb +2 -0
  15. data/app/models/metasploit/model/search/operation/group/union.rb +2 -0
  16. data/app/models/metasploit/model/search/operation/integer.rb +4 -0
  17. data/app/models/metasploit/model/search/operation/null.rb +2 -0
  18. data/app/models/metasploit/model/search/operation/set.rb +2 -0
  19. data/app/models/metasploit/model/search/operation/set/integer.rb +2 -0
  20. data/app/models/metasploit/model/search/operation/set/string.rb +2 -0
  21. data/app/models/metasploit/model/search/operation/string.rb +4 -0
  22. data/app/models/metasploit/model/search/operator/association.rb +2 -0
  23. data/app/models/metasploit/model/search/operator/attribute.rb +2 -0
  24. data/app/models/metasploit/model/search/operator/base.rb +4 -0
  25. data/app/models/metasploit/model/search/operator/delegation.rb +2 -0
  26. data/app/models/metasploit/model/search/operator/deprecated/app.rb +2 -0
  27. data/app/models/metasploit/model/search/operator/deprecated/author.rb +2 -0
  28. data/app/models/metasploit/model/search/operator/deprecated/authority.rb +2 -0
  29. data/app/models/metasploit/model/search/operator/deprecated/platform.rb +2 -0
  30. data/app/models/metasploit/model/search/operator/deprecated/ref.rb +2 -0
  31. data/app/models/metasploit/model/search/operator/deprecated/text.rb +2 -0
  32. data/app/models/metasploit/model/search/operator/group/base.rb +2 -0
  33. data/app/models/metasploit/model/search/operator/group/intersection.rb +2 -0
  34. data/app/models/metasploit/model/search/operator/group/union.rb +2 -0
  35. data/app/models/metasploit/model/search/operator/null.rb +2 -0
  36. data/app/models/metasploit/model/search/operator/single.rb +2 -0
  37. data/app/models/metasploit/model/search/query.rb +3 -0
  38. data/app/models/metasploit/model/spec/template.rb +9 -2
  39. data/app/models/metasploit/model/visitation/visitor.rb +3 -0
  40. data/lib/metasploit/model.rb +24 -15
  41. data/lib/metasploit/model/architecture.rb +2 -0
  42. data/lib/metasploit/model/association.rb +4 -0
  43. data/lib/metasploit/model/author.rb +2 -0
  44. data/lib/metasploit/model/authority.rb +14 -0
  45. data/lib/metasploit/model/authority/bid.rb +2 -0
  46. data/lib/metasploit/model/authority/cve.rb +2 -0
  47. data/lib/metasploit/model/authority/msb.rb +2 -0
  48. data/lib/metasploit/model/authority/osvdb.rb +2 -0
  49. data/lib/metasploit/model/authority/pmasa.rb +2 -0
  50. data/lib/metasploit/model/authority/secunia.rb +2 -0
  51. data/lib/metasploit/model/authority/us_cert_vu.rb +2 -0
  52. data/lib/metasploit/model/authority/waraxe.rb +2 -0
  53. data/lib/metasploit/model/authority/zdi.rb +2 -0
  54. data/lib/metasploit/model/base.rb +2 -0
  55. data/lib/metasploit/model/derivation.rb +4 -1
  56. data/lib/metasploit/model/email_address.rb +2 -0
  57. data/lib/metasploit/model/engine.rb +1 -0
  58. data/lib/metasploit/model/invalid.rb +2 -0
  59. data/lib/metasploit/model/login.rb +10 -0
  60. data/lib/metasploit/model/login/status.rb +2 -0
  61. data/lib/metasploit/model/module.rb +16 -0
  62. data/lib/metasploit/model/module/action.rb +2 -0
  63. data/lib/metasploit/model/module/ancestor.rb +6 -0
  64. data/lib/metasploit/model/module/ancestor/spec.rb +5 -0
  65. data/lib/metasploit/model/module/architecture.rb +2 -0
  66. data/lib/metasploit/model/module/author.rb +2 -0
  67. data/lib/metasploit/model/module/class.rb +5 -0
  68. data/lib/metasploit/model/module/class/spec.rb +5 -0
  69. data/lib/metasploit/model/module/instance.rb +6 -0
  70. data/lib/metasploit/model/module/instance/spec.rb +5 -0
  71. data/lib/metasploit/model/module/path.rb +3 -0
  72. data/lib/metasploit/model/module/platform.rb +2 -0
  73. data/lib/metasploit/model/module/rank.rb +2 -0
  74. data/lib/metasploit/model/module/reference.rb +2 -0
  75. data/lib/metasploit/model/module/target.rb +6 -0
  76. data/lib/metasploit/model/module/target/architecture.rb +2 -0
  77. data/lib/metasploit/model/module/target/platform.rb +2 -0
  78. data/lib/metasploit/model/platform.rb +2 -0
  79. data/lib/metasploit/model/real_pathname.rb +2 -0
  80. data/lib/metasploit/model/realm.rb +9 -0
  81. data/lib/metasploit/model/realm/key.rb +2 -0
  82. data/lib/metasploit/model/reference.rb +2 -0
  83. data/lib/metasploit/model/search.rb +9 -0
  84. data/lib/metasploit/model/search/attribute.rb +2 -0
  85. data/lib/metasploit/model/search/group.rb +6 -0
  86. data/lib/metasploit/model/search/operation.rb +4 -0
  87. data/lib/metasploit/model/search/operation/group.rb +5 -0
  88. data/lib/metasploit/model/search/operator.rb +4 -0
  89. data/lib/metasploit/model/search/operator/deprecated.rb +6 -0
  90. data/lib/metasploit/model/search/operator/group.rb +5 -0
  91. data/lib/metasploit/model/spec.rb +7 -0
  92. data/lib/metasploit/model/spec/i18n_exception_handler.rb +2 -0
  93. data/lib/metasploit/model/spec/pathname_collision.rb +2 -0
  94. data/lib/metasploit/model/spec/template/write.rb +2 -0
  95. data/lib/metasploit/model/spec/temporary_pathname.rb +3 -0
  96. data/lib/metasploit/model/translation.rb +2 -0
  97. data/lib/metasploit/model/version.rb +0 -1
  98. data/lib/metasploit/model/visitation.rb +2 -0
  99. data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +1 -1
  100. data/spec/lib/metasploit/model/engine_spec.rb +1 -1
  101. data/spec/lib/metasploit/model/login/status_spec.rb +83 -0
  102. data/spec/lib/metasploit/model/spec_spec.rb +3 -3
  103. data/spec/spec_helper.rb +4 -6
  104. metadata +22 -36
  105. data/lib/metasploit/model/configuration.rb +0 -72
  106. data/lib/metasploit/model/configuration/autoload.rb +0 -109
  107. data/lib/metasploit/model/configuration/child.rb +0 -12
  108. data/lib/metasploit/model/configuration/error.rb +0 -4
  109. data/lib/metasploit/model/configuration/i18n.rb +0 -54
  110. data/lib/metasploit/model/configuration/parent.rb +0 -50
  111. data/lib/metasploit/model/configured.rb +0 -46
  112. data/spec/lib/metasploit/model/configuration/autoload_spec.rb +0 -165
  113. data/spec/lib/metasploit/model/configuration/child_spec.rb +0 -24
  114. data/spec/lib/metasploit/model/configuration/error_spec.rb +0 -5
  115. data/spec/lib/metasploit/model/configuration/i18n_spec.rb +0 -103
  116. data/spec/lib/metasploit/model/configuration_spec.rb +0 -106
  117. data/spec/lib/metasploit/model/configured_spec.rb +0 -41
  118. data/spec/lib/metasploit/model_spec.rb +0 -68
  119. data/spec/support/shared/contexts/metasploit/model/configuration.rb +0 -11
  120. data/spec/support/shared/examples/metasploit/model/configuration/parent/child.rb +0 -60
@@ -1,109 +0,0 @@
1
- require 'metasploit/model/configuration/child'
2
-
3
- # Defines methods for adding paths to `ActiveSupport::Dependencies.autoload_paths`.
4
- class Metasploit::Model::Configuration::Autoload < Metasploit::Model::Configuration::Child
5
- #
6
- # Attributes
7
- #
8
-
9
- # @!attribute [rw] relative_once_paths
10
- # Paths relative to {Metasploit::Model::Configuration::Child#configuration #configuration}
11
- # {Metasploit::Model::Configuration#root #root} that should only be autoloaded once.
12
- #
13
- # @return [Array<String>]
14
-
15
- # @!attribute [rw] relative_paths
16
- # Paths relative to {Metasploit::Model::Configuration::Child#configuration #configuration}
17
- # {Metasploit::Model::Configuration#root #root} that should be autoloaded more than once.
18
- #
19
- # @return [Array<String>]
20
-
21
- #
22
- # Methods
23
- #
24
-
25
- # Combines {#once_paths} and {#paths} as both need to be added to
26
- # `ActiveSupport::Dependencies.autoload_paths`.
27
- #
28
- # @return [Array<String>]
29
- def all_paths
30
- @all_paths ||= (once_paths + paths).uniq
31
- end
32
-
33
- # Eager loads all rb files under {#all_paths}. Paths in {#all_paths} are sorted before loading, so that `app` will
34
- # load before `lib`. Files are required using `ActiveSupport::Dependencies::Loadable#require_dependency` so they
35
- # interact with `ActiveSupport::Dependencies` loading correctly.
36
- #
37
- # @return [void]
38
- def eager_load!
39
- # sort to favor app over lib since it is assumed that app/models will define classes and lib will define modules
40
- # included in those classes that are defined under the class namespaces, so the class needs to be required first
41
- all_paths.sort.each do |load_path|
42
- matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
43
-
44
- Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
45
- require_dependency file.sub(matcher, '\1')
46
- end
47
- end
48
- end
49
-
50
- # {#relative_once_paths} converted to absolute paths.
51
- #
52
- # @return [Array<String>]
53
- def once_paths
54
- @once_paths ||= relative_once_paths.collect { |relative_path|
55
- configuration.root.join(relative_path).to_path
56
- }
57
- end
58
-
59
- # {#relative_paths} converted to absolute paths.
60
- #
61
- # @return [Array<String>]
62
- def paths
63
- @paths ||= relative_paths.collect { |relative_path|
64
- configuration.root.join(relative_path).to_path
65
- }
66
- end
67
-
68
- # Paths relative to {Metasploit::Model::Configuration#root} that are to be added to
69
- # `ActiveSupport::Dependencies.autoload_paths` and `ActiveSupport::Dependencies.autoload_once_paths`.
70
- #
71
- # @return [Array<String>] Defaults to ['lib']
72
- def relative_once_paths
73
- @relative_once_paths ||= [
74
- 'lib'
75
- ]
76
- end
77
-
78
- attr_writer :relative_once_paths
79
-
80
- # Paths relative to {Metasploit::Model::Configuration#root} that are to be added to
81
- # `ActiveSupport::Dependencies.autoload_paths`, but not `ActiveSupport::Dependencies.autoload_once_paths`
82
- #
83
- # @return [Array<String>] Defaults to ['app/models']
84
- def relative_paths
85
- @relative_paths ||= [
86
- File.join('app', 'models')
87
- ]
88
- end
89
-
90
- attr_writer :relative_paths
91
-
92
- # Adds {#all_paths} to `ActiveSupport::Dependencies.autoload_paths` if they are not already there and adds
93
- # {#once_paths} to `ActiveSupport::Dependencies.autoload_once_paths` if they are not already there.
94
- #
95
- # @return [void]
96
- def setup
97
- all_paths.each do |autoload_path|
98
- unless ActiveSupport::Dependencies.autoload_paths.include? autoload_path
99
- ActiveSupport::Dependencies.autoload_paths << autoload_path
100
- end
101
- end
102
-
103
- once_paths.each do |autoload_once_path|
104
- unless ActiveSupport::Dependencies.autoload_once_paths.include? autoload_once_path
105
- ActiveSupport::Dependencies.autoload_once_paths << autoload_once_path
106
- end
107
- end
108
- end
109
- end
@@ -1,12 +0,0 @@
1
- # Child of a {Metasploit::Model::Configuration} that contains a reference to the {#configuration}.
2
- class Metasploit::Model::Configuration::Child
3
- #
4
- # Attributes
5
- #
6
-
7
- # @!attribute [rw] configuration
8
- # Main configuration.
9
- #
10
- # @return [Metasploit::Model::Configuration::Autoload]
11
- attr_accessor :configuration
12
- end
@@ -1,4 +0,0 @@
1
- # Error raised by {Metasploit::Model::Configuration#root} if root is not configured.
2
- class Metasploit::Model::Configuration::Error < Metasploit::Model::Error
3
-
4
- end
@@ -1,54 +0,0 @@
1
- require 'metasploit/model/configuration/child'
2
-
3
- # Defines methods for adding paths to `I18n.load_path`
4
- class Metasploit::Model::Configuration::I18n < Metasploit::Model::Configuration::Child
5
- #
6
- # Attributes
7
- #
8
-
9
- # @!attribute [rw] relative_directories
10
- # Paths relative to root that point to directories that contain locale files like `en.yml`.
11
- #
12
- # @return [Array<String>] Defaults to ['config/locales']
13
-
14
- # Absolute paths to directories under which to find I18n .yml files.
15
- #
16
- # @return [Array<String>]
17
- def directories
18
- @directories ||= relative_directories.collect { |relative_path|
19
- configuration.root.join(relative_path).to_path
20
- }
21
- end
22
-
23
- # Absolute paths to I18n .yml files.
24
- #
25
- # @return [Array<String>]
26
- def paths
27
- @paths ||= directories.flat_map { |directory|
28
- glob = File.join(directory, '*.yml')
29
- Dir.glob(glob)
30
- }
31
- end
32
-
33
- # Relative paths to I18n directories.
34
- #
35
- # @return [Array<String>] Defaults to 'config/locales'
36
- def relative_directories
37
- @relative_directories ||= [
38
- File.join('config', 'locales')
39
- ]
40
- end
41
-
42
- attr_writer :relative_directories
43
-
44
- # Adds {#paths} to `I18n.load_path` if they are not already there.
45
- #
46
- # @return [void]
47
- def setup
48
- paths.each do |path|
49
- unless ::I18n.load_path.include? path
50
- ::I18n.load_path << path
51
- end
52
- end
53
- end
54
- end
@@ -1,50 +0,0 @@
1
- # DSL for declaring {Metasploit::Model::Configuration::Child children} of {Metasploit::Model::Configuration}
2
- module Metasploit::Model::Configuration::Parent
3
- # Declares a {Metasploit::Model::Configuration::Child} with the given `name`.
4
- #
5
- # @param name [Symbol] The name of the child.
6
- # @return [void]
7
- def child(name)
8
- child_class_attribute_name = "#{name}_class"
9
- child_class_instance_variable_name = "@#{child_class_attribute_name}".to_sym
10
- child_instance_variable_name = "@#{name}".to_sym
11
-
12
- #
13
- # Attributes
14
- #
15
-
16
- # @!attribute [rw] <name>_class
17
- # The `Class` used to create {#<name>}.
18
- #
19
- # @return [Class]
20
- attr_writer child_class_attribute_name
21
-
22
- #
23
- # Methods
24
- #
25
-
26
- define_method(name) do
27
- unless instance_variable_defined? child_instance_variable_name
28
- child_instance = send(child_class_attribute_name).new
29
- child_instance.configuration = self
30
-
31
- instance_variable_set child_instance_variable_name, child_instance
32
- end
33
-
34
- instance_variable_get child_instance_variable_name
35
- end
36
-
37
- define_method(child_class_attribute_name) do
38
- child_class = instance_variable_get child_class_instance_variable_name
39
-
40
- unless child_class
41
- require "metasploit/model/configuration/#{name}"
42
-
43
- child_class = "Metasploit::Model::Configuration::#{name.to_s.camelize}".constantize
44
- instance_variable_set child_class_instance_variable_name, child_class
45
- end
46
-
47
- child_class
48
- end
49
- end
50
- end
@@ -1,46 +0,0 @@
1
- require 'active_support/core_ext/module/delegation'
2
-
3
- # Allows modules to be configured (using {Metasploit::Model::Configuration}) similar to Rails engines.
4
- #
5
- # @example Making gem module configurable
6
- # module MyGem
7
- # extend Metasploit::Model::Configured
8
- #
9
- # # assumes __FILE__ is lib/my_gem.rb
10
- # lib_my_gem_pathname = Pathname.new(___FILE__)
11
- # lib_pathname = lib_my_gem_pathname.parent
12
- # configuration.root = lib_pathname.parent
13
- #
14
- # configuration.autoload.paths << 'app/models'
15
- # end
16
- #
17
- # # registers 'app/models' as an autoload_path with ActiveSupport::Dependencies
18
- # MyGem.setup
19
- module Metasploit::Model::Configured
20
- # The {Metasploit::Model::Configuration} for this configured `Module`.
21
- #
22
- # @return [Metasploit::Model::Configuration]
23
- def configuration
24
- unless instance_variable_defined? :@configuration
25
- require 'metasploit/model/configuration'
26
-
27
- @configuration = Metasploit::Model::Configuration.new
28
- end
29
-
30
- @configuration
31
- end
32
-
33
- # @!method root
34
- # The configured root.
35
- #
36
- # @return (see Metasploit::Model::Configuration#root)
37
- #
38
- # @!method setup
39
- # Sets up the autoload and i18n paths for the configured gem.
40
- #
41
- # @return (see Metasploit::Model::Configuration.setup)
42
- # @raise (see Metasploit::Model::Configuration.setup)
43
- delegate :root,
44
- :setup,
45
- to: :configuration
46
- end
@@ -1,165 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Configuration::Autoload do
4
- include_context 'Metasploit::Model::Configuration'
5
-
6
- subject(:autoload) do
7
- described_class.new.tap { |autoload|
8
- autoload.configuration = configuration
9
- }
10
- end
11
-
12
- context 'all_paths' do
13
- subject(:all_paths) do
14
- autoload.all_paths
15
- end
16
-
17
- it 'should include autoload_once_paths' do
18
- all_paths.to_set.should be_superset(autoload.once_paths.to_set)
19
- end
20
-
21
- it 'should include paths' do
22
- all_paths.to_set.should be_superset(autoload.paths.to_set)
23
- end
24
- end
25
-
26
- context 'once_paths' do
27
- subject(:once_paths) do
28
- autoload.once_paths
29
- end
30
-
31
- it 'should call relative_once_paths' do
32
- autoload.should_receive(:relative_once_paths).and_return([])
33
-
34
- once_paths
35
- end
36
-
37
- it 'should have absolute paths' do
38
- once_paths.each do |once_path|
39
- once_path.should == File.absolute_path(once_path)
40
- end
41
- end
42
- end
43
-
44
- context 'paths' do
45
- subject(:paths) do
46
- autoload.paths
47
- end
48
-
49
- it 'should call relative_paths' do
50
- autoload.should_receive(:relative_paths).and_return([])
51
-
52
- paths
53
- end
54
-
55
- it 'should have absolute paths' do
56
- paths.each do |path|
57
- path.should == File.absolute_path(path)
58
- end
59
- end
60
- end
61
-
62
- context 'relative_once_paths' do
63
- subject(:relative_once_paths) do
64
- autoload.relative_once_paths
65
- end
66
-
67
- it { should include('lib') }
68
- end
69
-
70
- context 'relative_paths' do
71
- subject(:relative_paths) do
72
- autoload.relative_paths
73
- end
74
-
75
- it { should include('app/models') }
76
- end
77
-
78
- context 'setup' do
79
- subject(:setup) do
80
- autoload.setup
81
- end
82
-
83
- let(:autoload_once_path) do
84
- Metasploit::Model.root.join('spec', 'dummy', 'lib').to_path
85
- end
86
-
87
- let(:autoload_path) do
88
- Metasploit::Model.root.join('spec', 'dummy', 'app', 'models').to_path
89
- end
90
-
91
- before(:each) do
92
- @before_autoload_paths = ActiveSupport::Dependencies.autoload_paths.dup
93
- ActiveSupport::Dependencies.autoload_paths.clear
94
-
95
- @before_autoload_once_paths = ActiveSupport::Dependencies.autoload_once_paths.dup
96
- ActiveSupport::Dependencies.autoload_once_paths.clear
97
-
98
- autoload.stub(:autoload_once_paths).and_return([autoload_once_path])
99
- autoload.stub(:autoload_paths).and_return([])
100
- end
101
-
102
- after(:each) do
103
- ActiveSupport::Dependencies.autoload_paths = @before_autoload_paths
104
- ActiveSupport::Dependencies.autoload_once_paths = @before_autoload_once_paths
105
- end
106
-
107
- context 'paths' do
108
- it 'should call all_paths' do
109
- autoload.should_receive(:all_paths).and_return([])
110
-
111
- setup
112
- end
113
-
114
- context 'with autoload_path in ActiveSupport::Dependencies.autoload_paths' do
115
- before(:each) do
116
- ActiveSupport::Dependencies.autoload_paths << autoload_path
117
- ActiveSupport::Dependencies.autoload_paths << autoload_once_path
118
- end
119
-
120
- it 'should not add path to ActiveSupport::Dependencies.autoload_paths' do
121
- expect {
122
- setup
123
- }.to_not change(ActiveSupport::Dependencies, :autoload_paths)
124
- end
125
- end
126
-
127
- context 'without autoload_path in ActiveSupport::Dependencies.autoload_paths' do
128
- it 'should add path to ActiveSupport::Dependencies.autoload_paths' do
129
- setup
130
-
131
- ActiveSupport::Dependencies.autoload_paths.should include(autoload_once_path)
132
- end
133
- end
134
- end
135
-
136
- context 'once_paths' do
137
- it 'should call once_paths' do
138
- # once in #all_paths and once when called directly
139
- autoload.should_receive(:once_paths).twice.and_return([])
140
-
141
- setup
142
- end
143
-
144
- context 'with autoload_path in ActiveSupport::Dependencies.autoload_once_paths' do
145
- before(:each) do
146
- ActiveSupport::Dependencies.autoload_once_paths << autoload_once_path
147
- end
148
-
149
- it 'should not add path to ActiveSupport::Dependencies.autoload_once_paths' do
150
- expect {
151
- setup
152
- }.to_not change(ActiveSupport::Dependencies, :autoload_once_paths)
153
- end
154
- end
155
-
156
- context 'without autoload_path in ActiveSupport::Dependencies.autoload_once_paths' do
157
- it 'should add path to ActiveSupport::Dependencies.autoload_once_paths' do
158
- setup
159
-
160
- ActiveSupport::Dependencies.autoload_once_paths.should include(autoload_once_path)
161
- end
162
- end
163
- end
164
- end
165
- end