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
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjBmNjY2ZGRlNTM3YTU2YzM3NDNkYTNjMzVjZGZhNDQ5NzVmN2JkMQ==
4
+ ZTRmNzJmY2FkMmVlY2ZhZjEwODllODc5MjUxODhmNTQxNGQ1NDk1Nw==
5
5
  data.tar.gz: !binary |-
6
- NDQxMDVlMzA1NWU5NjdkMjQzZmFmYjc3MjAzZjA3MTY4NTNkZjc5NQ==
6
+ NDRmOGU4MGRjNjU0NjI5Y2ZkZGI0ZDk1NGU4ZjM5NzgwMDJjYzJhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmJlNzE4OWFiNTJmYjkwNjQyOGVkZDM0MzI5ZmQzYjAzYTU5ZWVjZWFkYWQx
10
- OTNlZGNhNWY1MDMwMmJhOWI5NGMzNDYyN2RlYTFlMmUzNzBhN2FiYjc2NDRm
11
- MjBhOTViYmJlOTRhMDJkZGFlNDNiODQ5ZDgzZDM4MDBiZWVjZDQ=
9
+ NmJiMTk4ODUwMTAxN2EwNjRhN2I2MzkyZDE1YWQ0ZTYzODRkZjUzM2MyMWRl
10
+ YjEyOTc4ODgxMzQyNjVkNmUxMzc3Nzk3NTAzOGRjZTViOGZiMTVjNDY2Mjgz
11
+ MzFiNzgzYmM1ZDEwMTkzZWQzYTZmMGNmNTRhZmE3NTdlZWUxNjk=
12
12
  data.tar.gz: !binary |-
13
- ZTRiMWM4M2Q5YmVhYzIwNDNkMWUxNjVlYTYyMDA1NGYxYWViOTJmNzhmZTAw
14
- NjJhNDQ3NTQxM2ZhMTM3MmRkNDE4YTViYzJkNTkyY2EwOWFhZjQzYThjNzZl
15
- OTk4NjIyZjE2MjZkOTM0YjIxMGYyMmY3MjNiOTExMzcxMDJlMTk=
13
+ YmNmNDgyYzcxNGNiNmNhOTExZjVlZjVlN2UzNjAzNDRhM2ZmNmUwY2M4N2Iz
14
+ NDExYjU4MDA0NjJlNDEwMjU4NjUyNGExMWJjMzA3MzgzNTcxMzc5YjdiOTY2
15
+ MGE5Y2VhODhiODE4MmYzY2VmNjJlYWY3NTlmMmU5NDg1NzM4MGM=
data/.rspec CHANGED
@@ -1,4 +1,4 @@
1
1
  --backtrace
2
2
  --colour
3
3
  --drb
4
- --format nested
4
+ --format documentation
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/association'
2
- require 'metasploit/model/base'
3
-
4
1
  # Reflection of the call to {Metasploit::Model::Association::ClassMethods#association}.
5
2
  class Metasploit::Model::Association::Reflection < Metasploit::Model::Base
6
3
  #
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/module/ancestor/spec'
2
- require 'metasploit/model/spec/template/write'
3
-
4
1
  # Writes templates for the {#module_ancestor} to disk.
5
2
  #
6
3
  # @example Update files after changing
@@ -1,7 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/module/class/spec'
3
- require 'metasploit/model/spec/template/write'
4
-
5
1
  # Writes templates for the {#module_class #module_class's} {Metasploit::Model::Module::Class#ancestors} to disk.
6
2
  #
7
3
  # @example Update files after changing associations
@@ -1,7 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/module/instance/spec'
3
- require 'metasploit/model/spec/template/write'
4
-
5
1
  # Writes templates for the {#module_instance #module_instance's}
6
2
  # {Metasploit::Model::Module::Instance#module_class #module_class's} {Metasploit::Model::Module::Class#ancestors} to
7
3
  # disk.
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/search/group'
3
-
4
1
  # Groups together {Metasploit::Model::Search::Operation::Base operations} and/or or nested groups.
5
2
  class Metasploit::Model::Search::Group::Base < Metasploit::Model::Base
6
3
  #
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/search/group'
2
-
3
1
  # The intersection (ANDing) of {Metasploit::Model::Search::Operation::Base operations} and/or or nested groups.
4
2
  class Metasploit::Model::Search::Group::Intersection < Metasploit::Model::Search::Group::Base
5
-
6
3
  end
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/search/group'
2
-
3
1
  # The union (ORing) of {Metasploit::Model::Search::Operation::Base operations} and/or or nested groups.
4
2
  class Metasploit::Model::Search::Group::Union < Metasploit::Model::Search::Group::Base
5
-
6
3
  end
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # An operation with a {Metasploit::Model::Search::Operator::Association} for
4
2
  # {Metasploit::Model::Search::Operation::Base#operator} that wraps a {#source_operation} produced by the
5
3
  # {Metasploit::Model::Search::Operator::Association#source_operator}. This allows an arbitrary number of associations
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/search/operation'
3
-
4
1
  # Base of all search operations that combine an {#operator} with the {#value} it is operating on. Subclasses allow
5
2
  # validations specific to the {#operator} {Metasploit::Model::Search::Operator::Single#type type}.
6
3
  class Metasploit::Model::Search::Operation::Base < Metasploit::Model::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Search operation with {Metasploit::Model::Search::Operation::Base#operator} with `#type` `:boolean`. Validates that
4
2
  # value is a proper boolean (`false` or `true`) or the `String` version of either.
5
3
  class Metasploit::Model::Search::Operation::Boolean < Metasploit::Model::Search::Operation::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Search operation with {Metasploit::Model::Search::Operation::Base#operator} with `#type` ':date'. Validates that
4
2
  # value is `String` that can parsed with `Date.parse` or already a `Date`.
5
3
  class Metasploit::Model::Search::Operation::Date < Metasploit::Model::Search::Operation::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation/group'
2
-
3
1
  # A group of one or more {#children child operations} from an operator's `#operate_on`, should be visited the same as
4
2
  # {Metasploit::Model::Search::Group::Base}.
5
3
  class Metasploit::Model::Search::Operation::Group::Base < Metasploit::Model::Search::Operation::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation/group'
2
-
3
1
  # An intersection of one or more {Metasploit::Model::Search::Operation::Group::Base#children child operations} from an
4
2
  # operator's `#operate_on`, should be visited the same as {Metasploit::Model::Search::Group::Base}.
5
3
  class Metasploit::Model::Search::Operation::Group::Intersection < Metasploit::Model::Search::Operation::Group::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation/group'
2
-
3
1
  # A union of one or more {Metasploit::Model::Search::Operation::Group::Base#children child operations} from an
4
2
  # operator's `#operate_on`, should be visited the same as {Metasploit::Model::Search::Group::Base}.
5
3
  class Metasploit::Model::Search::Operation::Group::Union < Metasploit::Model::Search::Operation::Group::Base
@@ -1,11 +1,7 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Search operation with {Metasploit::Model::Search::Operation::Base#operator} with `#type` `:integer`. Validates that
4
2
  # value is an integer.
5
3
  class Metasploit::Model::Search::Operation::Integer < Metasploit::Model::Search::Operation::Base
6
- require 'metasploit/model/search/operation/integer/value'
7
-
8
- include Metasploit::Model::Search::Operation::Integer::Value
4
+ include Metasploit::Model::Search::Operation::Value::Integer
9
5
 
10
6
  #
11
7
  # Validations
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Operation that uses a {Metasploit::Model::Search::Operation::Null null operator}.
4
2
  class Metasploit::Model::Search::Operation::Null < Metasploit::Model::Search::Operation::Base
5
3
  #
@@ -1,8 +1,11 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Operation on an attribute that has a constrained Set of valid
4
2
  # {Metasploit::Model::Search::Operation::Base#value values}.
5
3
  class Metasploit::Model::Search::Operation::Set < Metasploit::Model::Search::Operation::Base
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Integer
7
+ autoload :String
8
+
6
9
  #
7
10
  # Validations
8
11
  #
@@ -1,7 +1,5 @@
1
- require 'metasploit/model/search/operation/integer'
2
-
3
1
  # Search operation on an attribute that has a `Set<Integer>` for acceptable
4
2
  # {Metasploit::Model::Search::Operation::Base values}.
5
3
  class Metasploit::Model::Search::Operation::Set::Integer < Metasploit::Model::Search::Operation::Set
6
- include Metasploit::Model::Search::Operation::Integer::Value
4
+ include Metasploit::Model::Search::Operation::Value::Integer
7
5
  end
@@ -1,7 +1,5 @@
1
- require 'metasploit/model/search/operation/string'
2
-
3
1
  # Search operation on an attribute that has a `Set<String>` for acceptable
4
2
  # {Metasploit::Model::Search::Operation::Base values}.
5
3
  class Metasploit::Model::Search::Operation::Set::String < Metasploit::Model::Search::Operation::Set
6
- include Metasploit::Model::Search::Operation::String::Value
4
+ include Metasploit::Model::Search::Operation::Value::String
7
5
  end
@@ -1,10 +1,6 @@
1
- require 'metasploit/model/search/operation'
2
-
3
1
  # Search operation with {Metasploit::Model::Search::Operation::Base#operator} with `#type` `:string`.
4
2
  class Metasploit::Model::Search::Operation::String < Metasploit::Model::Search::Operation::Base
5
- require 'metasploit/model/search/operation/string/value'
6
-
7
- include Metasploit::Model::Search::Operation::String::Value
3
+ include Metasploit::Model::Search::Operation::Value::String
8
4
 
9
5
  #
10
6
  # Validations
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator'
2
-
3
1
  # A search operator declared with
4
2
  # {Metasploit::Model::Search::Association::ClassMethods#search_association search_association}.
5
3
  class Metasploit::Model::Search::Operator::Association < Metasploit::Model::Search::Operator::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator'
2
-
3
1
  # A search operator declared with
4
2
  # {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute}.
5
3
  class Metasploit::Model::Search::Operator::Attribute < Metasploit::Model::Search::Operator::Single
@@ -1,7 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/search/operator'
3
- require 'metasploit/model/search/operator/help'
4
-
5
1
  # Instead of writing an operator completely from scratch, you can subclass
6
2
  # {Metasploit::Model::Search::Operator::Base}.
7
3
  #
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator'
2
-
3
1
  # An operator that delegates to another operator(s).
4
2
  class Metasploit::Model::Search::Operator::Delegation < Metasploit::Model::Search::Operator::Base
5
3
  #
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Emulates the deprecated `app` operator by converting it to the union of `authors.name:<value>`,
4
2
  # `email_addresses.local<value before '@'>`, and `email_addresses.domain:<value before '@'>` in {#operate_on}.
5
3
  class Metasploit::Model::Search::Operator::Deprecated::App < Metasploit::Model::Search::Operator::Delegation
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Operator that emulates the behavior of 'author' operator that could search `Mdm::Module::Detail` by making
4
2
  # {Metasploit::Model::Search::Operation::Group::Union} between `authors.name`, `email_addresss.domain`, and
5
3
  # `email_addresses.local`.
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Operator for the direct, single authority reference search. Translates `<abbreviation>:<designation>` to
4
2
  # `authorities.abbreviation:<abbreviation> references.designation:<designation>`.
5
3
  class Metasploit::Model::Search::Operator::Deprecated::Authority < Metasploit::Model::Search::Operator::Delegation
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Translates `<name>:<value>` to the union of `platforms.name:<value>` and `targets.name:<value>` in order to support
4
2
  # the `os` and `platform` operators.
5
3
  class Metasploit::Model::Search::Operator::Deprecated::Platform < Metasploit::Model::Search::Operator::Group::Union
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Translates `ref:<value>` to union of `authorities.abbreviation:<value>`, `references.designation:<value>`, and
4
2
  # `references.designation:<value>`.
5
3
  class Metasploit::Model::Search::Operator::Deprecated::Ref < Metasploit::Model::Search::Operator::Group::Union
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/deprecated'
2
-
3
1
  # Search the equivalent of the text fields from `Mdm::Module::Detail` and its associations, making a union of
4
2
  # `description`, `name`, `actions.name`, `architectures.abbreviation`, `platform`, and `ref`.
5
3
  class Metasploit::Model::Search::Operator::Deprecated::Text < Metasploit::Model::Search::Operator::Group::Union
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/group'
2
-
3
1
  # Operator that {#operate_on produces} {Metasploit::Model::Search::Operation::Group::Base group operations}.
4
2
  class Metasploit::Model::Search::Operator::Group::Base < Metasploit::Model::Search::Operator::Delegation
5
3
  #
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/group'
2
-
3
1
  # Operator that {Metasploit::Model::Search::Operator::Group::Base#operate_on produces}
4
2
  # {Metasploit::Model::Search::Operation::Group::Intersection intersection operations}.
5
3
  class Metasploit::Model::Search::Operator::Group::Intersection < Metasploit::Model::Search::Operator::Group::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator/group'
2
-
3
1
  # Operator that {Metasploit::Model::Search::Operator::Group::Base#operate_on produces}
4
2
  # {Metasploit::Model::Search::Operation::Group::Union union operations}.
5
3
  class Metasploit::Model::Search::Operator::Group::Union < Metasploit::Model::Search::Operator::Group::Base
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator'
2
-
3
1
  # Operator used when the formatted operator name does not match a class's operators.
4
2
  class Metasploit::Model::Search::Operator::Null < Metasploit::Model::Search::Operator::Single
5
3
  #
@@ -1,5 +1,3 @@
1
- require 'metasploit/model/search/operator'
2
-
3
1
  # If all you want do is customize the name and operation `Class` that your custom operator class returns from
4
2
  # `#operate_on`, then you can subclass {Metasploit::Model::Search::Operator::Single} instead of
5
3
  # {Metasploit::Model::Search::Operator::Base}.
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/search'
3
-
4
1
  # Once {Metasploit::Model::Search::Operator search operators} are {Metasploit::Model::Search defined}, a formatted
5
2
  # query, composed of space separated formatted operation, `<operator.name>:<formatted_value>`, can be parsed to
6
3
  # produce a validatable query.
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/spec'
3
-
4
1
  # Processes {EXTENSION '.rb.erb'} templates to create {Metasploit::Model::Module::Ancestor#contents} that contain the
5
2
  # same metadata as the {Metasploit::Model::Module::Ancestor},
6
3
  # {Metasploit::Model::Module::Class}, {Metasploit::Model::Module::Instance} and associations for those contents. This
@@ -1,6 +1,3 @@
1
- require 'metasploit/model/base'
2
- require 'metasploit/model/visitation'
3
-
4
1
  # Visits node in a {http://en.wikipedia.org/wiki/Tree_(data_structure) tree}, such as
5
2
  # {Metasploit::Model::Search::Query#tree}.
6
3
  class Metasploit::Model::Visitation::Visitor < Metasploit::Model::Base
@@ -3,15 +3,13 @@
3
3
  #
4
4
  require 'active_model'
5
5
  require 'active_support'
6
- # not loaded by default with require 'active_support'
7
- require 'active_support/dependencies'
8
6
 
9
- #
10
- # Project
11
- #
12
-
13
- require 'metasploit/model/engine'
14
- require 'metasploit/model/version'
7
+ autoload :DerivationValidator, 'derivation_validator'
8
+ autoload :DynamicLengthValidator, 'dynamic_length_validator'
9
+ autoload :IpFormatValidator, 'ip_format_validator'
10
+ autoload :NilValidator, 'nil_validator'
11
+ autoload :ParametersValidator, 'parameters_validator'
12
+ autoload :PasswordIsStrongValidator, 'password_is_strong_validator'
15
13
 
16
14
  # Top-level namespace shared between metasploit-model, metasploit-framework, and Pro.
17
15
  module Metasploit
@@ -45,3 +43,11 @@ module Metasploit
45
43
  autoload :Visitation
46
44
  end
47
45
  end
46
+
47
+ #
48
+ # Project - require Metasploit::Model to be defined
49
+ #
50
+
51
+ # MUST require and not autoload as Rails::Engine loading works based subclass registration
52
+ require 'metasploit/model/engine'
53
+ require 'metasploit/model/version'
@@ -1,348 +1,342 @@
1
- require 'metasploit/model/translation'
1
+ # Code shared between `Mdm::Architecture` and `Metasploit::Framework::Architecture`.
2
+ module Metasploit::Model::Architecture
3
+ extend ActiveModel::Naming
4
+ extend ActiveSupport::Concern
2
5
 
3
- module Metasploit
4
- module Model
5
- # Code shared between `Mdm::Architecture` and `Metasploit::Framework::Architecture`.
6
- module Architecture
7
- extend ActiveModel::Naming
8
- extend ActiveSupport::Concern
6
+ include Metasploit::Model::Translation
9
7
 
10
- include Metasploit::Model::Translation
8
+ #
9
+ # CONSTANTS
10
+ #
11
11
 
12
- #
13
- # CONSTANTS
14
- #
12
+ # Valid values for {#abbreviation}
13
+ ABBREVIATIONS = [
14
+ 'armbe',
15
+ 'armle',
16
+ 'cbea',
17
+ 'cbea64',
18
+ 'cmd',
19
+ 'dalvik',
20
+ 'firefox',
21
+ 'java',
22
+ 'mipsbe',
23
+ 'mipsle',
24
+ 'nodejs',
25
+ 'php',
26
+ 'ppc',
27
+ 'ppc64',
28
+ 'python',
29
+ 'ruby',
30
+ 'sparc',
31
+ 'tty',
32
+ 'x86',
33
+ 'x86_64'
34
+ ]
35
+ # Valid values for {#bits}.
36
+ BITS = [
37
+ 32,
38
+ 64
39
+ ]
40
+ # Valid values for {#endianness}.
41
+ ENDIANNESSES = [
42
+ 'big',
43
+ 'little'
44
+ ]
45
+ # Valid values for {#family}.
46
+ FAMILIES = [
47
+ 'arm',
48
+ 'cbea',
49
+ 'javascript',
50
+ 'mips',
51
+ 'ppc',
52
+ 'sparc',
53
+ 'x86'
54
+ ]
55
+ # Attributes for seeds. Ensures that in-database seeds for `Mdm::Architecture` and in-memory seeds for
56
+ # `Metasploit::Framework::Architecture` are the same.
57
+ SEED_ATTRIBUTES = [
58
+ {
59
+ :abbreviation => 'armbe',
60
+ :bits => 32,
61
+ :endianness => 'big',
62
+ :family => 'arm',
63
+ :summary => 'Little-endian ARM'
64
+ },
65
+ {
66
+ :abbreviation => 'armle',
67
+ :bits => 32,
68
+ :endianness => 'little',
69
+ :family => 'arm',
70
+ :summary => 'Big-endian ARM'
71
+ },
72
+ {
73
+ :abbreviation => 'cbea',
74
+ :bits => 32,
75
+ :endianness => 'big',
76
+ :family => 'cbea',
77
+ :summary => '32-bit Cell Broadband Engine Architecture'
78
+ },
79
+ {
80
+ :abbreviation => 'cbea64',
81
+ :bits => 64,
82
+ :endianness => 'big',
83
+ :family => 'cbea',
84
+ :summary => '64-bit Cell Broadband Engine Architecture'
85
+ },
86
+ {
87
+ :abbreviation => 'cmd',
88
+ :bits => nil,
89
+ :endianness => nil,
90
+ :family => nil,
91
+ :summary => 'Command Injection'
92
+ },
93
+ {
94
+ :abbreviation => 'dalvik',
95
+ :bits => nil,
96
+ :endianness => nil,
97
+ :family => nil,
98
+ :summary => 'Dalvik process virtual machine used in Google Android'
99
+ },
100
+ {
101
+ abbreviation: 'firefox',
102
+ bits: nil,
103
+ endianness: nil,
104
+ family: 'javascript',
105
+ summary: "Firefox's privileged javascript API"
106
+ },
107
+ {
108
+ :abbreviation => 'java',
109
+ :bits => nil,
110
+ :endianness => 'big',
111
+ :family => nil,
112
+ :summary => 'Java'
113
+ },
114
+ {
115
+ :abbreviation => 'mipsbe',
116
+ :bits => 32,
117
+ :endianness => 'big',
118
+ :family => 'mips',
119
+ :summary => 'Big-endian MIPS'
120
+ },
121
+ {
122
+ :abbreviation => 'mipsle',
123
+ :bits => 32,
124
+ :endianness => 'little',
125
+ :family => 'mips',
126
+ :summary => 'Little-endian MIPS'
127
+ },
128
+ {
129
+ abbreviation: 'nodejs',
130
+ bits: nil,
131
+ endianness: nil,
132
+ family: 'javascript',
133
+ summary: 'NodeJS'
134
+ },
135
+ {
136
+ :abbreviation => 'php',
137
+ :bits => nil,
138
+ :endianness => nil,
139
+ :family => nil,
140
+ :summary => 'PHP'
141
+ },
142
+ {
143
+ :abbreviation => 'ppc',
144
+ :bits => 32,
145
+ :endianness => 'big',
146
+ :family => 'ppc',
147
+ :summary => '32-bit Peformance Optimization With Enhanced RISC - Performance Computing'
148
+ },
149
+ {
150
+ :abbreviation => 'ppc64',
151
+ :bits => 64,
152
+ :endianness => 'big',
153
+ :family => 'ppc',
154
+ :summary => '64-bit Performance Optimization With Enhanced RISC - Performance Computing'
155
+ },
156
+ {
157
+ :abbreviation => 'python',
158
+ :bits => nil,
159
+ :endianness => nil,
160
+ :family => nil,
161
+ :summary => 'Python'
162
+ },
163
+ {
164
+ :abbreviation => 'ruby',
165
+ :bits => nil,
166
+ :endianness => nil,
167
+ :family => nil,
168
+ :summary => 'Ruby'
169
+ },
170
+ {
171
+ :abbreviation => 'sparc',
172
+ :bits => nil,
173
+ :endianness => nil,
174
+ :family => 'sparc',
175
+ :summary => 'Scalable Processor ARChitecture'
176
+ },
177
+ {
178
+ :abbreviation => 'tty',
179
+ :bits => nil,
180
+ :endianness => nil,
181
+ :family => nil,
182
+ :summary => '*nix terminal'
183
+ },
184
+ {
185
+ :abbreviation => 'x86',
186
+ :bits => 32,
187
+ :endianness => 'little',
188
+ :family => 'x86',
189
+ :summary => '32-bit x86'
190
+ },
191
+ {
192
+ :abbreviation => 'x86_64',
193
+ :bits => 64,
194
+ :endianness => 'little',
195
+ :family => 'x86',
196
+ :summary => '64-bit x86'
197
+ }
198
+ ]
15
199
 
16
- # Valid values for {#abbreviation}
17
- ABBREVIATIONS = [
18
- 'armbe',
19
- 'armle',
20
- 'cbea',
21
- 'cbea64',
22
- 'cmd',
23
- 'dalvik',
24
- 'firefox',
25
- 'java',
26
- 'mipsbe',
27
- 'mipsle',
28
- 'nodejs',
29
- 'php',
30
- 'ppc',
31
- 'ppc64',
32
- 'python',
33
- 'ruby',
34
- 'sparc',
35
- 'tty',
36
- 'x86',
37
- 'x86_64'
38
- ]
39
- # Valid values for {#bits}.
40
- BITS = [
41
- 32,
42
- 64
43
- ]
44
- # Valid values for {#endianness}.
45
- ENDIANNESSES = [
46
- 'big',
47
- 'little'
48
- ]
49
- # Valid values for {#family}.
50
- FAMILIES = [
51
- 'arm',
52
- 'cbea',
53
- 'javascript',
54
- 'mips',
55
- 'ppc',
56
- 'sparc',
57
- 'x86'
58
- ]
59
- # Attributes for seeds. Ensures that in-database seeds for `Mdm::Architecture` and in-memory seeds for
60
- # `Metasploit::Framework::Architecture` are the same.
61
- SEED_ATTRIBUTES = [
62
- {
63
- :abbreviation => 'armbe',
64
- :bits => 32,
65
- :endianness => 'big',
66
- :family => 'arm',
67
- :summary => 'Little-endian ARM'
68
- },
69
- {
70
- :abbreviation => 'armle',
71
- :bits => 32,
72
- :endianness => 'little',
73
- :family => 'arm',
74
- :summary => 'Big-endian ARM'
75
- },
76
- {
77
- :abbreviation => 'cbea',
78
- :bits => 32,
79
- :endianness => 'big',
80
- :family => 'cbea',
81
- :summary => '32-bit Cell Broadband Engine Architecture'
82
- },
83
- {
84
- :abbreviation => 'cbea64',
85
- :bits => 64,
86
- :endianness => 'big',
87
- :family => 'cbea',
88
- :summary => '64-bit Cell Broadband Engine Architecture'
89
- },
90
- {
91
- :abbreviation => 'cmd',
92
- :bits => nil,
93
- :endianness => nil,
94
- :family => nil,
95
- :summary => 'Command Injection'
96
- },
97
- {
98
- :abbreviation => 'dalvik',
99
- :bits => nil,
100
- :endianness => nil,
101
- :family => nil,
102
- :summary => 'Dalvik process virtual machine used in Google Android'
103
- },
104
- {
105
- abbreviation: 'firefox',
106
- bits: nil,
107
- endianness: nil,
108
- family: 'javascript',
109
- summary: "Firefox's privileged javascript API"
110
- },
111
- {
112
- :abbreviation => 'java',
113
- :bits => nil,
114
- :endianness => 'big',
115
- :family => nil,
116
- :summary => 'Java'
117
- },
118
- {
119
- :abbreviation => 'mipsbe',
120
- :bits => 32,
121
- :endianness => 'big',
122
- :family => 'mips',
123
- :summary => 'Big-endian MIPS'
124
- },
125
- {
126
- :abbreviation => 'mipsle',
127
- :bits => 32,
128
- :endianness => 'little',
129
- :family => 'mips',
130
- :summary => 'Little-endian MIPS'
131
- },
132
- {
133
- abbreviation: 'nodejs',
134
- bits: nil,
135
- endianness: nil,
136
- family: 'javascript',
137
- summary: 'NodeJS'
138
- },
139
- {
140
- :abbreviation => 'php',
141
- :bits => nil,
142
- :endianness => nil,
143
- :family => nil,
144
- :summary => 'PHP'
145
- },
146
- {
147
- :abbreviation => 'ppc',
148
- :bits => 32,
149
- :endianness => 'big',
150
- :family => 'ppc',
151
- :summary => '32-bit Peformance Optimization With Enhanced RISC - Performance Computing'
152
- },
153
- {
154
- :abbreviation => 'ppc64',
155
- :bits => 64,
156
- :endianness => 'big',
157
- :family => 'ppc',
158
- :summary => '64-bit Performance Optimization With Enhanced RISC - Performance Computing'
159
- },
160
- {
161
- :abbreviation => 'python',
162
- :bits => nil,
163
- :endianness => nil,
164
- :family => nil,
165
- :summary => 'Python'
166
- },
167
- {
168
- :abbreviation => 'ruby',
169
- :bits => nil,
170
- :endianness => nil,
171
- :family => nil,
172
- :summary => 'Ruby'
173
- },
174
- {
175
- :abbreviation => 'sparc',
176
- :bits => nil,
177
- :endianness => nil,
178
- :family => 'sparc',
179
- :summary => 'Scalable Processor ARChitecture'
180
- },
181
- {
182
- :abbreviation => 'tty',
183
- :bits => nil,
184
- :endianness => nil,
185
- :family => nil,
186
- :summary => '*nix terminal'
187
- },
188
- {
189
- :abbreviation => 'x86',
190
- :bits => 32,
191
- :endianness => 'little',
192
- :family => 'x86',
193
- :summary => '32-bit x86'
194
- },
195
- {
196
- :abbreviation => 'x86_64',
197
- :bits => 64,
198
- :endianness => 'little',
199
- :family => 'x86',
200
- :summary => '64-bit x86'
201
- }
202
- ]
200
+ included do
201
+ include ActiveModel::Validations
202
+ include Metasploit::Model::Search
203
203
 
204
- included do
205
- include ActiveModel::Validations
206
- include Metasploit::Model::Search
204
+ #
205
+ # Search Attributes
206
+ #
207
207
 
208
- #
209
- # Search Attributes
210
- #
208
+ search_attribute :abbreviation,
209
+ type: {
210
+ set: :string
211
+ }
212
+ search_attribute :bits,
213
+ type: {
214
+ set: :integer
215
+ }
216
+ search_attribute :endianness,
217
+ type: {
218
+ set: :string
219
+ }
220
+ search_attribute :family,
221
+ type: {
222
+ set: :string
223
+ }
211
224
 
212
- search_attribute :abbreviation,
213
- type: {
214
- set: :string
215
- }
216
- search_attribute :bits,
217
- type: {
218
- set: :integer
219
- }
220
- search_attribute :endianness,
221
- type: {
222
- set: :string
223
- }
224
- search_attribute :family,
225
- type: {
226
- set: :string
227
- }
225
+ #
226
+ # Validations
227
+ #
228
228
 
229
- #
230
- # Validations
231
- #
232
-
233
- validates :abbreviation,
234
- :inclusion => {
235
- :in => ABBREVIATIONS
236
- }
237
- validates :bits,
238
- :inclusion => {
239
- :allow_nil => true,
240
- :in => BITS
241
- }
242
- validates :endianness,
243
- :inclusion => {
244
- :allow_nil => true,
245
- :in => ENDIANNESSES
246
- }
247
- validates :family,
248
- :inclusion => {
249
- :allow_nil => true,
250
- :in => FAMILIES
251
- }
252
- validates :summary,
253
- :presence => true
254
- end
229
+ validates :abbreviation,
230
+ :inclusion => {
231
+ :in => ABBREVIATIONS
232
+ }
233
+ validates :bits,
234
+ :inclusion => {
235
+ :allow_nil => true,
236
+ :in => BITS
237
+ }
238
+ validates :endianness,
239
+ :inclusion => {
240
+ :allow_nil => true,
241
+ :in => ENDIANNESSES
242
+ }
243
+ validates :family,
244
+ :inclusion => {
245
+ :allow_nil => true,
246
+ :in => FAMILIES
247
+ }
248
+ validates :summary,
249
+ :presence => true
250
+ end
255
251
 
256
- # Adds <attribute>_set methods to class.
257
- module ClassMethods
258
- # Set of valid values to search for `attribute`. Does not include `nil` as search syntax cannot differentiate
259
- # '' and nil when parsing.
260
- #
261
- # @param attribute [Symbol] attribute name.
262
- # @return [Set]
263
- def self.set(attribute)
264
- SEED_ATTRIBUTES.each_with_object(Set.new) { |attributes, set|
265
- value = attributes.fetch(attribute)
252
+ # Adds <attribute>_set methods to class.
253
+ module ClassMethods
254
+ # Set of valid values to search for `attribute`. Does not include `nil` as search syntax cannot differentiate
255
+ # '' and nil when parsing.
256
+ #
257
+ # @param attribute [Symbol] attribute name.
258
+ # @return [Set]
259
+ def self.set(attribute)
260
+ SEED_ATTRIBUTES.each_with_object(Set.new) { |attributes, set|
261
+ value = attributes.fetch(attribute)
266
262
 
267
- unless value.nil?
268
- set.add value
269
- end
270
- }
263
+ unless value.nil?
264
+ set.add value
271
265
  end
266
+ }
267
+ end
272
268
 
273
- # @!method abbreviation_set
274
- # Set of valid {Metasploit::Model::Architecture#abbreviation} for search.
275
- #
276
- # @return [Set<String>]
277
- #
278
- # @!method bits_set
279
- # Set of valid {Metasploit::Model::Architecture#bits} for search.
280
- #
281
- # @return [Set<Integer>]
282
- #
283
- # @!method endianness_set
284
- # Set of valid {Metasploit::Model::Architecture#endianness} for search.
285
- #
286
- # @return [Set<String>]
287
- #
288
- # @!method family_set
289
- # Set of valid {Metasploit::Model::Architecture#family} for search.
290
- #
291
- # @return [Set<String>]
292
- [:abbreviation, :bits, :endianness, :family].each do |attribute|
293
- # calculate external to method so it is only calculated once
294
- set = self.set(attribute)
269
+ # @!method abbreviation_set
270
+ # Set of valid {Metasploit::Model::Architecture#abbreviation} for search.
271
+ #
272
+ # @return [Set<String>]
273
+ #
274
+ # @!method bits_set
275
+ # Set of valid {Metasploit::Model::Architecture#bits} for search.
276
+ #
277
+ # @return [Set<Integer>]
278
+ #
279
+ # @!method endianness_set
280
+ # Set of valid {Metasploit::Model::Architecture#endianness} for search.
281
+ #
282
+ # @return [Set<String>]
283
+ #
284
+ # @!method family_set
285
+ # Set of valid {Metasploit::Model::Architecture#family} for search.
286
+ #
287
+ # @return [Set<String>]
288
+ [:abbreviation, :bits, :endianness, :family].each do |attribute|
289
+ # calculate external to method so it is only calculated once
290
+ set = self.set(attribute)
295
291
 
296
- define_method("#{attribute}_set") do
297
- set
298
- end
299
- end
292
+ define_method("#{attribute}_set") do
293
+ set
300
294
  end
295
+ end
296
+ end
301
297
 
302
- #
303
- # Associations
304
- #
298
+ #
299
+ # Associations
300
+ #
305
301
 
306
- # @!attribute [r] module_instances
307
- # {Metasploit::Model::Module::Instance Modules} that have this {Metasploit::Model::Module::Architecture} as a
308
- # {Metasploit::Model::Module::Instance#architectures support architecture}.
309
- #
310
- # @return [Array<Metasploit::Model::Module::Instance>]
302
+ # @!attribute [r] module_instances
303
+ # {Metasploit::Model::Module::Instance Modules} that have this {Metasploit::Model::Module::Architecture} as a
304
+ # {Metasploit::Model::Module::Instance#architectures support architecture}.
305
+ #
306
+ # @return [Array<Metasploit::Model::Module::Instance>]
311
307
 
312
- #
313
- # Attributes
314
- #
308
+ #
309
+ # Attributes
310
+ #
315
311
 
316
- # @!attribute [rw] abbreviation
317
- # Abbreviation used for the architecture. Will match ARCH constants in metasploit-framework.
318
- #
319
- # @return [String]
312
+ # @!attribute [rw] abbreviation
313
+ # Abbreviation used for the architecture. Will match ARCH constants in metasploit-framework.
314
+ #
315
+ # @return [String]
320
316
 
321
- # @!attribute [rw] bits
322
- # Number of bits supported by this architecture.
323
- #
324
- # @return [32] if 32-bit
325
- # @return [64] if 64-bit
326
- # @return [nil] if bits aren't applicable, such as for non-CPU architectures like ruby, etc.
317
+ # @!attribute [rw] bits
318
+ # Number of bits supported by this architecture.
319
+ #
320
+ # @return [32] if 32-bit
321
+ # @return [64] if 64-bit
322
+ # @return [nil] if bits aren't applicable, such as for non-CPU architectures like ruby, etc.
327
323
 
328
- # @!attribute [rw] endianness
329
- # The endianness of the architecture.
330
- #
331
- # @return ['big'] if big endian
332
- # @return ['little'] if little endian
333
- # @return [nil] if endianness is not applicable, such as for software architectures like tty.
324
+ # @!attribute [rw] endianness
325
+ # The endianness of the architecture.
326
+ #
327
+ # @return ['big'] if big endian
328
+ # @return ['little'] if little endian
329
+ # @return [nil] if endianness is not applicable, such as for software architectures like tty.
334
330
 
335
- # @!attribute [rw] family
336
- # The CPU architecture family.
337
- #
338
- # @return [String] if a CPU architecture.
339
- # @return [nil] if not a CPU architecture.
331
+ # @!attribute [rw] family
332
+ # The CPU architecture family.
333
+ #
334
+ # @return [String] if a CPU architecture.
335
+ # @return [nil] if not a CPU architecture.
340
336
 
341
- # @!attribute [rw] summary
342
- # Sentence length summary of architecture. Usually an expansion of the abbreviation or initialism in the
343
- # {#abbreviation} and the {#bits} and {#endianness} in prose.
344
- #
345
- # @return [String]
346
- end
347
- end
348
- end
337
+ # @!attribute [rw] summary
338
+ # Sentence length summary of architecture. Usually an expansion of the abbreviation or initialism in the
339
+ # {#abbreviation} and the {#bits} and {#endianness} in prose.
340
+ #
341
+ # @return [String]
342
+ end