metasploit-model 0.24.1.pre.semantic.pre.versioning.pre.2.pre.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (380) hide show
  1. checksums.yaml +15 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +27 -0
  4. data/.rspec +4 -0
  5. data/.simplecov +38 -0
  6. data/.travis.yml +6 -0
  7. data/.yardopts +5 -0
  8. data/Gemfile +43 -0
  9. data/LICENSE +27 -0
  10. data/README.md +33 -0
  11. data/Rakefile +52 -0
  12. data/app/models/metasploit/model/association/reflection.rb +46 -0
  13. data/app/models/metasploit/model/module/ancestor/spec/template.rb +125 -0
  14. data/app/models/metasploit/model/module/class/spec/template.rb +92 -0
  15. data/app/models/metasploit/model/module/instance/spec/template.rb +97 -0
  16. data/app/models/metasploit/model/search/group/base.rb +21 -0
  17. data/app/models/metasploit/model/search/group/intersection.rb +4 -0
  18. data/app/models/metasploit/model/search/group/union.rb +4 -0
  19. data/app/models/metasploit/model/search/operation/base.rb +39 -0
  20. data/app/models/metasploit/model/search/operation/boolean.rb +36 -0
  21. data/app/models/metasploit/model/search/operation/date.rb +37 -0
  22. data/app/models/metasploit/model/search/operation/integer.rb +14 -0
  23. data/app/models/metasploit/model/search/operation/null.rb +26 -0
  24. data/app/models/metasploit/model/search/operation/set.rb +34 -0
  25. data/app/models/metasploit/model/search/operation/set/integer.rb +5 -0
  26. data/app/models/metasploit/model/search/operation/set/string.rb +5 -0
  27. data/app/models/metasploit/model/search/operation/string.rb +11 -0
  28. data/app/models/metasploit/model/search/operation/union.rb +59 -0
  29. data/app/models/metasploit/model/search/operator/association.rb +43 -0
  30. data/app/models/metasploit/model/search/operator/attribute.rb +60 -0
  31. data/app/models/metasploit/model/search/operator/base.rb +34 -0
  32. data/app/models/metasploit/model/search/operator/delegation.rb +40 -0
  33. data/app/models/metasploit/model/search/operator/deprecated/app.rb +27 -0
  34. data/app/models/metasploit/model/search/operator/deprecated/author.rb +33 -0
  35. data/app/models/metasploit/model/search/operator/deprecated/authority.rb +43 -0
  36. data/app/models/metasploit/model/search/operator/deprecated/platform.rb +45 -0
  37. data/app/models/metasploit/model/search/operator/deprecated/ref.rb +50 -0
  38. data/app/models/metasploit/model/search/operator/deprecated/text.rb +32 -0
  39. data/app/models/metasploit/model/search/operator/null.rb +44 -0
  40. data/app/models/metasploit/model/search/operator/single.rb +98 -0
  41. data/app/models/metasploit/model/search/operator/union.rb +33 -0
  42. data/app/models/metasploit/model/search/query.rb +171 -0
  43. data/app/models/metasploit/model/spec/template.rb +273 -0
  44. data/app/models/metasploit/model/visitation/visitor.rb +69 -0
  45. data/app/validators/derivation_validator.rb +17 -0
  46. data/app/validators/dynamic_length_validator.rb +45 -0
  47. data/app/validators/ip_format_validator.rb +31 -0
  48. data/app/validators/nil_validator.rb +16 -0
  49. data/app/validators/parameters_validator.rb +147 -0
  50. data/app/validators/password_is_strong_validator.rb +115 -0
  51. data/config/locales/en.yml +209 -0
  52. data/lib/metasploit/model.rb +38 -0
  53. data/lib/metasploit/model/architecture.rb +346 -0
  54. data/lib/metasploit/model/association.rb +49 -0
  55. data/lib/metasploit/model/association/error.rb +40 -0
  56. data/lib/metasploit/model/author.rb +58 -0
  57. data/lib/metasploit/model/authority.rb +134 -0
  58. data/lib/metasploit/model/authority/bid.rb +10 -0
  59. data/lib/metasploit/model/authority/cve.rb +10 -0
  60. data/lib/metasploit/model/authority/msb.rb +10 -0
  61. data/lib/metasploit/model/authority/osvdb.rb +10 -0
  62. data/lib/metasploit/model/authority/pmasa.rb +10 -0
  63. data/lib/metasploit/model/authority/secunia.rb +10 -0
  64. data/lib/metasploit/model/authority/us_cert_vu.rb +10 -0
  65. data/lib/metasploit/model/authority/waraxe.rb +31 -0
  66. data/lib/metasploit/model/authority/zdi.rb +10 -0
  67. data/lib/metasploit/model/base.rb +25 -0
  68. data/lib/metasploit/model/configuration.rb +72 -0
  69. data/lib/metasploit/model/configuration/autoload.rb +109 -0
  70. data/lib/metasploit/model/configuration/child.rb +12 -0
  71. data/lib/metasploit/model/configuration/error.rb +4 -0
  72. data/lib/metasploit/model/configuration/i18n.rb +54 -0
  73. data/lib/metasploit/model/configuration/parent.rb +50 -0
  74. data/lib/metasploit/model/configured.rb +46 -0
  75. data/lib/metasploit/model/derivation.rb +110 -0
  76. data/lib/metasploit/model/derivation/full_name.rb +25 -0
  77. data/lib/metasploit/model/email_address.rb +128 -0
  78. data/lib/metasploit/model/engine.rb +34 -0
  79. data/lib/metasploit/model/error.rb +7 -0
  80. data/lib/metasploit/model/file.rb +49 -0
  81. data/lib/metasploit/model/invalid.rb +17 -0
  82. data/lib/metasploit/model/module.rb +8 -0
  83. data/lib/metasploit/model/module/action.rb +58 -0
  84. data/lib/metasploit/model/module/ancestor.rb +494 -0
  85. data/lib/metasploit/model/module/architecture.rb +40 -0
  86. data/lib/metasploit/model/module/author.rb +47 -0
  87. data/lib/metasploit/model/module/class.rb +406 -0
  88. data/lib/metasploit/model/module/handler.rb +35 -0
  89. data/lib/metasploit/model/module/instance.rb +626 -0
  90. data/lib/metasploit/model/module/path.rb +165 -0
  91. data/lib/metasploit/model/module/platform.rb +38 -0
  92. data/lib/metasploit/model/module/rank.rb +91 -0
  93. data/lib/metasploit/model/module/reference.rb +38 -0
  94. data/lib/metasploit/model/module/stance.rb +22 -0
  95. data/lib/metasploit/model/module/target.rb +80 -0
  96. data/lib/metasploit/model/module/target/architecture.rb +42 -0
  97. data/lib/metasploit/model/module/target/platform.rb +42 -0
  98. data/lib/metasploit/model/module/type.rb +44 -0
  99. data/lib/metasploit/model/nilify_blanks.rb +53 -0
  100. data/lib/metasploit/model/platform.rb +250 -0
  101. data/lib/metasploit/model/real_pathname.rb +18 -0
  102. data/lib/metasploit/model/reference.rb +108 -0
  103. data/lib/metasploit/model/search.rb +63 -0
  104. data/lib/metasploit/model/search/association.rb +32 -0
  105. data/lib/metasploit/model/search/attribute.rb +51 -0
  106. data/lib/metasploit/model/search/operation.rb +31 -0
  107. data/lib/metasploit/model/search/operation/integer/value.rb +33 -0
  108. data/lib/metasploit/model/search/operation/string/value.rb +14 -0
  109. data/lib/metasploit/model/search/operator.rb +10 -0
  110. data/lib/metasploit/model/search/operator/help.rb +47 -0
  111. data/lib/metasploit/model/search/with.rb +40 -0
  112. data/lib/metasploit/model/spec.rb +140 -0
  113. data/lib/metasploit/model/spec/error.rb +9 -0
  114. data/lib/metasploit/model/spec/i18n_exception_handler.rb +19 -0
  115. data/lib/metasploit/model/spec/pathname_collision.rb +28 -0
  116. data/lib/metasploit/model/spec/template/write.rb +42 -0
  117. data/lib/metasploit/model/spec/temporary_pathname.rb +59 -0
  118. data/lib/metasploit/model/translation.rb +31 -0
  119. data/lib/metasploit/model/version.rb +33 -0
  120. data/lib/metasploit/model/visitation.rb +9 -0
  121. data/lib/metasploit/model/visitation/visit.rb +103 -0
  122. data/lib/tasks/yard.rake +30 -0
  123. data/metasploit-model.gemspec +39 -0
  124. data/script/rails +9 -0
  125. data/spec/app/models/metasploit/model/association/reflection_spec.rb +48 -0
  126. data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +174 -0
  127. data/spec/app/models/metasploit/model/module/class/spec/template_spec.rb +222 -0
  128. data/spec/app/models/metasploit/model/module/instance/spec/template_spec.rb +201 -0
  129. data/spec/app/models/metasploit/model/search/group/base_spec.rb +5 -0
  130. data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +5 -0
  131. data/spec/app/models/metasploit/model/search/group/union_spec.rb +5 -0
  132. data/spec/app/models/metasploit/model/search/operation/base_spec.rb +70 -0
  133. data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +56 -0
  134. data/spec/app/models/metasploit/model/search/operation/date_spec.rb +89 -0
  135. data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +9 -0
  136. data/spec/app/models/metasploit/model/search/operation/null_spec.rb +64 -0
  137. data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +7 -0
  138. data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +7 -0
  139. data/spec/app/models/metasploit/model/search/operation/set_spec.rb +126 -0
  140. data/spec/app/models/metasploit/model/search/operation/string_spec.rb +9 -0
  141. data/spec/app/models/metasploit/model/search/operation/union_spec.rb +124 -0
  142. data/spec/app/models/metasploit/model/search/operator/association_spec.rb +108 -0
  143. data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +104 -0
  144. data/spec/app/models/metasploit/model/search/operator/base_spec.rb +34 -0
  145. data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +108 -0
  146. data/spec/app/models/metasploit/model/search/operator/deprecated/app_spec.rb +62 -0
  147. data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +161 -0
  148. data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +123 -0
  149. data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +112 -0
  150. data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +327 -0
  151. data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +357 -0
  152. data/spec/app/models/metasploit/model/search/operator/null_spec.rb +41 -0
  153. data/spec/app/models/metasploit/model/search/operator/single_spec.rb +327 -0
  154. data/spec/app/models/metasploit/model/search/operator/union_spec.rb +92 -0
  155. data/spec/app/models/metasploit/model/search/query_spec.rb +742 -0
  156. data/spec/app/models/metasploit/model/spec/template_spec.rb +23 -0
  157. data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +45 -0
  158. data/spec/app/validators/derivation_validator_spec.rb +92 -0
  159. data/spec/app/validators/dynamic_length_validator_spec.rb +293 -0
  160. data/spec/app/validators/ip_format_validator_spec.rb +124 -0
  161. data/spec/app/validators/nil_validator_spec.rb +69 -0
  162. data/spec/app/validators/parameters_validator_spec.rb +342 -0
  163. data/spec/app/validators/password_is_strong_validator_spec.rb +250 -0
  164. data/spec/dummy/Rakefile +7 -0
  165. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  166. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  167. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  168. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  169. data/spec/dummy/app/mailers/.gitkeep +0 -0
  170. data/spec/dummy/app/models/dummy/architecture.rb +92 -0
  171. data/spec/dummy/app/models/dummy/author.rb +15 -0
  172. data/spec/dummy/app/models/dummy/authority.rb +130 -0
  173. data/spec/dummy/app/models/dummy/email_address.rb +27 -0
  174. data/spec/dummy/app/models/dummy/module/action.rb +25 -0
  175. data/spec/dummy/app/models/dummy/module/ancestor.rb +67 -0
  176. data/spec/dummy/app/models/dummy/module/architecture.rb +19 -0
  177. data/spec/dummy/app/models/dummy/module/author.rb +28 -0
  178. data/spec/dummy/app/models/dummy/module/class.rb +69 -0
  179. data/spec/dummy/app/models/dummy/module/instance.rb +209 -0
  180. data/spec/dummy/app/models/dummy/module/path.rb +64 -0
  181. data/spec/dummy/app/models/dummy/module/platform.rb +19 -0
  182. data/spec/dummy/app/models/dummy/module/rank.rb +44 -0
  183. data/spec/dummy/app/models/dummy/module/reference.rb +19 -0
  184. data/spec/dummy/app/models/dummy/module/target.rb +62 -0
  185. data/spec/dummy/app/models/dummy/module/target/architecture.rb +19 -0
  186. data/spec/dummy/app/models/dummy/module/target/platform.rb +19 -0
  187. data/spec/dummy/app/models/dummy/platform.rb +58 -0
  188. data/spec/dummy/app/models/dummy/reference.rb +31 -0
  189. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  190. data/spec/dummy/config.ru +4 -0
  191. data/spec/dummy/config/application.rb +43 -0
  192. data/spec/dummy/config/boot.rb +10 -0
  193. data/spec/dummy/config/environment.rb +5 -0
  194. data/spec/dummy/config/environments/development.rb +27 -0
  195. data/spec/dummy/config/environments/production.rb +63 -0
  196. data/spec/dummy/config/environments/test.rb +29 -0
  197. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  198. data/spec/dummy/config/initializers/inflections.rb +15 -0
  199. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  200. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  201. data/spec/dummy/config/initializers/session_store.rb +3 -0
  202. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  203. data/spec/dummy/config/locales/en.yml +1 -0
  204. data/spec/dummy/config/routes.rb +2 -0
  205. data/spec/dummy/db/schema.rb +707 -0
  206. data/spec/dummy/lib/assets/.gitkeep +0 -0
  207. data/spec/dummy/log/.gitkeep +0 -0
  208. data/spec/dummy/public/404.html +26 -0
  209. data/spec/dummy/public/422.html +26 -0
  210. data/spec/dummy/public/500.html +25 -0
  211. data/spec/dummy/public/favicon.ico +0 -0
  212. data/spec/dummy/script/rails +6 -0
  213. data/spec/dummy/spec/factories/dummy/architectures.rb +13 -0
  214. data/spec/dummy/spec/factories/dummy/authorities.rb +32 -0
  215. data/spec/dummy/spec/factories/dummy/authors.rb +8 -0
  216. data/spec/dummy/spec/factories/dummy/email_addresses.rb +8 -0
  217. data/spec/dummy/spec/factories/dummy/module/actions.rb +13 -0
  218. data/spec/dummy/spec/factories/dummy/module/ancestors.rb +45 -0
  219. data/spec/dummy/spec/factories/dummy/module/architectures.rb +35 -0
  220. data/spec/dummy/spec/factories/dummy/module/authors.rb +10 -0
  221. data/spec/dummy/spec/factories/dummy/module/classes.rb +40 -0
  222. data/spec/dummy/spec/factories/dummy/module/instances.rb +86 -0
  223. data/spec/dummy/spec/factories/dummy/module/paths.rb +16 -0
  224. data/spec/dummy/spec/factories/dummy/module/platforms.rb +35 -0
  225. data/spec/dummy/spec/factories/dummy/module/ranks.rb +14 -0
  226. data/spec/dummy/spec/factories/dummy/module/references.rb +17 -0
  227. data/spec/dummy/spec/factories/dummy/module/target/architectures.rb +40 -0
  228. data/spec/dummy/spec/factories/dummy/module/target/platforms.rb +41 -0
  229. data/spec/dummy/spec/factories/dummy/module/targets.rb +46 -0
  230. data/spec/dummy/spec/factories/dummy/platforms.rb +3 -0
  231. data/spec/dummy/spec/factories/dummy/references.rb +26 -0
  232. data/spec/factories/metasploit/model/architectures.rb +6 -0
  233. data/spec/factories/metasploit/model/association/reflections.rb +9 -0
  234. data/spec/factories/metasploit/model/authorities.rb +28 -0
  235. data/spec/factories/metasploit/model/authors.rb +9 -0
  236. data/spec/factories/metasploit/model/bases.rb +10 -0
  237. data/spec/factories/metasploit/model/email_addresses.rb +14 -0
  238. data/spec/factories/metasploit/model/module/actions.rb +9 -0
  239. data/spec/factories/metasploit/model/module/ancestors.rb +180 -0
  240. data/spec/factories/metasploit/model/module/architectures.rb +15 -0
  241. data/spec/factories/metasploit/model/module/classes.rb +47 -0
  242. data/spec/factories/metasploit/model/module/handlers.rb +3 -0
  243. data/spec/factories/metasploit/model/module/instances.rb +83 -0
  244. data/spec/factories/metasploit/model/module/paths.rb +51 -0
  245. data/spec/factories/metasploit/model/module/platforms.rb +15 -0
  246. data/spec/factories/metasploit/model/module/ranks.rb +9 -0
  247. data/spec/factories/metasploit/model/module/references.rb +11 -0
  248. data/spec/factories/metasploit/model/module/stances.rb +3 -0
  249. data/spec/factories/metasploit/model/module/targets.rb +22 -0
  250. data/spec/factories/metasploit/model/module/types.rb +5 -0
  251. data/spec/factories/metasploit/model/references.rb +88 -0
  252. data/spec/factories/metasploit/model/search/operator/associations.rb +5 -0
  253. data/spec/factories/metasploit/model/search/operator/attributes.rb +7 -0
  254. data/spec/factories/metasploit/model/search/operator/bases.rb +5 -0
  255. data/spec/lib/metasploit/model/architecture_spec.rb +52 -0
  256. data/spec/lib/metasploit/model/association/error_spec.rb +48 -0
  257. data/spec/lib/metasploit/model/association_spec.rb +145 -0
  258. data/spec/lib/metasploit/model/author_spec.rb +6 -0
  259. data/spec/lib/metasploit/model/authority/bid_spec.rb +17 -0
  260. data/spec/lib/metasploit/model/authority/cve_spec.rb +17 -0
  261. data/spec/lib/metasploit/model/authority/msb_spec.rb +17 -0
  262. data/spec/lib/metasploit/model/authority/osvdb_spec.rb +17 -0
  263. data/spec/lib/metasploit/model/authority/pmasa_spec.rb +17 -0
  264. data/spec/lib/metasploit/model/authority/secunia_spec.rb +17 -0
  265. data/spec/lib/metasploit/model/authority/us_cert_vu_spec.rb +17 -0
  266. data/spec/lib/metasploit/model/authority/waraxe_spec.rb +51 -0
  267. data/spec/lib/metasploit/model/authority/zdi_spec.rb +21 -0
  268. data/spec/lib/metasploit/model/authority_spec.rb +10 -0
  269. data/spec/lib/metasploit/model/base_spec.rb +58 -0
  270. data/spec/lib/metasploit/model/configuration/autoload_spec.rb +165 -0
  271. data/spec/lib/metasploit/model/configuration/child_spec.rb +24 -0
  272. data/spec/lib/metasploit/model/configuration/error_spec.rb +5 -0
  273. data/spec/lib/metasploit/model/configuration/i18n_spec.rb +103 -0
  274. data/spec/lib/metasploit/model/configuration_spec.rb +106 -0
  275. data/spec/lib/metasploit/model/configured_spec.rb +41 -0
  276. data/spec/lib/metasploit/model/derivation/full_name_spec.rb +75 -0
  277. data/spec/lib/metasploit/model/derivation_spec.rb +217 -0
  278. data/spec/lib/metasploit/model/email_address_spec.rb +19 -0
  279. data/spec/lib/metasploit/model/engine_spec.rb +84 -0
  280. data/spec/lib/metasploit/model/file_spec.rb +43 -0
  281. data/spec/lib/metasploit/model/invalid_spec.rb +54 -0
  282. data/spec/lib/metasploit/model/module/action_spec.rb +6 -0
  283. data/spec/lib/metasploit/model/module/ancestor_spec.rb +6 -0
  284. data/spec/lib/metasploit/model/module/architecture_spec.rb +9 -0
  285. data/spec/lib/metasploit/model/module/author_spec.rb +6 -0
  286. data/spec/lib/metasploit/model/module/class_spec.rb +19 -0
  287. data/spec/lib/metasploit/model/module/handler_spec.rb +61 -0
  288. data/spec/lib/metasploit/model/module/instance_spec.rb +183 -0
  289. data/spec/lib/metasploit/model/module/path_spec.rb +6 -0
  290. data/spec/lib/metasploit/model/module/platform_spec.rb +9 -0
  291. data/spec/lib/metasploit/model/module/rank_spec.rb +29 -0
  292. data/spec/lib/metasploit/model/module/reference_spec.rb +9 -0
  293. data/spec/lib/metasploit/model/module/stance_spec.rb +30 -0
  294. data/spec/lib/metasploit/model/module/target/architecture_spec.rb +9 -0
  295. data/spec/lib/metasploit/model/module/target/platform_spec.rb +9 -0
  296. data/spec/lib/metasploit/model/module/target_spec.rb +9 -0
  297. data/spec/lib/metasploit/model/module/type_spec.rb +125 -0
  298. data/spec/lib/metasploit/model/nilify_blanks_spec.rb +156 -0
  299. data/spec/lib/metasploit/model/platform_spec.rb +100 -0
  300. data/spec/lib/metasploit/model/reference_spec.rb +21 -0
  301. data/spec/lib/metasploit/model/search/association_spec.rb +33 -0
  302. data/spec/lib/metasploit/model/search/attribute_spec.rb +99 -0
  303. data/spec/lib/metasploit/model/search/operation/integer/value_spec.rb +20 -0
  304. data/spec/lib/metasploit/model/search/operation/string/value_spec.rb +20 -0
  305. data/spec/lib/metasploit/model/search/operation_spec.rb +144 -0
  306. data/spec/lib/metasploit/model/search/operator/help_spec.rb +41 -0
  307. data/spec/lib/metasploit/model/search/with_spec.rb +81 -0
  308. data/spec/lib/metasploit/model/search_spec.rb +230 -0
  309. data/spec/lib/metasploit/model/spec/error_spec.rb +5 -0
  310. data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +42 -0
  311. data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +55 -0
  312. data/spec/lib/metasploit/model/spec_spec.rb +114 -0
  313. data/spec/lib/metasploit/model/translation_spec.rb +82 -0
  314. data/spec/lib/metasploit/model/version_spec.rb +141 -0
  315. data/spec/lib/metasploit/model/visitation/visit_spec.rb +316 -0
  316. data/spec/lib/metasploit/model_spec.rb +68 -0
  317. data/spec/spec_helper.rb +48 -0
  318. data/spec/support/shared/contexts/metasploit/model/configuration.rb +11 -0
  319. data/spec/support/shared/contexts/metasploit/model/module/ancestor/contents/metasploit_module.rb +12 -0
  320. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents.rb +10 -0
  321. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents/metasploit_module.rb +15 -0
  322. data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +13 -0
  323. data/spec/support/shared/examples/derives.rb +115 -0
  324. data/spec/support/shared/examples/metasploit/model/architecture.rb +425 -0
  325. data/spec/support/shared/examples/metasploit/model/architecture/seed.rb +25 -0
  326. data/spec/support/shared/examples/metasploit/model/author.rb +27 -0
  327. data/spec/support/shared/examples/metasploit/model/authority.rb +124 -0
  328. data/spec/support/shared/examples/metasploit/model/authority/seed.rb +49 -0
  329. data/spec/support/shared/examples/metasploit/model/configuration/parent/child.rb +60 -0
  330. data/spec/support/shared/examples/metasploit/model/email_address.rb +220 -0
  331. data/spec/support/shared/examples/metasploit/model/module/action.rb +26 -0
  332. data/spec/support/shared/examples/metasploit/model/module/ancestor.rb +2004 -0
  333. data/spec/support/shared/examples/metasploit/model/module/ancestor/payload_factory.rb +63 -0
  334. data/spec/support/shared/examples/metasploit/model/module/architecture.rb +36 -0
  335. data/spec/support/shared/examples/metasploit/model/module/author.rb +29 -0
  336. data/spec/support/shared/examples/metasploit/model/module/class.rb +1514 -0
  337. data/spec/support/shared/examples/metasploit/model/module/handler.rb +21 -0
  338. data/spec/support/shared/examples/metasploit/model/module/instance.rb +1384 -0
  339. data/spec/support/shared/examples/metasploit/model/module/instance/class_methods.rb +537 -0
  340. data/spec/support/shared/examples/metasploit/model/module/instance/is_not_stanced_with_module_type.rb +22 -0
  341. data/spec/support/shared/examples/metasploit/model/module/instance/is_stanced_with_module_type.rb +38 -0
  342. data/spec/support/shared/examples/metasploit/model/module/instance/validates/dynamic_length_of.rb +131 -0
  343. data/spec/support/shared/examples/metasploit/model/module/path.rb +493 -0
  344. data/spec/support/shared/examples/metasploit/model/module/platform.rb +36 -0
  345. data/spec/support/shared/examples/metasploit/model/module/rank.rb +92 -0
  346. data/spec/support/shared/examples/metasploit/model/module/reference.rb +16 -0
  347. data/spec/support/shared/examples/metasploit/model/module/target.rb +29 -0
  348. data/spec/support/shared/examples/metasploit/model/module/target/architecture.rb +56 -0
  349. data/spec/support/shared/examples/metasploit/model/module/target/platform.rb +56 -0
  350. data/spec/support/shared/examples/metasploit/model/platform.rb +213 -0
  351. data/spec/support/shared/examples/metasploit/model/real_pathname.rb +29 -0
  352. data/spec/support/shared/examples/metasploit/model/reference.rb +410 -0
  353. data/spec/support/shared/examples/metasploit/model/search/operation/integer/value.rb +79 -0
  354. data/spec/support/shared/examples/metasploit/model/search/operation/string/value.rb +53 -0
  355. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +134 -0
  356. data/spec/support/shared/examples/metasploit/model/translation.rb +37 -0
  357. data/spec/support/shared/examples/search/query.rb +43 -0
  358. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/app.rb +44 -0
  359. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +60 -0
  360. data/spec/support/shared/examples/search_association.rb +13 -0
  361. data/spec/support/shared/examples/search_attribute.rb +27 -0
  362. data/spec/support/shared/examples/search_with.rb +36 -0
  363. data/spec/support/shared/matchers/allow_attribute.rb +17 -0
  364. data/spec/support/templates/metasploit/model/module/ancestors/_attributes.rb.erb +9 -0
  365. data/spec/support/templates/metasploit/model/module/ancestors/_methods.rb.erb +8 -0
  366. data/spec/support/templates/metasploit/model/module/ancestors/_validations.rb.erb +6 -0
  367. data/spec/support/templates/metasploit/model/module/ancestors/base.rb.erb +3 -0
  368. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_auxiliary.rb.erb +1 -0
  369. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_encoder.rb.erb +1 -0
  370. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_exploit.rb.erb +1 -0
  371. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_non_payload.rb.erb +5 -0
  372. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_nop.rb.erb +1 -0
  373. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_payload.rb.erb +4 -0
  374. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_post.rb.erb +1 -0
  375. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_handled.rb.erb +20 -0
  376. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_single.rb.erb +1 -0
  377. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stage.rb.erb +0 -0
  378. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stager.rb.erb +1 -0
  379. data/spec/support/templates/metasploit/model/module/classes/_methods.rb.erb +9 -0
  380. metadata +748 -0
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metasploit::Model do
4
+ let(:root_pathname) do
5
+ spec_lib_metasploit_pathname = Pathname.new(__FILE__).parent
6
+ spec_lib_pathname = spec_lib_metasploit_pathname.parent
7
+ spec_pathname = spec_lib_pathname.parent
8
+
9
+ spec_pathname.parent
10
+ end
11
+
12
+ it 'should extend Metasploit::Model::Configured' do
13
+ described_class.singleton_class.should include Metasploit::Model::Configured
14
+ end
15
+
16
+ context 'configuration' do
17
+ subject(:configuration) do
18
+ described_class.configuration
19
+ end
20
+
21
+ context 'autoload' do
22
+ subject(:autoload) do
23
+ configuration.autoload
24
+ end
25
+
26
+ context 'once_paths' do
27
+ subject(:once_paths) do
28
+ autoload.once_paths
29
+ end
30
+
31
+ it { should include root_pathname.join('lib').to_path }
32
+ end
33
+
34
+ context 'paths' do
35
+ subject(:paths) do
36
+ autoload.paths
37
+ end
38
+
39
+ it { should include root_pathname.join('app', 'models').to_path }
40
+ it { should include root_pathname.join('app', 'validators').to_path }
41
+ end
42
+ end
43
+
44
+ context 'i18n' do
45
+ subject(:i18n) do
46
+ configuration.i18n
47
+ end
48
+
49
+ context 'paths' do
50
+ subject(:paths) do
51
+ i18n.paths
52
+ end
53
+
54
+ it { should include root_pathname.join('config', 'locales', 'en.yml').to_path }
55
+ end
56
+ end
57
+ end
58
+
59
+ context 'root' do
60
+ subject(:root) do
61
+ described_class.root
62
+ end
63
+
64
+ it 'should be top-level directory of metasploit-model project' do
65
+ root.should == root_pathname
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,48 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require 'rubygems'
5
+ require 'bundler'
6
+ Bundler.setup(:default, :test)
7
+
8
+ # Require simplecov before loading ..dummy/config/environment.rb because it will cause metasploit_data_models/lib to
9
+ # be loaded, which would result in Coverage not recording hits for any of the files.
10
+ require 'simplecov'
11
+ require 'coveralls'
12
+
13
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
14
+
15
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
16
+ require 'rspec/rails'
17
+ require 'rspec/autorun'
18
+
19
+ # full backtrace in logs so its easier to trace errors
20
+ Rails.backtrace_cleaner.remove_silencers!
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ support_glob = Metasploit::Model.root.join('spec', 'support', '**', '*.rb')
25
+
26
+ Dir.glob(support_glob) do |path|
27
+ require path
28
+ end
29
+
30
+ RSpec.configure do |config|
31
+ config.before(:suite) do
32
+ # this must be explicitly set here because it should always be spec/tmp for w/e project is using
33
+ # Metasploit::Model::Spec to handle file system clean up.
34
+ Metasploit::Model::Spec.temporary_pathname = Metasploit::Model.root.join('spec', 'tmp')
35
+ # Clean up any left over files from a previously aborted suite
36
+ Metasploit::Model::Spec.remove_temporary_pathname
37
+
38
+ # catch missing translations
39
+ I18n.exception_handler = Metasploit::Model::Spec::I18nExceptionHandler.new
40
+ end
41
+
42
+ config.after(:each) do
43
+ Metasploit::Model::Spec.remove_temporary_pathname
44
+ end
45
+
46
+ config.mock_with :rspec
47
+ config.order = :random
48
+ end
@@ -0,0 +1,11 @@
1
+ shared_context 'Metasploit::Model::Configuration' do
2
+ let(:configuration) do
3
+ Metasploit::Model::Configuration.new.tap { |configuration|
4
+ configuration.root = root
5
+ }
6
+ end
7
+
8
+ let(:root) do
9
+ Metasploit::Model.root.join('spec', 'dummy')
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ shared_context 'Metasploit::Model::Module::Ancestor#contents metasploit_module' do
2
+ def namespace_module_metasploit_module(namespace_module)
3
+ constant = namespace_module_metasploit_module_constant(namespace_module)
4
+ namespace_module.const_get(constant)
5
+ end
6
+
7
+ def namespace_module_metasploit_module_constant(namespace_module)
8
+ namespace_module.constants.find { |constant|
9
+ constant.to_s =~ /Metasploit\d+/
10
+ }
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ shared_context 'Metasploit::Model::Module::Ancestor factory contents' do
2
+ subject(:contents) do
3
+ module_ancestor.contents
4
+ end
5
+
6
+ before(:each) do
7
+ # need to validate so that real_path is derived so contents can be read
8
+ module_ancestor.valid?
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ shared_context 'Metasploit::Model::Module::Ancestor factory contents metasploit_module' do
2
+ include_context 'Metasploit::Model::Module::Ancestor#contents metasploit_module'
3
+
4
+ subject(:metasploit_module) do
5
+ namespace_module_metasploit_module(namespace_module)
6
+ end
7
+
8
+ let(:namespace_module) do
9
+ Module.new
10
+ end
11
+
12
+ before(:each) do
13
+ namespace_module.module_eval(contents)
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ shared_context 'Metasploit::Model::Search::Operator::Union#children' do
2
+ subject(:children) do
3
+ operator.children(formatted_value)
4
+ end
5
+
6
+ def child(formatted_operator)
7
+ operator_name = formatted_operator.to_sym
8
+
9
+ children.find { |operation|
10
+ operation.operator.name == operator_name
11
+ }
12
+ end
13
+ end
@@ -0,0 +1,115 @@
1
+ shared_examples_for 'derives' do |attribute, options={}|
2
+ options.assert_valid_keys(:validates)
3
+
4
+ derived = "derived_#{attribute}"
5
+ validates = options.fetch(:validates)
6
+
7
+ context attribute do
8
+ it { should be_a Metasploit::Model::Derivation }
9
+
10
+ let(:validate) do
11
+ # don't use `described_class` as it won't be correct when testing mixin modules.
12
+ base_class.validate_by_derived_attribute[attribute]
13
+ end
14
+
15
+ it "should declare #{attribute} is derived" do
16
+ validate.should_not be_nil
17
+ end
18
+
19
+ if validates
20
+ it "should validate #{attribute}" do
21
+ validate.should be_true
22
+ end
23
+
24
+ context 'validation' do
25
+ before(:each) do
26
+ subject.send("#{attribute}=", value)
27
+ end
28
+
29
+ context "with #{attribute} matching #{derived}" do
30
+ let(:value) do
31
+ subject.send(derived)
32
+ end
33
+
34
+ it { should be_valid }
35
+ end
36
+
37
+ context "without #{attribute} matching #{derived}" do
38
+ let(:value) do
39
+ "not #{subject.send(derived)}"
40
+ end
41
+
42
+ it { should_not be_valid }
43
+
44
+ it "should record error on #{attribute}" do
45
+ subject.valid?
46
+
47
+ subject.errors[attribute].should include("must match its derivation")
48
+ end
49
+ end
50
+ end
51
+ else
52
+ it "should not validate #{attribute}" do
53
+ validate.should be_false
54
+ end
55
+ end
56
+
57
+ context "##{derived}" do
58
+ it "should respond to #{derived}" do
59
+ subject.should respond_to(derived)
60
+ end
61
+
62
+ it 'should not be nil or the spec that expect a change will fail' do
63
+ subject.send(derived).should_not be_nil
64
+ end
65
+ end
66
+
67
+ context 'callbacks' do
68
+ context 'before validation' do
69
+ before(:each) do
70
+ subject.send("#{attribute}=", value)
71
+ end
72
+
73
+ context "with #{attribute}" do
74
+ let(:value) do
75
+ attribute_type = self.attribute_type(attribute)
76
+
77
+ case attribute_type
78
+ when :string, :text
79
+ 'existing_value'
80
+ when :datetime
81
+ DateTime.new
82
+ else
83
+ raise ArgumentError,
84
+ "Don't know how to make valid existing value for attribute type (#{attribute_type.inspect})"
85
+ end
86
+ end
87
+
88
+ it "should not change #{attribute}" do
89
+ expect {
90
+ subject.valid?
91
+ }.to_not change {
92
+ subject.send(attribute)
93
+ }
94
+ end
95
+ end
96
+
97
+ context "without #{attribute}" do
98
+ let(:value) do
99
+ nil
100
+ end
101
+
102
+ it "should set #{attribute} to #{derived}" do
103
+ expect {
104
+ subject.valid?
105
+ }.to change {
106
+ subject.send(attribute)
107
+ }
108
+
109
+ subject.send(attribute).should == subject.send(derived)
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,425 @@
1
+ Metasploit::Model::Spec.shared_examples_for 'Architecture' do
2
+ subject(:architecture) do
3
+ # Architecture, don't have a factory, they have a sequence and can't use sequence generated architectures because
4
+ # validators so tightly constraint values.
5
+ architecture_class.new
6
+ end
7
+
8
+ context 'CONSTANTS' do
9
+ context 'ABBREVIATIONS' do
10
+ subject(:abbreviations) do
11
+ described_class::ABBREVIATIONS
12
+ end
13
+
14
+ it 'should be an Array<String>' do
15
+ abbreviations.should be_an Array
16
+
17
+ abbreviations.each do |architecture|
18
+ architecture.should be_a String
19
+ end
20
+ end
21
+
22
+ it 'should include both endians of ARM' do
23
+ abbreviations.should include('armbe')
24
+ abbreviations.should include('armle')
25
+ end
26
+
27
+ it 'should include 32-bit and 64-bit versions of Cell Broadband Engine Architecture' do
28
+ abbreviations.should include('cbea')
29
+ abbreviations.should include('cbea64')
30
+ end
31
+
32
+ it 'should include cmd for command shell' do
33
+ abbreviations.should include('cmd')
34
+ end
35
+
36
+ it 'should include dalvik for Dalvik Virtual Machine in Google Android' do
37
+ abbreviations.should include('dalvik')
38
+ end
39
+
40
+ it 'should include firefox for Firefox privileged javascript API' do
41
+ expect(abbreviations).to include('firefox')
42
+ end
43
+
44
+ it 'should include java for Java Virtual Machine' do
45
+ abbreviations.should include('java')
46
+ end
47
+
48
+ it 'should include endian-ware MIPS' do
49
+ abbreviations.should include('mipsbe')
50
+ abbreviations.should include('mipsle')
51
+ end
52
+
53
+ it 'should include nodejs for javascript code that requires NodeJS extensions/libraries' do
54
+ expect(abbreviations).to include('nodejs')
55
+ end
56
+
57
+ it 'should include php for PHP code' do
58
+ abbreviations.should include('php')
59
+ end
60
+
61
+ it 'should include 32-bit and 64-bit PowerPC' do
62
+ abbreviations.should include('ppc')
63
+ abbreviations.should include('ppc64')
64
+ end
65
+
66
+ it 'should include python for Python code' do
67
+ abbreviations.should include('python')
68
+ end
69
+
70
+ it 'should include ruby for Ruby code' do
71
+ abbreviations.should include('ruby')
72
+ end
73
+
74
+ it 'should include sparc for Sparc' do
75
+ abbreviations.should include('sparc')
76
+ end
77
+
78
+ it 'should include tty for Terminals' do
79
+ abbreviations.should include('tty')
80
+ end
81
+
82
+ it 'should include 32-bit and 64-bit x86' do
83
+ abbreviations.should include('x86')
84
+ abbreviations.should include('x86_64')
85
+ end
86
+ end
87
+
88
+ context 'BITS' do
89
+ subject(:bits) do
90
+ described_class::BITS
91
+ end
92
+
93
+ it { should include 32 }
94
+ it { should include 64 }
95
+ end
96
+
97
+ context 'ENDIANNESSES' do
98
+ subject(:endiannesses) do
99
+ described_class::ENDIANNESSES
100
+ end
101
+
102
+ it { should include 'big' }
103
+ it { should include 'little' }
104
+ end
105
+
106
+ context 'FAMILIES' do
107
+ subject(:families) do
108
+ described_class::FAMILIES
109
+ end
110
+
111
+ it 'includes arm for big- and little-endian ARM' do
112
+ expect(families).to include('arm')
113
+ end
114
+
115
+ it 'includes cbea for 32- and 64-bit Cell Broadband Engine Architecture' do
116
+ expect(families).to include('cbea')
117
+ end
118
+
119
+ it 'includes javascript for NodeJS' do
120
+ expect(families).to include('javascript')
121
+ end
122
+
123
+ it 'includes mips for big and little-endian MIPS' do
124
+ expect(families).to include('mips')
125
+ end
126
+
127
+ it 'includes ppc for 32- and 64-bit PPC' do
128
+ expect(families).to include('ppc')
129
+ end
130
+
131
+ it 'includes sparc for sparc' do
132
+ expect(families).to include('sparc')
133
+ end
134
+
135
+ it 'includes x86 for x86 and x86_64' do
136
+ expect(families).to include('x86')
137
+ end
138
+ end
139
+ end
140
+
141
+ context 'search' do
142
+ context 'attributes' do
143
+ it_should_behave_like 'search_attribute',
144
+ :abbreviation,
145
+ type: {
146
+ set: :string
147
+ }
148
+ it_should_behave_like 'search_attribute',
149
+ :bits,
150
+ type: {
151
+ set: :integer
152
+ }
153
+ it_should_behave_like 'search_attribute',
154
+ :endianness,
155
+ type: {
156
+ set: :string
157
+ }
158
+ it_should_behave_like 'search_attribute',
159
+ :family,
160
+ type: {
161
+ set: :string
162
+ }
163
+ end
164
+ end
165
+
166
+ context 'seeds' do
167
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
168
+ :abbreviation => 'armbe',
169
+ :bits => 32,
170
+ :endianness => 'big',
171
+ :family => 'arm',
172
+ :summary => 'Little-endian ARM'
173
+
174
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
175
+ :abbreviation => 'armle',
176
+ :bits => 32,
177
+ :endianness => 'little',
178
+ :family => 'arm',
179
+ :summary => 'Big-endian ARM'
180
+
181
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
182
+ :abbreviation => 'cbea',
183
+ :bits => 32,
184
+ :endianness => 'big',
185
+ :family => 'cbea',
186
+ :summary => '32-bit Cell Broadband Engine Architecture'
187
+
188
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
189
+ :abbreviation => 'cbea64',
190
+ :bits => 64,
191
+ :endianness => 'big',
192
+ :family => 'cbea',
193
+ :summary => '64-bit Cell Broadband Engine Architecture'
194
+
195
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
196
+ :abbreviation => 'cmd',
197
+ :bits => nil,
198
+ :endianness => nil,
199
+ :family => nil,
200
+ :summary => 'Command Injection'
201
+
202
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
203
+ :abbreviation => 'dalvik',
204
+ :bits => nil,
205
+ :endianness => nil,
206
+ :family => nil,
207
+ :summary => 'Dalvik process virtual machine used in Google Android'
208
+
209
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
210
+ abbreviation: 'firefox',
211
+ bits: nil,
212
+ endianness: nil,
213
+ family: 'javascript',
214
+ summary: "Firefox's privileged javascript API"
215
+
216
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
217
+ :abbreviation => 'java',
218
+ :bits => nil,
219
+ :endianness => 'big',
220
+ :family => nil,
221
+ :summary => 'Java'
222
+
223
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
224
+ :abbreviation => 'mipsbe',
225
+ :bits => 32,
226
+ :endianness => 'big',
227
+ :family => 'mips',
228
+ :summary => 'Big-endian MIPS'
229
+
230
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
231
+ :abbreviation => 'mipsle',
232
+ :bits => 32,
233
+ :endianness => 'little',
234
+ :family => 'mips',
235
+ :summary => 'Little-endian MIPS'
236
+
237
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
238
+ :abbreviation => 'nodejs',
239
+ :bits => nil,
240
+ :endianness => nil,
241
+ :family => 'javascript',
242
+ :summary => 'NodeJS'
243
+
244
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
245
+ :abbreviation => 'php',
246
+ :bits => nil,
247
+ :endianness => nil,
248
+ :family => nil,
249
+ :summary => 'PHP'
250
+
251
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
252
+ :abbreviation => 'ppc',
253
+ :bits => 32,
254
+ :endianness => 'big',
255
+ :family => 'ppc',
256
+ :summary => '32-bit Peformance Optimization With Enhanced RISC - Performance Computing'
257
+
258
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
259
+ :abbreviation => 'ppc64',
260
+ :bits => 64,
261
+ :endianness => 'big',
262
+ :family => 'ppc',
263
+ :summary => '64-bit Performance Optimization With Enhanced RISC - Performance Computing'
264
+
265
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
266
+ :abbreviation => 'python',
267
+ :bits => nil,
268
+ :endianness => nil,
269
+ :family => nil,
270
+ :summary => 'Python'
271
+
272
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
273
+ :abbreviation => 'ruby',
274
+ :bits => nil,
275
+ :endianness => nil,
276
+ :family => nil,
277
+ :summary => 'Ruby'
278
+
279
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
280
+ :abbreviation => 'sparc',
281
+ :bits => nil,
282
+ :endianness => nil,
283
+ :family => 'sparc',
284
+ :summary => 'Scalable Processor ARChitecture'
285
+
286
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
287
+ :abbreviation => 'tty',
288
+ :bits => nil,
289
+ :endianness => nil,
290
+ :family => nil,
291
+ :summary => '*nix terminal'
292
+
293
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
294
+ :abbreviation => 'x86',
295
+ :bits => 32,
296
+ :endianness => 'little',
297
+ :family => 'x86',
298
+ :summary => '32-bit x86'
299
+
300
+ it_should_behave_like 'Metasploit::Model::Architecture seed',
301
+ :abbreviation => 'x86_64',
302
+ :bits => 64,
303
+ :endianness => 'little',
304
+ :family => 'x86',
305
+ :summary => '64-bit x86'
306
+ end
307
+
308
+ context 'validations' do
309
+ context 'abbreviation' do
310
+ # have to test inclusion validation manually because
311
+ # ensure_inclusion_of(:abbreviation).in_array(described_class::ABBREVIATIONS).allow_nil does not work with
312
+ # additional uniqueness validation.
313
+ context 'ensure inclusion of abbreviation in ABBREVIATIONS' do
314
+ let(:error) do
315
+ 'is not included in the list'
316
+ end
317
+
318
+ abbreviations = [
319
+ 'armbe',
320
+ 'armle',
321
+ 'cbea',
322
+ 'cbea64',
323
+ 'cmd',
324
+ 'dalvik',
325
+ 'firefox',
326
+ 'java',
327
+ 'mipsbe',
328
+ 'mipsle',
329
+ 'nodejs',
330
+ 'php',
331
+ 'ppc',
332
+ 'ppc64',
333
+ 'python',
334
+ 'ruby',
335
+ 'sparc',
336
+ 'tty',
337
+ 'x86',
338
+ 'x86_64'
339
+ ]
340
+
341
+ abbreviations.each do |abbreviation|
342
+ context "with #{abbreviation.inspect}" do
343
+ before(:each) do
344
+ architecture.abbreviation = abbreviation
345
+
346
+ architecture.valid?
347
+ end
348
+
349
+ it 'should not record error on abbreviation' do
350
+ architecture.errors[:abbreviation].should_not include(error)
351
+ end
352
+ end
353
+ end
354
+ end
355
+ end
356
+
357
+ it { should ensure_inclusion_of(:bits).in_array(described_class::BITS).allow_nil }
358
+ it { should ensure_inclusion_of(:endianness).in_array(described_class::ENDIANNESSES).allow_nil }
359
+ it { should ensure_inclusion_of(:family).in_array(described_class::FAMILIES).allow_nil }
360
+ it { should validate_presence_of(:summary) }
361
+ end
362
+
363
+ context 'abbreviation_set' do
364
+ subject(:abbreviation_set) do
365
+ architecture_class.abbreviation_set
366
+ end
367
+
368
+ it { should_not include nil }
369
+ it { should include 'armbe' }
370
+ it { should include 'armle' }
371
+ it { should include 'cbea' }
372
+ it { should include 'cbea64' }
373
+ it { should include 'cmd' }
374
+ it { should include 'dalvik' }
375
+ it { should include 'firefox' }
376
+ it { should include 'java' }
377
+ it { should include 'mipsbe' }
378
+ it { should include 'mipsle' }
379
+ it { should include 'nodejs' }
380
+ it { should include 'php' }
381
+ it { should include 'ppc' }
382
+ it { should include 'ppc64' }
383
+ it { should include 'python' }
384
+ it { should include 'ruby' }
385
+ it { should include 'sparc' }
386
+ it { should include 'tty' }
387
+ it { should include 'x86' }
388
+ it { should include 'x86_64' }
389
+ end
390
+
391
+ context 'bits_set' do
392
+ subject(:bits_set) do
393
+ architecture_class.bits_set
394
+ end
395
+
396
+ it { should_not include nil }
397
+ it { should include 32 }
398
+ it { should include 64 }
399
+ end
400
+
401
+ context 'endianness_set' do
402
+ subject(:endianness_set) do
403
+ architecture_class.endianness_set
404
+ end
405
+
406
+ it { should_not include nil }
407
+ it { should include 'big' }
408
+ it { should include 'little' }
409
+ end
410
+
411
+ context 'family_set' do
412
+ subject(:family_set) do
413
+ architecture_class.family_set
414
+ end
415
+
416
+ it { should_not include nil }
417
+ it { should include 'arm' }
418
+ it { should include 'cbea' }
419
+ it { should include 'mips' }
420
+ it { should include 'javascript' }
421
+ it { should include 'ppc' }
422
+ it { should include 'sparc' }
423
+ it { should include 'x86' }
424
+ end
425
+ end