metasploit-model 0.28.0-java → 0.29.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/config/locales/en.yml +0 -171
  4. data/lib/metasploit/model.rb +0 -2
  5. data/lib/metasploit/model/spec.rb +0 -130
  6. data/lib/metasploit/model/version.rb +1 -1
  7. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +4 -6
  8. data/spec/support/shared/examples/metasploit/model/translation.rb +1 -1
  9. data/spec/support/shared/examples/search_association.rb +1 -1
  10. data/spec/support/shared/examples/search_with.rb +4 -2
  11. metadata +2 -348
  12. data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -125
  13. data/app/models/metasploit/model/module/class/spec/template.rb +0 -92
  14. data/app/models/metasploit/model/module/instance/spec/template.rb +0 -97
  15. data/app/models/metasploit/model/spec/template.rb +0 -277
  16. data/app/validators/derivation_validator.rb +0 -17
  17. data/app/validators/dynamic_length_validator.rb +0 -45
  18. data/lib/metasploit/model/architecture.rb +0 -342
  19. data/lib/metasploit/model/author.rb +0 -54
  20. data/lib/metasploit/model/authority.rb +0 -141
  21. data/lib/metasploit/model/authority/bid.rb +0 -10
  22. data/lib/metasploit/model/authority/cve.rb +0 -10
  23. data/lib/metasploit/model/authority/msb.rb +0 -10
  24. data/lib/metasploit/model/authority/osvdb.rb +0 -10
  25. data/lib/metasploit/model/authority/pmasa.rb +0 -10
  26. data/lib/metasploit/model/authority/secunia.rb +0 -10
  27. data/lib/metasploit/model/authority/us_cert_vu.rb +0 -10
  28. data/lib/metasploit/model/authority/waraxe.rb +0 -31
  29. data/lib/metasploit/model/authority/zdi.rb +0 -10
  30. data/lib/metasploit/model/derivation.rb +0 -109
  31. data/lib/metasploit/model/derivation/full_name.rb +0 -19
  32. data/lib/metasploit/model/email_address.rb +0 -124
  33. data/lib/metasploit/model/module.rb +0 -20
  34. data/lib/metasploit/model/module/action.rb +0 -52
  35. data/lib/metasploit/model/module/ancestor.rb +0 -491
  36. data/lib/metasploit/model/module/ancestor/spec.rb +0 -6
  37. data/lib/metasploit/model/module/architecture.rb +0 -34
  38. data/lib/metasploit/model/module/author.rb +0 -40
  39. data/lib/metasploit/model/module/class.rb +0 -403
  40. data/lib/metasploit/model/module/class/spec.rb +0 -6
  41. data/lib/metasploit/model/module/handler.rb +0 -29
  42. data/lib/metasploit/model/module/instance.rb +0 -622
  43. data/lib/metasploit/model/module/instance/spec.rb +0 -6
  44. data/lib/metasploit/model/module/path.rb +0 -159
  45. data/lib/metasploit/model/module/platform.rb +0 -32
  46. data/lib/metasploit/model/module/rank.rb +0 -85
  47. data/lib/metasploit/model/module/reference.rb +0 -32
  48. data/lib/metasploit/model/module/stance.rb +0 -16
  49. data/lib/metasploit/model/module/target.rb +0 -78
  50. data/lib/metasploit/model/module/target/architecture.rb +0 -34
  51. data/lib/metasploit/model/module/target/platform.rb +0 -34
  52. data/lib/metasploit/model/module/type.rb +0 -38
  53. data/lib/metasploit/model/platform.rb +0 -246
  54. data/lib/metasploit/model/real_pathname.rb +0 -16
  55. data/lib/metasploit/model/reference.rb +0 -104
  56. data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +0 -174
  57. data/spec/app/models/metasploit/model/module/class/spec/template_spec.rb +0 -222
  58. data/spec/app/models/metasploit/model/module/instance/spec/template_spec.rb +0 -201
  59. data/spec/app/models/metasploit/model/search/operator/deprecated/app_spec.rb +0 -62
  60. data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +0 -197
  61. data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +0 -135
  62. data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +0 -124
  63. data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +0 -387
  64. data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +0 -399
  65. data/spec/app/models/metasploit/model/spec/template_spec.rb +0 -23
  66. data/spec/app/validators/derivation_validator_spec.rb +0 -92
  67. data/spec/app/validators/dynamic_length_validator_spec.rb +0 -293
  68. data/spec/dummy/app/models/dummy/architecture.rb +0 -92
  69. data/spec/dummy/app/models/dummy/author.rb +0 -15
  70. data/spec/dummy/app/models/dummy/authority.rb +0 -130
  71. data/spec/dummy/app/models/dummy/email_address.rb +0 -27
  72. data/spec/dummy/app/models/dummy/module/action.rb +0 -25
  73. data/spec/dummy/app/models/dummy/module/ancestor.rb +0 -67
  74. data/spec/dummy/app/models/dummy/module/architecture.rb +0 -19
  75. data/spec/dummy/app/models/dummy/module/author.rb +0 -28
  76. data/spec/dummy/app/models/dummy/module/class.rb +0 -69
  77. data/spec/dummy/app/models/dummy/module/instance.rb +0 -209
  78. data/spec/dummy/app/models/dummy/module/path.rb +0 -64
  79. data/spec/dummy/app/models/dummy/module/platform.rb +0 -19
  80. data/spec/dummy/app/models/dummy/module/rank.rb +0 -44
  81. data/spec/dummy/app/models/dummy/module/reference.rb +0 -19
  82. data/spec/dummy/app/models/dummy/module/target.rb +0 -62
  83. data/spec/dummy/app/models/dummy/module/target/architecture.rb +0 -19
  84. data/spec/dummy/app/models/dummy/module/target/platform.rb +0 -19
  85. data/spec/dummy/app/models/dummy/platform.rb +0 -58
  86. data/spec/dummy/app/models/dummy/reference.rb +0 -31
  87. data/spec/dummy/spec/factories/dummy/architectures.rb +0 -13
  88. data/spec/dummy/spec/factories/dummy/authorities.rb +0 -32
  89. data/spec/dummy/spec/factories/dummy/authors.rb +0 -8
  90. data/spec/dummy/spec/factories/dummy/email_addresses.rb +0 -8
  91. data/spec/dummy/spec/factories/dummy/module/actions.rb +0 -13
  92. data/spec/dummy/spec/factories/dummy/module/ancestors.rb +0 -45
  93. data/spec/dummy/spec/factories/dummy/module/architectures.rb +0 -35
  94. data/spec/dummy/spec/factories/dummy/module/authors.rb +0 -10
  95. data/spec/dummy/spec/factories/dummy/module/classes.rb +0 -40
  96. data/spec/dummy/spec/factories/dummy/module/instances.rb +0 -86
  97. data/spec/dummy/spec/factories/dummy/module/paths.rb +0 -16
  98. data/spec/dummy/spec/factories/dummy/module/platforms.rb +0 -35
  99. data/spec/dummy/spec/factories/dummy/module/ranks.rb +0 -14
  100. data/spec/dummy/spec/factories/dummy/module/references.rb +0 -17
  101. data/spec/dummy/spec/factories/dummy/module/target/architectures.rb +0 -40
  102. data/spec/dummy/spec/factories/dummy/module/target/platforms.rb +0 -41
  103. data/spec/dummy/spec/factories/dummy/module/targets.rb +0 -46
  104. data/spec/dummy/spec/factories/dummy/platforms.rb +0 -3
  105. data/spec/dummy/spec/factories/dummy/references.rb +0 -26
  106. data/spec/factories/metasploit/model/architectures.rb +0 -6
  107. data/spec/factories/metasploit/model/authorities.rb +0 -28
  108. data/spec/factories/metasploit/model/authors.rb +0 -9
  109. data/spec/factories/metasploit/model/email_addresses.rb +0 -14
  110. data/spec/factories/metasploit/model/module/actions.rb +0 -9
  111. data/spec/factories/metasploit/model/module/ancestors.rb +0 -180
  112. data/spec/factories/metasploit/model/module/architectures.rb +0 -15
  113. data/spec/factories/metasploit/model/module/classes.rb +0 -47
  114. data/spec/factories/metasploit/model/module/handlers.rb +0 -3
  115. data/spec/factories/metasploit/model/module/instances.rb +0 -83
  116. data/spec/factories/metasploit/model/module/paths.rb +0 -51
  117. data/spec/factories/metasploit/model/module/platforms.rb +0 -15
  118. data/spec/factories/metasploit/model/module/ranks.rb +0 -9
  119. data/spec/factories/metasploit/model/module/references.rb +0 -11
  120. data/spec/factories/metasploit/model/module/stances.rb +0 -3
  121. data/spec/factories/metasploit/model/module/targets.rb +0 -22
  122. data/spec/factories/metasploit/model/module/types.rb +0 -5
  123. data/spec/factories/metasploit/model/references.rb +0 -88
  124. data/spec/lib/metasploit/model/architecture_spec.rb +0 -52
  125. data/spec/lib/metasploit/model/author_spec.rb +0 -6
  126. data/spec/lib/metasploit/model/authority/bid_spec.rb +0 -17
  127. data/spec/lib/metasploit/model/authority/cve_spec.rb +0 -17
  128. data/spec/lib/metasploit/model/authority/msb_spec.rb +0 -17
  129. data/spec/lib/metasploit/model/authority/osvdb_spec.rb +0 -17
  130. data/spec/lib/metasploit/model/authority/pmasa_spec.rb +0 -17
  131. data/spec/lib/metasploit/model/authority/secunia_spec.rb +0 -17
  132. data/spec/lib/metasploit/model/authority/us_cert_vu_spec.rb +0 -17
  133. data/spec/lib/metasploit/model/authority/waraxe_spec.rb +0 -51
  134. data/spec/lib/metasploit/model/authority/zdi_spec.rb +0 -21
  135. data/spec/lib/metasploit/model/authority_spec.rb +0 -10
  136. data/spec/lib/metasploit/model/derivation/full_name_spec.rb +0 -75
  137. data/spec/lib/metasploit/model/derivation_spec.rb +0 -217
  138. data/spec/lib/metasploit/model/email_address_spec.rb +0 -19
  139. data/spec/lib/metasploit/model/module/action_spec.rb +0 -6
  140. data/spec/lib/metasploit/model/module/ancestor_spec.rb +0 -6
  141. data/spec/lib/metasploit/model/module/architecture_spec.rb +0 -9
  142. data/spec/lib/metasploit/model/module/author_spec.rb +0 -6
  143. data/spec/lib/metasploit/model/module/class_spec.rb +0 -19
  144. data/spec/lib/metasploit/model/module/handler_spec.rb +0 -61
  145. data/spec/lib/metasploit/model/module/instance_spec.rb +0 -183
  146. data/spec/lib/metasploit/model/module/path_spec.rb +0 -6
  147. data/spec/lib/metasploit/model/module/platform_spec.rb +0 -9
  148. data/spec/lib/metasploit/model/module/rank_spec.rb +0 -29
  149. data/spec/lib/metasploit/model/module/reference_spec.rb +0 -9
  150. data/spec/lib/metasploit/model/module/stance_spec.rb +0 -30
  151. data/spec/lib/metasploit/model/module/target/architecture_spec.rb +0 -9
  152. data/spec/lib/metasploit/model/module/target/platform_spec.rb +0 -9
  153. data/spec/lib/metasploit/model/module/target_spec.rb +0 -9
  154. data/spec/lib/metasploit/model/module/type_spec.rb +0 -125
  155. data/spec/lib/metasploit/model/platform_spec.rb +0 -100
  156. data/spec/lib/metasploit/model/reference_spec.rb +0 -21
  157. data/spec/support/shared/contexts/metasploit/model/module/ancestor/contents/metasploit_module.rb +0 -12
  158. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents.rb +0 -10
  159. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents/metasploit_module.rb +0 -15
  160. data/spec/support/shared/examples/derives.rb +0 -115
  161. data/spec/support/shared/examples/metasploit/model/architecture.rb +0 -425
  162. data/spec/support/shared/examples/metasploit/model/architecture/seed.rb +0 -25
  163. data/spec/support/shared/examples/metasploit/model/author.rb +0 -27
  164. data/spec/support/shared/examples/metasploit/model/authority.rb +0 -124
  165. data/spec/support/shared/examples/metasploit/model/authority/seed.rb +0 -49
  166. data/spec/support/shared/examples/metasploit/model/email_address.rb +0 -220
  167. data/spec/support/shared/examples/metasploit/model/module/action.rb +0 -26
  168. data/spec/support/shared/examples/metasploit/model/module/ancestor.rb +0 -2004
  169. data/spec/support/shared/examples/metasploit/model/module/ancestor/payload_factory.rb +0 -63
  170. data/spec/support/shared/examples/metasploit/model/module/architecture.rb +0 -36
  171. data/spec/support/shared/examples/metasploit/model/module/author.rb +0 -29
  172. data/spec/support/shared/examples/metasploit/model/module/class.rb +0 -1514
  173. data/spec/support/shared/examples/metasploit/model/module/handler.rb +0 -21
  174. data/spec/support/shared/examples/metasploit/model/module/instance.rb +0 -1384
  175. data/spec/support/shared/examples/metasploit/model/module/instance/class_methods.rb +0 -537
  176. data/spec/support/shared/examples/metasploit/model/module/instance/is_not_stanced_with_module_type.rb +0 -22
  177. data/spec/support/shared/examples/metasploit/model/module/instance/is_stanced_with_module_type.rb +0 -38
  178. data/spec/support/shared/examples/metasploit/model/module/instance/validates/dynamic_length_of.rb +0 -131
  179. data/spec/support/shared/examples/metasploit/model/module/path.rb +0 -493
  180. data/spec/support/shared/examples/metasploit/model/module/platform.rb +0 -36
  181. data/spec/support/shared/examples/metasploit/model/module/rank.rb +0 -92
  182. data/spec/support/shared/examples/metasploit/model/module/reference.rb +0 -16
  183. data/spec/support/shared/examples/metasploit/model/module/target.rb +0 -29
  184. data/spec/support/shared/examples/metasploit/model/module/target/architecture.rb +0 -56
  185. data/spec/support/shared/examples/metasploit/model/module/target/platform.rb +0 -56
  186. data/spec/support/shared/examples/metasploit/model/platform.rb +0 -213
  187. data/spec/support/shared/examples/metasploit/model/real_pathname.rb +0 -29
  188. data/spec/support/shared/examples/metasploit/model/reference.rb +0 -410
  189. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/app.rb +0 -44
  190. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +0 -72
  191. data/spec/support/templates/metasploit/model/module/ancestors/_attributes.rb.erb +0 -9
  192. data/spec/support/templates/metasploit/model/module/ancestors/_methods.rb.erb +0 -8
  193. data/spec/support/templates/metasploit/model/module/ancestors/_validations.rb.erb +0 -6
  194. data/spec/support/templates/metasploit/model/module/ancestors/base.rb.erb +0 -3
  195. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_auxiliary.rb.erb +0 -1
  196. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_encoder.rb.erb +0 -1
  197. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_exploit.rb.erb +0 -1
  198. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_non_payload.rb.erb +0 -5
  199. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_nop.rb.erb +0 -1
  200. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_payload.rb.erb +0 -4
  201. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_post.rb.erb +0 -1
  202. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_handled.rb.erb +0 -20
  203. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_single.rb.erb +0 -1
  204. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stage.rb.erb +0 -0
  205. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stager.rb.erb +0 -1
  206. data/spec/support/templates/metasploit/model/module/classes/_methods.rb.erb +0 -9
@@ -1,34 +0,0 @@
1
- # Model that joins {Metasploit::Model::Platform} and {Metasploit::Model::Module::Target}.
2
- module Metasploit::Model::Module::Target::Platform
3
- extend ActiveModel::Naming
4
- extend ActiveSupport::Concern
5
-
6
- include Metasploit::Model::Translation
7
-
8
- included do
9
- include ActiveModel::Validations
10
-
11
- #
12
- # Validations
13
- #
14
-
15
- validates :module_target,
16
- presence: true
17
- validates :platform,
18
- presence: true
19
- end
20
-
21
- #
22
- # Associations
23
- #
24
-
25
- # @!attribute [rw] module_target
26
- # The module target that supports {#platform}.
27
- #
28
- # @return [Metasploit::Model::Module::Target]
29
-
30
- # @!attribute [rw] platform
31
- # The platform supported by the {#module_target}.
32
- #
33
- # @return [Metasploit::Model::Platform]
34
- end
@@ -1,38 +0,0 @@
1
- # Defines constants for {Metasploit::Model::Module} types as used in {Metasploit::Model::Module::Ancestor}.
2
- module Metasploit::Model::Module::Type
3
- #
4
- # CONSTANTS
5
- #
6
-
7
- # Symbolizes any module type is allowed.
8
- ANY = '_any_'
9
- # Auxiliary modules
10
- AUX = 'auxiliary'
11
- # Encoder modules
12
- ENCODER = 'encoder'
13
- # Exploit modules
14
- EXPLOIT = 'exploit'
15
- # No operation modules
16
- NOP = 'nop'
17
- # Payload modules
18
- PAYLOAD = 'payload'
19
- # Post-exploitation modules
20
- POST = 'post'
21
-
22
- # Array<String> of all supported module types (except {ANY} since that's a symbolic type)
23
- ALL = [
24
- AUX,
25
- ENCODER,
26
- EXPLOIT,
27
- NOP,
28
- PAYLOAD,
29
- POST
30
- ]
31
-
32
- # Array<String> of all module types that aren't {PAYLOAD} because {PAYLOAD}
33
- # {Metasploit::Model::Module::Ancestor#contents} define `Modules` instead of `Classes` and so need to be loaded
34
- # differently.
35
- NON_PAYLOAD = ALL.reject { |module_type|
36
- module_type == PAYLOAD
37
- }
38
- end
@@ -1,246 +0,0 @@
1
- # Code shared between `Mdm::Platform` and `Metasploit::Framework::Platform`.
2
- module Metasploit::Model::Platform
3
- extend ActiveModel::Naming
4
- extend ActiveSupport::Concern
5
-
6
- include Metasploit::Model::Translation
7
-
8
- #
9
- # CONSTANTS
10
- #
11
-
12
- # Platforms are seeded in a hierarchy with deeper levels refining higher levels, so 'Windows 98 SE' is a
13
- # refinement of 'Windows 98', which is a refinement of 'Windows'.
14
- SEED_RELATIVE_NAME_TREE = {
15
- 'AIX' => nil,
16
- 'Android' => nil,
17
- 'BSD' => nil,
18
- 'BSDi' => nil,
19
- 'Cisco' => nil,
20
- 'Firefox' => nil,
21
- 'FreeBSD' => nil,
22
- 'HPUX' => nil,
23
- 'IRIX' => nil,
24
- 'Java' => nil,
25
- 'Javascript' => nil,
26
- 'Linux' => nil,
27
- 'NetBSD' => nil,
28
- 'Netware' => nil,
29
- 'NodeJS' => nil,
30
- 'OpenBSD' => nil,
31
- 'OSX' => nil,
32
- 'PHP' => nil,
33
- 'Python' => nil,
34
- 'Ruby' => nil,
35
- 'Solaris' => {
36
- '4' => nil,
37
- '5' => nil,
38
- '6' => nil,
39
- '7' => nil,
40
- '8' => nil,
41
- '9' => nil,
42
- '10' => nil
43
- },
44
- 'Windows' => {
45
- '95' => nil,
46
- '98' => {
47
- 'FE' => nil,
48
- 'SE' => nil
49
- },
50
- 'ME' => nil,
51
- 'NT' => {
52
- 'SP0' => nil,
53
- 'SP1' => nil,
54
- 'SP2' => nil,
55
- 'SP3' => nil,
56
- 'SP4' => nil,
57
- 'SP5' => nil,
58
- 'SP6' => nil,
59
- 'SP6a' => nil
60
- },
61
- '2000' => {
62
- 'SP0' => nil,
63
- 'SP1' => nil,
64
- 'SP2' => nil,
65
- 'SP3' => nil,
66
- 'SP4' => nil
67
- },
68
- 'XP' => {
69
- 'SP0' => nil,
70
- 'SP1' => nil,
71
- 'SP2' => nil,
72
- 'SP3' => nil
73
- },
74
- '2003' => {
75
- 'SP0' => nil,
76
- 'SP1' => nil
77
- },
78
- 'Vista' => {
79
- 'SP0' => nil,
80
- 'SP1' => nil
81
- },
82
- '7' => nil
83
- },
84
- 'UNIX' => nil
85
- }
86
-
87
- included do
88
- include ActiveModel::MassAssignmentSecurity
89
- include ActiveModel::Validations
90
- include Metasploit::Model::Derivation
91
- include Metasploit::Model::Search
92
-
93
- #
94
- # Derivations
95
- #
96
-
97
- derives :fully_qualified_name, :validate => true
98
-
99
- #
100
- # Mass Assignment Security
101
- #
102
-
103
- attr_accessible :relative_name
104
-
105
- #
106
- # Search
107
- #
108
-
109
- search_attribute :fully_qualified_name,
110
- type: {
111
- set: :string
112
- }
113
-
114
- #
115
- # Validation
116
- #
117
-
118
- validates :fully_qualified_name,
119
- inclusion: {
120
- in: Metasploit::Model::Platform.fully_qualified_name_set
121
- }
122
- validates :relative_name,
123
- presence: true
124
- end
125
-
126
- # Adds {#fully_qualified_name_set} to class.
127
- module ClassMethods
128
- # Set of valid {Metasploit::Model::Platform#fully_qualified_name}.
129
- #
130
- # @return [Set<String>]
131
- def fully_qualified_name_set
132
- Metasploit::Model::Platform.fully_qualified_name_set
133
- end
134
- end
135
-
136
- #
137
- # Attributes
138
- #
139
-
140
- # @!attribute [rw] fully_qualified_name
141
- # The fully qualified name of this platform, as would be used in the platform list in a metasploit-framework
142
- # module.
143
- #
144
- # @return [String]
145
-
146
- # @!attribute [rw] parent
147
- # The parent platform of this platform. For example, Windows is parent of Windows 98, which is the parent of
148
- # Windows 98 FE.
149
- #
150
- # @return [nil] if this is a top-level platform, such as Windows or Linux.
151
- # @return [Metasploit::Model::Platform]
152
-
153
- # @!attribute [rw] relative_name
154
- # The name of this platform relative to the {#fully_qualified_name} of {#parent}.
155
- #
156
- # @return [String]
157
-
158
- #
159
- # Methods
160
- #
161
-
162
- # Derives {#fully_qualified_name} from {#parent}'s {#fully_qualified_name} and this platform's {#relative_name}.
163
- #
164
- # @return [nil] if {#relative_name} is blank.
165
- # @return [String] {#relative_name} if {#parent} is `nil`.
166
- # @return [String] '<{#parent} {#relative_name}> <{#relative_name}>' if {#parent} is not `nil`.
167
- def derived_fully_qualified_name
168
- if relative_name.present?
169
- if parent
170
- "#{parent.fully_qualified_name} #{relative_name}"
171
- else
172
- relative_name
173
- end
174
- end
175
- end
176
-
177
- # @note Not defined in `ClassMethods` because consumers should always refer back to {Metasploit::Model::Platform}
178
- # when seeding.
179
- #
180
- # @param options [Hash{Symbol => Object, Hash}]
181
- # @option options [Object] :parent (nil) The parent object to which to attach the children.
182
- # @option options [Hash{String => nil,Hash}] :grandchildren_by_child_relative_name
183
- # ({SEED_RELATIVE_NAME_TREE}) Maps {#relative_name} of children under :parent to their children
184
- # (grandchildren of parent). Grandchildren can be `nil` or another recursive `Hash` of names and their
185
- # descendants.
186
- # @yield [attributes] Block should construct child object using attributes.
187
- # @yieldparam attributes [Hash{Symbol => Object,String}] Hash containing attributes for child object, include
188
- # :parent for {#parent} and :relative_name for {#relative_name}.
189
- # @yieldreturn [Object] child derived from :parent and :relative_name to be used as the parent for
190
- # grandchildren.
191
- # @return [void]
192
- def self.each_seed_attributes(options={}, &block)
193
- options.assert_valid_keys(:parent, :grandchildren_by_child_relative_name)
194
-
195
- parent = options[:parent]
196
- grandchildren_by_child_relative_name = options.fetch(
197
- :grandchildren_by_child_relative_name,
198
- SEED_RELATIVE_NAME_TREE
199
- )
200
-
201
- grandchildren_by_child_relative_name.each do |child_relative_name, great_grandchildren_by_grandchild_relative_name|
202
- attributes = {
203
- parent: parent,
204
- relative_name: child_relative_name
205
- }
206
- child = block.call(attributes)
207
-
208
- if great_grandchildren_by_grandchild_relative_name
209
- each_seed_attributes(
210
- grandchildren_by_child_relative_name: great_grandchildren_by_grandchild_relative_name,
211
- parent: child,
212
- &block
213
- )
214
- end
215
- end
216
- end
217
-
218
- # List of valid {#fully_qualified_name} derived from {SEED_RELATIVE_NAME_TREE}.
219
- #
220
- # @return [Array<String>]
221
- def self.fully_qualified_name_set
222
- unless instance_variable_defined? :@fully_qualified_name_set
223
- @fully_qualified_name_set = Set.new
224
-
225
- each_seed_attributes do |attributes|
226
- parent = attributes.fetch(:parent)
227
- relative_name = attributes.fetch(:relative_name)
228
-
229
- if parent
230
- fully_qualified_name = "#{parent} #{relative_name}"
231
- else
232
- fully_qualified_name = relative_name
233
- end
234
-
235
- @fully_qualified_name_set.add fully_qualified_name
236
-
237
- # yieldreturn
238
- fully_qualified_name
239
- end
240
-
241
- @fully_qualified_name_set.freeze
242
- end
243
-
244
- @fully_qualified_name_set
245
- end
246
- end
@@ -1,16 +0,0 @@
1
- require 'pathname'
2
-
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
14
- end
15
- end
16
- end
@@ -1,104 +0,0 @@
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)
100
- end
101
-
102
- derived
103
- end
104
- end
@@ -1,174 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Module::Ancestor::Spec::Template do
4
- subject(:template) do
5
- described_class.new(
6
- module_ancestor: module_ancestor
7
- )
8
- end
9
-
10
- let(:module_ancestor) do
11
- FactoryGirl.build(:dummy_module_ancestor)
12
- end
13
-
14
- context 'CONSTANTS' do
15
- context 'DEFAULT_SEARCH_PATHNAMES' do
16
- subject(:default_search_pathnames) do
17
- described_class::DEFAULT_SEARCH_PATHNAMES
18
- end
19
-
20
- it "includes 'module/ancestors'" do
21
- expect(default_search_pathnames).to include(Pathname.new('module/ancestors'))
22
- end
23
- end
24
-
25
- context 'DEFAULT_SOURCE_RELATIVE_NAME' do
26
- subject(:default_source_relative_name) do
27
- described_class::DEFAULT_SOURCE_RELATIVE_NAME
28
- end
29
-
30
- it { should == 'base' }
31
- end
32
- end
33
-
34
- context 'validations' do
35
- it { should validate_presence_of :module_ancestor }
36
- end
37
-
38
- context '#destination_pathname' do
39
- subject(:destination_pathname) do
40
- template.destination_pathname
41
- end
42
-
43
- context 'with #module_ancestor' do
44
- it 'defaults to module_ancestor.real_pathname' do
45
- expect(destination_pathname).to eq(module_ancestor.real_pathname)
46
- end
47
- end
48
-
49
- context 'without #module_ancestor' do
50
- let(:module_ancestor) do
51
- nil
52
- end
53
-
54
- it { should be_nil }
55
- end
56
- end
57
-
58
- context '#locals' do
59
- subject(:locals) do
60
- template.locals
61
- end
62
-
63
- it { should be_a Hash }
64
-
65
- context '[:metasploit_module_relative_name]' do
66
- subject(:metasploit_module_relative_name) do
67
- locals[:metasploit_module_relative_name]
68
- end
69
-
70
- it 'is #metasploit_module_relative_name' do
71
- expect(metasploit_module_relative_name).to eq(template.metasploit_module_relative_name)
72
- end
73
- end
74
-
75
- context '[:module_ancestor]' do
76
- subject(:locals_module_ancestor) do
77
- locals[:module_ancestor]
78
- end
79
-
80
- it 'is #module_ancestor' do
81
- expect(locals_module_ancestor).to eq(template.module_ancestor)
82
- end
83
- end
84
- end
85
-
86
- context '#metasploit_module_relative_name' do
87
- subject(:metasploit_module_relative_name) do
88
- template.metasploit_module_relative_name
89
- end
90
-
91
- it { should be_a String }
92
-
93
- it 'uses FactoryGirl.generate' do
94
- # ensure template is memoized so only metasploit_module_relative_name's usage of FactoryGirl is seen
95
- template
96
-
97
- expect(FactoryGirl).to receive(:generate).with(:metasploit_model_module_ancestor_metasploit_module_relative_name).and_call_original
98
-
99
- metasploit_module_relative_name
100
- end
101
- end
102
-
103
- context '#overwrite' do
104
- subject(:overwrite) do
105
- template.overwrite
106
- end
107
-
108
- it { should be_false }
109
- end
110
-
111
- context '#search_pathnames' do
112
- subject(:search_pathnames) do
113
- template.search_pathnames
114
- end
115
-
116
- it 'uses DEFAULT_SEARCH_PATHNAMES' do
117
- expect(search_pathnames).to match_array(described_class::DEFAULT_SEARCH_PATHNAMES)
118
- end
119
- end
120
-
121
- context '#source_relative_name' do
122
- subject(:source_relative_name) do
123
- template.source_relative_name
124
- end
125
-
126
- it 'uses DEFAULT_SOURCE_RELATIVE_NAME' do
127
- expect(source_relative_name).to eq(described_class::DEFAULT_SOURCE_RELATIVE_NAME)
128
- end
129
- end
130
-
131
- context 'write' do
132
- subject(:write) do
133
- described_class.write(attributes)
134
- end
135
-
136
- before(:each) do
137
- # Since overwrite is false, have to delete the template that the factories make.
138
- module_ancestor.real_pathname.delete
139
- end
140
-
141
- context 'with valid' do
142
- let(:attributes) do
143
- {
144
- module_ancestor: module_ancestor
145
- }
146
- end
147
-
148
- it { should be_true }
149
-
150
- it 'writes template' do
151
- # memoize attributes so any other writes besides the one under-test are already run.
152
- attributes
153
-
154
- described_class.any_instance.should_receive(:write)
155
-
156
- write
157
- end
158
- end
159
-
160
- context 'without valid' do
161
- let(:attributes) do
162
- {}
163
- end
164
-
165
- it { should be_false }
166
-
167
- it 'does not write template' do
168
- described_class.any_instance.should_not_receive(:write)
169
-
170
- write
171
- end
172
- end
173
- end
174
- end