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,25 +1,19 @@
1
- module Metasploit
2
- module Model
3
- module Derivation
4
- # Methods for deriving full_name from module_type and reference_name in `Mdm::Module::Ancestor`,
5
- # `Mdm::Module::Class`, `Metasploit::Framework::Module::Ancestor`, and `Metasploit::Framework::Module::Class`.
6
- module FullName
7
- # Derives full_name by combining module_type and reference_name in the same way used to create modules using
8
- # Msf::ModuleManager#create in metasploit-framework.
9
- #
10
- # @return [String] <module_type>/<reference_name>
11
- # @return [nil] if module_type is `nil`.
12
- # @return [nil] if reference_name is `nil`.
13
- def derived_full_name
14
- derived = nil
1
+ # Methods for deriving full_name from module_type and reference_name in `Mdm::Module::Ancestor`,
2
+ # `Mdm::Module::Class`, `Metasploit::Framework::Module::Ancestor`, and `Metasploit::Framework::Module::Class`.
3
+ module Metasploit::Model::Derivation::FullName
4
+ # Derives full_name by combining module_type and reference_name in the same way used to create modules using
5
+ # Msf::ModuleManager#create in metasploit-framework.
6
+ #
7
+ # @return [String] <module_type>/<reference_name>
8
+ # @return [nil] if module_type is `nil`.
9
+ # @return [nil] if reference_name is `nil`.
10
+ def derived_full_name
11
+ derived = nil
15
12
 
16
- if module_type and reference_name
17
- derived = "#{module_type}/#{reference_name}"
18
- end
19
-
20
- derived
21
- end
22
- end
13
+ if module_type and reference_name
14
+ derived = "#{module_type}/#{reference_name}"
23
15
  end
16
+
17
+ derived
24
18
  end
25
- end
19
+ end
@@ -1,130 +1,124 @@
1
- require 'metasploit/model/translation'
2
-
3
- module Metasploit
4
- module Model
5
- # Code shared between `Mdm::EmailAddress` and `Metasploit::Framework::EmailAddress`.
6
- module EmailAddress
7
- extend ActiveModel::Naming
8
- extend ActiveSupport::Concern
9
-
10
- include Metasploit::Model::Translation
11
-
12
- included do
13
- include ActiveModel::MassAssignmentSecurity
14
- include ActiveModel::Validations
15
- include Metasploit::Model::Derivation
16
- include Metasploit::Model::Search
17
-
18
- #
19
- # Derivations
20
- #
21
-
22
- derives :domain, :validate => true
23
- derives :full, :validate => true
24
- derives :local, :validate => true
25
-
26
- #
27
- # Mass Assignment Security
28
- #
29
-
30
- attr_accessible :domain
31
- attr_accessible :full
32
- attr_accessible :local
33
-
34
- #
35
- # Search Attributes
36
- #
37
-
38
- search_attribute :domain, :type => :string
39
- search_attribute :full, :type => :string
40
- search_attribute :local, :type => :string
41
-
42
- #
43
- # Validations
44
- #
45
-
46
- validates :domain, :presence => true
47
- validates :local, :presence => true
48
- end
49
-
50
- #
51
- # Associations
52
- #
53
-
54
- # @!attribute [rw] module_authors
55
- # Credits where {#authors} used this email address for {#module_instances modules}.
56
- #
57
- # @return [Array<Metasploit::Model::Module::Author>]
58
-
59
- # @!attribute [r] authors
60
- # Authors that used this email address.
61
- #
62
- # @return [Array<Metasploit::Model::Author>]
63
-
64
- # @!attribute [r] module_instances
65
- # Modules where this email address was used.
66
- #
67
- # @return [Array<Metasploit::Module::Instance>]
68
-
69
- #
70
- # Attributes
71
- #
72
-
73
- # @!attribute [rw] domain
74
- # The domain part of the email address after the `'@'`.
75
- #
76
- # @return [String]
77
-
78
- # @!attribute [rw] full
79
- # The full email address.
80
- #
81
- # @return [String] <{#local}>@<{#domain}
82
-
83
- # @!attribute [rw] local
84
- # The local part of the email address before the `'@'`.
85
- #
86
- # @return [String]
87
-
88
- #
89
- # Methods
90
- #
91
-
92
- # Derives {#domain} from {#full}
93
- #
94
- # @return [String] if {#full} is present
95
- # @return [nil] if {#full} is not present
96
- def derived_domain
97
- domain = nil
98
-
99
- if full.present?
100
- _local, domain = full.split('@', 2)
101
- end
102
-
103
- domain
104
- end
105
-
106
- # Derives {#full} from {#domain} and {#local}
107
- #
108
- # @return [String]
109
- def derived_full
110
- if domain.present? && local.present?
111
- "#{local}@#{domain}"
112
- end
113
- end
114
-
115
- # Derives {#local} from {#full}.
116
- #
117
- # @return [String] if {#full} is present
118
- # @return [nil] if {#full} is not present
119
- def derived_local
120
- local = nil
121
-
122
- if full.present?
123
- local, _domain = full.split('@', 2)
124
- end
125
-
126
- local
127
- end
1
+ # Code shared between `Mdm::EmailAddress` and `Metasploit::Framework::EmailAddress`.
2
+ module Metasploit::Model::EmailAddress
3
+ extend ActiveModel::Naming
4
+ extend ActiveSupport::Concern
5
+
6
+ include Metasploit::Model::Translation
7
+
8
+ included do
9
+ include ActiveModel::MassAssignmentSecurity
10
+ include ActiveModel::Validations
11
+ include Metasploit::Model::Derivation
12
+ include Metasploit::Model::Search
13
+
14
+ #
15
+ # Derivations
16
+ #
17
+
18
+ derives :domain, :validate => true
19
+ derives :full, :validate => true
20
+ derives :local, :validate => true
21
+
22
+ #
23
+ # Mass Assignment Security
24
+ #
25
+
26
+ attr_accessible :domain
27
+ attr_accessible :full
28
+ attr_accessible :local
29
+
30
+ #
31
+ # Search Attributes
32
+ #
33
+
34
+ search_attribute :domain, :type => :string
35
+ search_attribute :full, :type => :string
36
+ search_attribute :local, :type => :string
37
+
38
+ #
39
+ # Validations
40
+ #
41
+
42
+ validates :domain, :presence => true
43
+ validates :local, :presence => true
44
+ end
45
+
46
+ #
47
+ # Associations
48
+ #
49
+
50
+ # @!attribute [rw] module_authors
51
+ # Credits where {#authors} used this email address for {#module_instances modules}.
52
+ #
53
+ # @return [Array<Metasploit::Model::Module::Author>]
54
+
55
+ # @!attribute [r] authors
56
+ # Authors that used this email address.
57
+ #
58
+ # @return [Array<Metasploit::Model::Author>]
59
+
60
+ # @!attribute [r] module_instances
61
+ # Modules where this email address was used.
62
+ #
63
+ # @return [Array<Metasploit::Module::Instance>]
64
+
65
+ #
66
+ # Attributes
67
+ #
68
+
69
+ # @!attribute [rw] domain
70
+ # The domain part of the email address after the `'@'`.
71
+ #
72
+ # @return [String]
73
+
74
+ # @!attribute [rw] full
75
+ # The full email address.
76
+ #
77
+ # @return [String] <{#local}>@<{#domain}
78
+
79
+ # @!attribute [rw] local
80
+ # The local part of the email address before the `'@'`.
81
+ #
82
+ # @return [String]
83
+
84
+ #
85
+ # Methods
86
+ #
87
+
88
+ # Derives {#domain} from {#full}
89
+ #
90
+ # @return [String] if {#full} is present
91
+ # @return [nil] if {#full} is not present
92
+ def derived_domain
93
+ domain = nil
94
+
95
+ if full.present?
96
+ _local, domain = full.split('@', 2)
97
+ end
98
+
99
+ domain
100
+ end
101
+
102
+ # Derives {#full} from {#domain} and {#local}
103
+ #
104
+ # @return [String]
105
+ def derived_full
106
+ if domain.present? && local.present?
107
+ "#{local}@#{domain}"
128
108
  end
129
109
  end
130
- end
110
+
111
+ # Derives {#local} from {#full}.
112
+ #
113
+ # @return [String] if {#full} is present
114
+ # @return [nil] if {#full} is not present
115
+ def derived_local
116
+ local = nil
117
+
118
+ if full.present?
119
+ local, _domain = full.split('@', 2)
120
+ end
121
+
122
+ local
123
+ end
124
+ end
@@ -1,28 +1,33 @@
1
1
  require 'rails'
2
2
 
3
- module Metasploit
4
- module Model
5
- # Rails engine for Metasploit::Model. Will automatically be used if `Rails` is defined when
6
- # 'metasploit/model' is required, as should be the case in any normal Rails application Gemfile where
7
- # gem 'rails' is the first gem in the Gemfile.
8
- class Engine < Rails::Engine
9
- # @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
10
- config.generators do |g|
11
- g.assets false
12
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
13
- g.helper false
14
- g.test_framework :rspec, :fixture => false
15
- end
3
+ # Rails engine for Metasploit::Model. Will automatically be used if `Rails` is defined when
4
+ # 'metasploit/model' is required, as should be the case in any normal Rails application Gemfile where
5
+ # gem 'rails' is the first gem in the Gemfile.
6
+ class Metasploit::Model::Engine < Rails::Engine
7
+ # @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
8
+ config.generators do |g|
9
+ g.assets false
10
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
11
+ g.helper false
12
+ g.test_framework :rspec, :fixture => false
13
+ end
14
+
15
+ # Remove ActiveSupport::Dependencies loading paths to save time during constant resolution and to ensure that
16
+ # metasploit-model is properly declaring all autoloads and not falling back on ActiveSupport::Dependencies
17
+ config.paths.each_value do |path|
18
+ path.skip_autoload!
19
+ path.skip_autoload_once!
20
+ path.skip_eager_load!
21
+ path.skip_load_path!
22
+ end
16
23
 
17
- initializer 'metasploit-model.prepend_factory_path', :after => 'factory_girl.set_factory_paths' do
18
- if defined? FactoryGirl
19
- relative_definition_file_path = config.generators.options[:factory_girl][:dir]
20
- definition_file_path = root.join(relative_definition_file_path)
24
+ initializer 'metasploit-model.prepend_factory_path', :after => 'factory_girl.set_factory_paths' do
25
+ if defined? FactoryGirl
26
+ relative_definition_file_path = config.generators.options[:factory_girl][:dir]
27
+ definition_file_path = root.join(relative_definition_file_path)
21
28
 
22
- # unshift so that dependent gems can modify metasploit-model's factories
23
- FactoryGirl.definition_file_paths.unshift definition_file_path
24
- end
25
- end
29
+ # unshift so that dependent gems can modify metasploit-model's factories
30
+ FactoryGirl.definition_file_paths.unshift definition_file_path
26
31
  end
27
32
  end
28
33
  end
@@ -1,7 +1,3 @@
1
- module Metasploit
2
- module Model
3
- # Base class for error hierarchy for {Metasploit::Model}
4
- class Error < StandardError
5
- end
6
- end
7
- end
1
+ # Base class for error hierarchy for {Metasploit::Model}
2
+ class Metasploit::Model::Error < StandardError
3
+ end
@@ -1,5 +1,3 @@
1
- require 'metasploit/model'
2
-
3
1
  if RUBY_PLATFORM =~ /java/ && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('1.7.14')
4
2
  require 'java'
5
3
 
@@ -1,19 +1,13 @@
1
- require 'metasploit/model/error'
1
+ # Error raised if a {Metasploit::Model} ActiveModel is invalid.
2
+ class Metasploit::Model::Invalid < Metasploit::Model::Error
3
+ def initialize(model)
4
+ @model = model
2
5
 
3
- module Metasploit
4
- module Model
5
- # Error raised if a {Metasploit::Model} ActiveModel is invalid.
6
- class Invalid < Metasploit::Model::Error
7
- def initialize(model)
8
- @model = model
9
-
10
- errors = @model.errors.full_messages.join(', ')
11
- # Must be called model_invalid so it doesn't alias errors.messages.invalid
12
- translated_message = ::I18n.translate('metasploit.model.errors.messages.model_invalid', :errors => errors)
13
- super(translated_message)
14
- end
15
-
16
- attr_reader :model
17
- end
6
+ errors = @model.errors.full_messages.join(', ')
7
+ # Must be called model_invalid so it doesn't alias errors.messages.invalid
8
+ translated_message = ::I18n.translate('metasploit.model.errors.messages.model_invalid', :errors => errors)
9
+ super(translated_message)
18
10
  end
19
- end
11
+
12
+ attr_reader :model
13
+ end
@@ -1,6 +1,3 @@
1
- require 'metasploit/model'
2
-
3
-
4
1
  # Namespace for constants used in `Metasploit::Credential::Login` that need to be accessible without
5
2
  # `metasploit-credential`
6
3
  module Metasploit::Model::Login
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/login'
2
-
3
1
  # Canonical `Metasploit::Credential::Login#status`.
4
2
  #
5
3
  # `Metasploit::Credential::Login#status` is restricted to values in {ALL}, so new valid values need to be added to this
@@ -1,24 +1,20 @@
1
- module Metasploit
2
- module Model
3
- # Namespace that maps to `Mdm::Module` and `Metasploit::Framework::Module` and contains constants and mixins to
4
- # DRY the implementation of the in-memory and in-database models in those namespaces.
5
- module Module
6
- extend ActiveSupport::Autoload
1
+ # Namespace that maps to `Mdm::Module` and `Metasploit::Framework::Module` and contains constants and mixins to
2
+ # DRY the implementation of the in-memory and in-database models in those namespaces.
3
+ module Metasploit::Model::Module
4
+ extend ActiveSupport::Autoload
7
5
 
8
- autoload :Action
9
- autoload :Ancestor
10
- autoload :Architecture
11
- autoload :Author
12
- autoload :Class
13
- autoload :Handler
14
- autoload :Instance
15
- autoload :Path
16
- autoload :Platform
17
- autoload :Rank
18
- autoload :Reference
19
- autoload :Stance
20
- autoload :Target
21
- autoload :Type
22
- end
23
- end
24
- end
6
+ autoload :Action
7
+ autoload :Ancestor
8
+ autoload :Architecture
9
+ autoload :Author
10
+ autoload :Class
11
+ autoload :Handler
12
+ autoload :Instance
13
+ autoload :Path
14
+ autoload :Platform
15
+ autoload :Rank
16
+ autoload :Reference
17
+ autoload :Stance
18
+ autoload :Target
19
+ autoload :Type
20
+ end