metasploit-model 0.27.3-java → 0.27.4-java

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 +4 -4
  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,20 +1,16 @@
1
1
  require 'pathname'
2
2
 
3
- module Metasploit
4
- module Model
5
- # Adds {#real_pathname} to class, which will convert `#real_path` `String` to a `Pathname`.
6
- module RealPathname
7
- # `#real_path` as a `Pathname`.
8
- #
9
- # @return [Pathname] unless `#real_path` is `nil`.
10
- # @return [nil] if `#real_path` is `nil`.
11
- def real_pathname
12
- if real_path
13
- Pathname.new(real_path)
14
- else
15
- nil
16
- end
17
- end
3
+ # Adds {#real_pathname} to class, which will convert `#real_path` `String` to a `Pathname`.
4
+ module Metasploit::Model::RealPathname
5
+ # `#real_path` as a `Pathname`.
6
+ #
7
+ # @return [Pathname] unless `#real_path` is `nil`.
8
+ # @return [nil] if `#real_path` is `nil`.
9
+ def real_pathname
10
+ if real_path
11
+ Pathname.new(real_path)
12
+ else
13
+ nil
18
14
  end
19
15
  end
20
- end
16
+ end
@@ -1,5 +1,3 @@
1
- require 'metasploit/model'
2
-
3
1
  # Namespace for constants used in `Metasploit::Credential::Realm` that need to be accessible without
4
2
  # `metasploit-credential`
5
3
  module Metasploit::Model::Realm
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/realm'
2
-
3
1
  # Canonical `Metasploit::Credential::Realm#key`s.
4
2
  #
5
3
  # `Metasploit::Credential::Realm#key` is restricted to values in {ALL}, so new valid values need to be added to this
@@ -1,110 +1,104 @@
1
- require 'metasploit/model/translation'
2
-
3
- module Metasploit
4
- module Model
5
- # Code shared between `Mdm::Reference` and `Metasploit::Framework::Reference`.
6
- module Reference
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 :url, :validate => false
23
-
24
- #
25
- # Mass Assignment Security
26
- #
27
-
28
- attr_accessible :designation
29
- attr_accessible :url
30
-
31
- #
32
- # Search Attributes
33
- #
34
-
35
- search_attribute :designation, :type => :string
36
- search_attribute :url, :type => :string
37
-
38
- #
39
- # Validations
40
- #
41
-
42
- validates :designation,
43
- :presence => {
44
- :if => :authority?
45
- },
46
- :nil => {
47
- :unless => :authority?
48
- }
49
- validates :url,
50
- :presence => {
51
- :unless => :authority?
52
- }
53
- end
54
-
55
- #
56
- # Associations
57
- #
58
-
59
- # @!attribute [rw] authority
60
- # The {Metasploit::Model::Authority authority} that assigned {#designation}.
61
- #
62
- # @return [Metasploit::Model::Authority, nil]
63
-
64
- # @!attribute [r] module_instances
65
- # {Metasploit::Model::Module::Instance Modules} that exploit this reference or describe a proof-of-concept (PoC)
66
- # code that the module is based on.
67
- #
68
- # @return [Array<Metasploit::Model::Module::Instance>]
69
-
70
- #
71
- # Attributes
72
- #
73
-
74
- # @!attribute [rw] designation
75
- # A designation (usually a string of numbers and dashes) assigned by {#authority}.
76
- #
77
- # @return [String, nil]
78
-
79
- # @!attribute [rw] url
80
- # URL to web page with information about referenced exploit.
81
- #
82
- # @return [String, nil]
83
-
84
- #
85
- # Instance Methods
86
- #
87
-
88
- # Returns whether {#authority} is not `nil`.
89
- #
90
- # @return [true] unless {#authority} is `nil`.
91
- # @return [false] if {#authority} is `nil`.
92
- def authority?
93
- authority.present?
94
- end
95
-
96
- # Derives {#url} based how {#authority} routes {#designation designations} to a URL.
97
- #
98
- # @return [String, nil]
99
- def derived_url
100
- derived = nil
101
-
102
- if authority and designation.present?
103
- derived = authority.designation_url(designation)
104
- end
105
-
106
- derived
107
- end
1
+ # Code shared between `Mdm::Reference` and `Metasploit::Framework::Reference`.
2
+ module Metasploit::Model::Reference
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 :url, :validate => false
19
+
20
+ #
21
+ # Mass Assignment Security
22
+ #
23
+
24
+ attr_accessible :designation
25
+ attr_accessible :url
26
+
27
+ #
28
+ # Search Attributes
29
+ #
30
+
31
+ search_attribute :designation, :type => :string
32
+ search_attribute :url, :type => :string
33
+
34
+ #
35
+ # Validations
36
+ #
37
+
38
+ validates :designation,
39
+ :presence => {
40
+ :if => :authority?
41
+ },
42
+ :nil => {
43
+ :unless => :authority?
44
+ }
45
+ validates :url,
46
+ :presence => {
47
+ :unless => :authority?
48
+ }
49
+ end
50
+
51
+ #
52
+ # Associations
53
+ #
54
+
55
+ # @!attribute [rw] authority
56
+ # The {Metasploit::Model::Authority authority} that assigned {#designation}.
57
+ #
58
+ # @return [Metasploit::Model::Authority, nil]
59
+
60
+ # @!attribute [r] module_instances
61
+ # {Metasploit::Model::Module::Instance Modules} that exploit this reference or describe a proof-of-concept (PoC)
62
+ # code that the module is based on.
63
+ #
64
+ # @return [Array<Metasploit::Model::Module::Instance>]
65
+
66
+ #
67
+ # Attributes
68
+ #
69
+
70
+ # @!attribute [rw] designation
71
+ # A designation (usually a string of numbers and dashes) assigned by {#authority}.
72
+ #
73
+ # @return [String, nil]
74
+
75
+ # @!attribute [rw] url
76
+ # URL to web page with information about referenced exploit.
77
+ #
78
+ # @return [String, nil]
79
+
80
+ #
81
+ # Instance Methods
82
+ #
83
+
84
+ # Returns whether {#authority} is not `nil`.
85
+ #
86
+ # @return [true] unless {#authority} is `nil`.
87
+ # @return [false] if {#authority} is `nil`.
88
+ def authority?
89
+ authority.present?
90
+ end
91
+
92
+ # Derives {#url} based how {#authority} routes {#designation designations} to a URL.
93
+ #
94
+ # @return [String, nil]
95
+ def derived_url
96
+ derived = nil
97
+
98
+ if authority and designation.present?
99
+ derived = authority.designation_url(designation)
108
100
  end
101
+
102
+ derived
109
103
  end
110
- end
104
+ end
@@ -1,106 +1,103 @@
1
- module Metasploit
2
- module Model
3
- # DSL to define associations and attributes that can be searched. Making an association searchable, will expose
4
- # the attributes that association's class defined as searchable.
5
- #
6
- # # Operators
7
- #
8
- # Search operators define how to search against a given `Class`.
9
- #
10
- # ## Attributes
11
- #
12
- # Boolean, `Date`, `Integer`, and `String` attributes can be searched with
13
- # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute}. `Integer` and `String`
14
- # attributes can be further restricted to a defined `Set` of values.
15
- #
16
- # class Part
17
- # include Metasploit::Model::Search
18
- #
19
- # search_attribute :part,
20
- # :integer
21
- # end
22
- #
23
- # The above defines the `:part` operator on `Part`.
24
- #
25
- # ## Custom search operators
26
- #
27
- # If a search operator does not directly correspond to an attribute or a the attribute needs custom validation, then
28
- # a custom {Metasploit::Model::Search::Operator operator class} can be setup as the search operator
29
- #
30
- # class Search::Operator::UUID
31
- # def name
32
- # :uuid
33
- # end
34
- # end
35
- #
36
- # class Part
37
- # include Metasploit::Model::Search
38
- #
39
- # search_with Search::Operator::UUID
40
- # end
41
- #
42
- # The above defines the `:uuid` operator on `Part`.
43
- #
44
- # ## Associations
45
- #
46
- # Search operators registered with
47
- # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute} or
48
- # {Metasploit::Model::Search::With::ClassMethods#search_with search_with} on an associated `Class` can be searched
49
- # with {Metasploit::Model::Search::Association::ClassMethods#search_association}:
50
- #
51
- # class Widget
52
- # include Metasploit::Model::Search
53
- #
54
- # # declare parts association
55
- #
56
- # search_association :parts
57
- # end
58
- #
59
- # The above will define the `:'parts.number'` and `:'parts.uuid'` operator on `Widget`.
60
- #
61
- # # Queries
62
- #
63
- # {include:Metasploit::Model::Search::Query}
64
- module Search
65
- extend ActiveSupport::Concern
66
- extend ActiveSupport::Autoload
67
-
68
- require 'metasploit/model/search/association'
69
- require 'metasploit/model/search/attribute'
70
- require 'metasploit/model/search/with'
1
+ # DSL to define associations and attributes that can be searched. Making an association searchable, will expose
2
+ # the attributes that association's class defined as searchable.
3
+ #
4
+ # # Operators
5
+ #
6
+ # Search operators define how to search against a given `Class`.
7
+ #
8
+ # ## Attributes
9
+ #
10
+ # Boolean, `Date`, `Integer`, and `String` attributes can be searched with
11
+ # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute}. `Integer` and `String`
12
+ # attributes can be further restricted to a defined `Set` of values.
13
+ #
14
+ # class Part
15
+ # include Metasploit::Model::Search
16
+ #
17
+ # search_attribute :part,
18
+ # :integer
19
+ # end
20
+ #
21
+ # The above defines the `:part` operator on `Part`.
22
+ #
23
+ # ## Custom search operators
24
+ #
25
+ # If a search operator does not directly correspond to an attribute or a the attribute needs custom validation, then
26
+ # a custom {Metasploit::Model::Search::Operator operator class} can be setup as the search operator
27
+ #
28
+ # class Search::Operator::UUID
29
+ # def name
30
+ # :uuid
31
+ # end
32
+ # end
33
+ #
34
+ # class Part
35
+ # include Metasploit::Model::Search
36
+ #
37
+ # search_with Search::Operator::UUID
38
+ # end
39
+ #
40
+ # The above defines the `:uuid` operator on `Part`.
41
+ #
42
+ # ## Associations
43
+ #
44
+ # Search operators registered with
45
+ # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute} or
46
+ # {Metasploit::Model::Search::With::ClassMethods#search_with search_with} on an associated `Class` can be searched
47
+ # with {Metasploit::Model::Search::Association::ClassMethods#search_association}:
48
+ #
49
+ # class Widget
50
+ # include Metasploit::Model::Search
51
+ #
52
+ # # declare parts association
53
+ #
54
+ # search_association :parts
55
+ # end
56
+ #
57
+ # The above will define the `:'parts.number'` and `:'parts.uuid'` operator on `Widget`.
58
+ #
59
+ # # Queries
60
+ #
61
+ # {include:Metasploit::Model::Search::Query}
62
+ module Metasploit::Model::Search
63
+ extend ActiveSupport::Autoload
64
+ extend ActiveSupport::Concern
71
65
 
72
- include Metasploit::Model::Search::Association
73
- include Metasploit::Model::Search::Attribute
74
- include Metasploit::Model::Search::With
66
+ autoload :Association
67
+ autoload :Attribute
68
+ autoload :Group
69
+ autoload :Operation
70
+ autoload :Operator
71
+ autoload :Query
72
+ autoload :Search
73
+ autoload :With
75
74
 
76
- autoload :Group
77
- autoload :Operation
78
- autoload :Operator
75
+ include Metasploit::Model::Search::Association
76
+ include Metasploit::Model::Search::Attribute
77
+ include Metasploit::Model::Search::With
79
78
 
80
- # Allows operators registered with {Metasploit::Model::Search::Association::ClassMethods#search_association} and
81
- # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute} to be looked up by name.
82
- module ClassMethods
83
- # Collects all search attributes from search associations and all attributes from this class to show the valid
84
- # search operators to search.
85
- #
86
- # @return [Hash{Symbol => Metasploit::Model::Search::Operator}] Maps
87
- # {Metasploit::Model::Search::Operator::Base#name} to {Metasploit::Model::Search::Operator::Base#name}.
88
- def search_operator_by_name
89
- unless instance_variable_defined? :@search_operator_by_name
90
- @search_operator_by_name = {}
79
+ # Allows operators registered with {Metasploit::Model::Search::Association::ClassMethods#search_association} and
80
+ # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute} to be looked up by name.
81
+ module ClassMethods
82
+ # Collects all search attributes from search associations and all attributes from this class to show the valid
83
+ # search operators to search.
84
+ #
85
+ # @return [Hash{Symbol => Metasploit::Model::Search::Operator}] Maps
86
+ # {Metasploit::Model::Search::Operator::Base#name} to {Metasploit::Model::Search::Operator::Base#name}.
87
+ def search_operator_by_name
88
+ unless instance_variable_defined? :@search_operator_by_name
89
+ @search_operator_by_name = {}
91
90
 
92
- search_with_operator_by_name.each_value do |operator|
93
- @search_operator_by_name[operator.name] = operator
94
- end
95
-
96
- search_association_operators.each do |operator|
97
- @search_operator_by_name[operator.name] = operator
98
- end
99
- end
91
+ search_with_operator_by_name.each_value do |operator|
92
+ @search_operator_by_name[operator.name] = operator
93
+ end
100
94
 
101
- @search_operator_by_name
95
+ search_association_operators.each do |operator|
96
+ @search_operator_by_name[operator.name] = operator
102
97
  end
103
98
  end
99
+
100
+ @search_operator_by_name
104
101
  end
105
102
  end
106
- end
103
+ end