metasploit-model 0.24.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +27 -0
- data/.rspec +4 -0
- data/.simplecov +38 -0
- data/.travis.yml +6 -0
- data/.yardopts +5 -0
- data/Gemfile +43 -0
- data/LICENSE +27 -0
- data/README.md +33 -0
- data/Rakefile +52 -0
- data/app/models/metasploit/model/association/reflection.rb +46 -0
- data/app/models/metasploit/model/module/ancestor/spec/template.rb +125 -0
- data/app/models/metasploit/model/module/class/spec/template.rb +92 -0
- data/app/models/metasploit/model/module/instance/spec/template.rb +97 -0
- data/app/models/metasploit/model/search/group/base.rb +21 -0
- data/app/models/metasploit/model/search/group/intersection.rb +4 -0
- data/app/models/metasploit/model/search/group/union.rb +4 -0
- data/app/models/metasploit/model/search/operation/base.rb +39 -0
- data/app/models/metasploit/model/search/operation/boolean.rb +36 -0
- data/app/models/metasploit/model/search/operation/date.rb +37 -0
- data/app/models/metasploit/model/search/operation/integer.rb +14 -0
- data/app/models/metasploit/model/search/operation/null.rb +26 -0
- data/app/models/metasploit/model/search/operation/set.rb +34 -0
- data/app/models/metasploit/model/search/operation/set/integer.rb +5 -0
- data/app/models/metasploit/model/search/operation/set/string.rb +5 -0
- data/app/models/metasploit/model/search/operation/string.rb +11 -0
- data/app/models/metasploit/model/search/operation/union.rb +59 -0
- data/app/models/metasploit/model/search/operator/association.rb +43 -0
- data/app/models/metasploit/model/search/operator/attribute.rb +60 -0
- data/app/models/metasploit/model/search/operator/base.rb +34 -0
- data/app/models/metasploit/model/search/operator/delegation.rb +40 -0
- data/app/models/metasploit/model/search/operator/deprecated/app.rb +27 -0
- data/app/models/metasploit/model/search/operator/deprecated/author.rb +33 -0
- data/app/models/metasploit/model/search/operator/deprecated/authority.rb +43 -0
- data/app/models/metasploit/model/search/operator/deprecated/platform.rb +45 -0
- data/app/models/metasploit/model/search/operator/deprecated/ref.rb +50 -0
- data/app/models/metasploit/model/search/operator/deprecated/text.rb +32 -0
- data/app/models/metasploit/model/search/operator/null.rb +44 -0
- data/app/models/metasploit/model/search/operator/single.rb +98 -0
- data/app/models/metasploit/model/search/operator/union.rb +33 -0
- data/app/models/metasploit/model/search/query.rb +171 -0
- data/app/models/metasploit/model/spec/template.rb +273 -0
- data/app/models/metasploit/model/visitation/visitor.rb +69 -0
- data/app/validators/derivation_validator.rb +17 -0
- data/app/validators/dynamic_length_validator.rb +45 -0
- data/app/validators/ip_format_validator.rb +31 -0
- data/app/validators/nil_validator.rb +16 -0
- data/app/validators/parameters_validator.rb +147 -0
- data/app/validators/password_is_strong_validator.rb +115 -0
- data/config/locales/en.yml +209 -0
- data/lib/metasploit/model.rb +38 -0
- data/lib/metasploit/model/architecture.rb +346 -0
- data/lib/metasploit/model/association.rb +49 -0
- data/lib/metasploit/model/association/error.rb +40 -0
- data/lib/metasploit/model/author.rb +58 -0
- data/lib/metasploit/model/authority.rb +134 -0
- data/lib/metasploit/model/authority/bid.rb +10 -0
- data/lib/metasploit/model/authority/cve.rb +10 -0
- data/lib/metasploit/model/authority/msb.rb +10 -0
- data/lib/metasploit/model/authority/osvdb.rb +10 -0
- data/lib/metasploit/model/authority/pmasa.rb +10 -0
- data/lib/metasploit/model/authority/secunia.rb +10 -0
- data/lib/metasploit/model/authority/us_cert_vu.rb +10 -0
- data/lib/metasploit/model/authority/waraxe.rb +31 -0
- data/lib/metasploit/model/authority/zdi.rb +10 -0
- data/lib/metasploit/model/base.rb +25 -0
- data/lib/metasploit/model/configuration.rb +72 -0
- data/lib/metasploit/model/configuration/autoload.rb +109 -0
- data/lib/metasploit/model/configuration/child.rb +12 -0
- data/lib/metasploit/model/configuration/error.rb +4 -0
- data/lib/metasploit/model/configuration/i18n.rb +54 -0
- data/lib/metasploit/model/configuration/parent.rb +50 -0
- data/lib/metasploit/model/configured.rb +46 -0
- data/lib/metasploit/model/derivation.rb +110 -0
- data/lib/metasploit/model/derivation/full_name.rb +25 -0
- data/lib/metasploit/model/email_address.rb +128 -0
- data/lib/metasploit/model/engine.rb +34 -0
- data/lib/metasploit/model/error.rb +7 -0
- data/lib/metasploit/model/file.rb +49 -0
- data/lib/metasploit/model/invalid.rb +17 -0
- data/lib/metasploit/model/module.rb +8 -0
- data/lib/metasploit/model/module/action.rb +58 -0
- data/lib/metasploit/model/module/ancestor.rb +494 -0
- data/lib/metasploit/model/module/architecture.rb +40 -0
- data/lib/metasploit/model/module/author.rb +47 -0
- data/lib/metasploit/model/module/class.rb +406 -0
- data/lib/metasploit/model/module/handler.rb +35 -0
- data/lib/metasploit/model/module/instance.rb +626 -0
- data/lib/metasploit/model/module/path.rb +165 -0
- data/lib/metasploit/model/module/platform.rb +38 -0
- data/lib/metasploit/model/module/rank.rb +91 -0
- data/lib/metasploit/model/module/reference.rb +38 -0
- data/lib/metasploit/model/module/stance.rb +22 -0
- data/lib/metasploit/model/module/target.rb +80 -0
- data/lib/metasploit/model/module/target/architecture.rb +42 -0
- data/lib/metasploit/model/module/target/platform.rb +42 -0
- data/lib/metasploit/model/module/type.rb +44 -0
- data/lib/metasploit/model/nilify_blanks.rb +53 -0
- data/lib/metasploit/model/platform.rb +250 -0
- data/lib/metasploit/model/real_pathname.rb +18 -0
- data/lib/metasploit/model/reference.rb +108 -0
- data/lib/metasploit/model/search.rb +63 -0
- data/lib/metasploit/model/search/association.rb +32 -0
- data/lib/metasploit/model/search/attribute.rb +51 -0
- data/lib/metasploit/model/search/operation.rb +31 -0
- data/lib/metasploit/model/search/operation/integer/value.rb +33 -0
- data/lib/metasploit/model/search/operation/string/value.rb +14 -0
- data/lib/metasploit/model/search/operator.rb +10 -0
- data/lib/metasploit/model/search/operator/help.rb +47 -0
- data/lib/metasploit/model/search/with.rb +40 -0
- data/lib/metasploit/model/spec.rb +140 -0
- data/lib/metasploit/model/spec/error.rb +9 -0
- data/lib/metasploit/model/spec/i18n_exception_handler.rb +19 -0
- data/lib/metasploit/model/spec/pathname_collision.rb +28 -0
- data/lib/metasploit/model/spec/template/write.rb +42 -0
- data/lib/metasploit/model/spec/temporary_pathname.rb +59 -0
- data/lib/metasploit/model/translation.rb +31 -0
- data/lib/metasploit/model/version.rb +31 -0
- data/lib/metasploit/model/visitation.rb +9 -0
- data/lib/metasploit/model/visitation/visit.rb +103 -0
- data/lib/tasks/yard.rake +30 -0
- data/metasploit-model.gemspec +39 -0
- data/script/rails +9 -0
- data/spec/app/models/metasploit/model/association/reflection_spec.rb +48 -0
- data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +174 -0
- data/spec/app/models/metasploit/model/module/class/spec/template_spec.rb +222 -0
- data/spec/app/models/metasploit/model/module/instance/spec/template_spec.rb +201 -0
- data/spec/app/models/metasploit/model/search/group/base_spec.rb +5 -0
- data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +5 -0
- data/spec/app/models/metasploit/model/search/group/union_spec.rb +5 -0
- data/spec/app/models/metasploit/model/search/operation/base_spec.rb +70 -0
- data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +56 -0
- data/spec/app/models/metasploit/model/search/operation/date_spec.rb +89 -0
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +9 -0
- data/spec/app/models/metasploit/model/search/operation/null_spec.rb +64 -0
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +7 -0
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +7 -0
- data/spec/app/models/metasploit/model/search/operation/set_spec.rb +126 -0
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +9 -0
- data/spec/app/models/metasploit/model/search/operation/union_spec.rb +124 -0
- data/spec/app/models/metasploit/model/search/operator/association_spec.rb +108 -0
- data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +104 -0
- data/spec/app/models/metasploit/model/search/operator/base_spec.rb +34 -0
- data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +108 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/app_spec.rb +62 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +161 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +123 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +112 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +327 -0
- data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +357 -0
- data/spec/app/models/metasploit/model/search/operator/null_spec.rb +41 -0
- data/spec/app/models/metasploit/model/search/operator/single_spec.rb +327 -0
- data/spec/app/models/metasploit/model/search/operator/union_spec.rb +92 -0
- data/spec/app/models/metasploit/model/search/query_spec.rb +742 -0
- data/spec/app/models/metasploit/model/spec/template_spec.rb +23 -0
- data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +45 -0
- data/spec/app/validators/derivation_validator_spec.rb +92 -0
- data/spec/app/validators/dynamic_length_validator_spec.rb +293 -0
- data/spec/app/validators/ip_format_validator_spec.rb +124 -0
- data/spec/app/validators/nil_validator_spec.rb +69 -0
- data/spec/app/validators/parameters_validator_spec.rb +342 -0
- data/spec/app/validators/password_is_strong_validator_spec.rb +250 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/dummy/architecture.rb +92 -0
- data/spec/dummy/app/models/dummy/author.rb +15 -0
- data/spec/dummy/app/models/dummy/authority.rb +130 -0
- data/spec/dummy/app/models/dummy/email_address.rb +27 -0
- data/spec/dummy/app/models/dummy/module/action.rb +25 -0
- data/spec/dummy/app/models/dummy/module/ancestor.rb +67 -0
- data/spec/dummy/app/models/dummy/module/architecture.rb +19 -0
- data/spec/dummy/app/models/dummy/module/author.rb +28 -0
- data/spec/dummy/app/models/dummy/module/class.rb +69 -0
- data/spec/dummy/app/models/dummy/module/instance.rb +209 -0
- data/spec/dummy/app/models/dummy/module/path.rb +64 -0
- data/spec/dummy/app/models/dummy/module/platform.rb +19 -0
- data/spec/dummy/app/models/dummy/module/rank.rb +44 -0
- data/spec/dummy/app/models/dummy/module/reference.rb +19 -0
- data/spec/dummy/app/models/dummy/module/target.rb +62 -0
- data/spec/dummy/app/models/dummy/module/target/architecture.rb +19 -0
- data/spec/dummy/app/models/dummy/module/target/platform.rb +19 -0
- data/spec/dummy/app/models/dummy/platform.rb +58 -0
- data/spec/dummy/app/models/dummy/reference.rb +31 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +43 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +27 -0
- data/spec/dummy/config/environments/production.rb +63 -0
- data/spec/dummy/config/environments/test.rb +29 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy/config/locales/en.yml +1 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +707 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/factories/dummy/architectures.rb +13 -0
- data/spec/dummy/spec/factories/dummy/authorities.rb +32 -0
- data/spec/dummy/spec/factories/dummy/authors.rb +8 -0
- data/spec/dummy/spec/factories/dummy/email_addresses.rb +8 -0
- data/spec/dummy/spec/factories/dummy/module/actions.rb +13 -0
- data/spec/dummy/spec/factories/dummy/module/ancestors.rb +45 -0
- data/spec/dummy/spec/factories/dummy/module/architectures.rb +35 -0
- data/spec/dummy/spec/factories/dummy/module/authors.rb +10 -0
- data/spec/dummy/spec/factories/dummy/module/classes.rb +40 -0
- data/spec/dummy/spec/factories/dummy/module/instances.rb +86 -0
- data/spec/dummy/spec/factories/dummy/module/paths.rb +16 -0
- data/spec/dummy/spec/factories/dummy/module/platforms.rb +35 -0
- data/spec/dummy/spec/factories/dummy/module/ranks.rb +14 -0
- data/spec/dummy/spec/factories/dummy/module/references.rb +17 -0
- data/spec/dummy/spec/factories/dummy/module/target/architectures.rb +40 -0
- data/spec/dummy/spec/factories/dummy/module/target/platforms.rb +41 -0
- data/spec/dummy/spec/factories/dummy/module/targets.rb +46 -0
- data/spec/dummy/spec/factories/dummy/platforms.rb +3 -0
- data/spec/dummy/spec/factories/dummy/references.rb +26 -0
- data/spec/factories/metasploit/model/architectures.rb +6 -0
- data/spec/factories/metasploit/model/association/reflections.rb +9 -0
- data/spec/factories/metasploit/model/authorities.rb +28 -0
- data/spec/factories/metasploit/model/authors.rb +9 -0
- data/spec/factories/metasploit/model/bases.rb +10 -0
- data/spec/factories/metasploit/model/email_addresses.rb +14 -0
- data/spec/factories/metasploit/model/module/actions.rb +9 -0
- data/spec/factories/metasploit/model/module/ancestors.rb +180 -0
- data/spec/factories/metasploit/model/module/architectures.rb +15 -0
- data/spec/factories/metasploit/model/module/classes.rb +47 -0
- data/spec/factories/metasploit/model/module/handlers.rb +3 -0
- data/spec/factories/metasploit/model/module/instances.rb +83 -0
- data/spec/factories/metasploit/model/module/paths.rb +51 -0
- data/spec/factories/metasploit/model/module/platforms.rb +15 -0
- data/spec/factories/metasploit/model/module/ranks.rb +9 -0
- data/spec/factories/metasploit/model/module/references.rb +11 -0
- data/spec/factories/metasploit/model/module/stances.rb +3 -0
- data/spec/factories/metasploit/model/module/targets.rb +22 -0
- data/spec/factories/metasploit/model/module/types.rb +5 -0
- data/spec/factories/metasploit/model/references.rb +88 -0
- data/spec/factories/metasploit/model/search/operator/associations.rb +5 -0
- data/spec/factories/metasploit/model/search/operator/attributes.rb +7 -0
- data/spec/factories/metasploit/model/search/operator/bases.rb +5 -0
- data/spec/lib/metasploit/model/architecture_spec.rb +52 -0
- data/spec/lib/metasploit/model/association/error_spec.rb +48 -0
- data/spec/lib/metasploit/model/association_spec.rb +145 -0
- data/spec/lib/metasploit/model/author_spec.rb +6 -0
- data/spec/lib/metasploit/model/authority/bid_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/cve_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/msb_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/osvdb_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/pmasa_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/secunia_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/us_cert_vu_spec.rb +17 -0
- data/spec/lib/metasploit/model/authority/waraxe_spec.rb +51 -0
- data/spec/lib/metasploit/model/authority/zdi_spec.rb +21 -0
- data/spec/lib/metasploit/model/authority_spec.rb +10 -0
- data/spec/lib/metasploit/model/base_spec.rb +58 -0
- data/spec/lib/metasploit/model/configuration/autoload_spec.rb +165 -0
- data/spec/lib/metasploit/model/configuration/child_spec.rb +24 -0
- data/spec/lib/metasploit/model/configuration/error_spec.rb +5 -0
- data/spec/lib/metasploit/model/configuration/i18n_spec.rb +103 -0
- data/spec/lib/metasploit/model/configuration_spec.rb +106 -0
- data/spec/lib/metasploit/model/configured_spec.rb +41 -0
- data/spec/lib/metasploit/model/derivation/full_name_spec.rb +75 -0
- data/spec/lib/metasploit/model/derivation_spec.rb +217 -0
- data/spec/lib/metasploit/model/email_address_spec.rb +19 -0
- data/spec/lib/metasploit/model/engine_spec.rb +84 -0
- data/spec/lib/metasploit/model/file_spec.rb +43 -0
- data/spec/lib/metasploit/model/invalid_spec.rb +54 -0
- data/spec/lib/metasploit/model/module/action_spec.rb +6 -0
- data/spec/lib/metasploit/model/module/ancestor_spec.rb +6 -0
- data/spec/lib/metasploit/model/module/architecture_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/author_spec.rb +6 -0
- data/spec/lib/metasploit/model/module/class_spec.rb +19 -0
- data/spec/lib/metasploit/model/module/handler_spec.rb +61 -0
- data/spec/lib/metasploit/model/module/instance_spec.rb +183 -0
- data/spec/lib/metasploit/model/module/path_spec.rb +6 -0
- data/spec/lib/metasploit/model/module/platform_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/rank_spec.rb +29 -0
- data/spec/lib/metasploit/model/module/reference_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/stance_spec.rb +30 -0
- data/spec/lib/metasploit/model/module/target/architecture_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/target/platform_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/target_spec.rb +9 -0
- data/spec/lib/metasploit/model/module/type_spec.rb +125 -0
- data/spec/lib/metasploit/model/nilify_blanks_spec.rb +156 -0
- data/spec/lib/metasploit/model/platform_spec.rb +100 -0
- data/spec/lib/metasploit/model/reference_spec.rb +21 -0
- data/spec/lib/metasploit/model/search/association_spec.rb +33 -0
- data/spec/lib/metasploit/model/search/attribute_spec.rb +99 -0
- data/spec/lib/metasploit/model/search/operation/integer/value_spec.rb +20 -0
- data/spec/lib/metasploit/model/search/operation/string/value_spec.rb +20 -0
- data/spec/lib/metasploit/model/search/operation_spec.rb +144 -0
- data/spec/lib/metasploit/model/search/operator/help_spec.rb +41 -0
- data/spec/lib/metasploit/model/search/with_spec.rb +81 -0
- data/spec/lib/metasploit/model/search_spec.rb +230 -0
- data/spec/lib/metasploit/model/spec/error_spec.rb +5 -0
- data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +42 -0
- data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +55 -0
- data/spec/lib/metasploit/model/spec_spec.rb +114 -0
- data/spec/lib/metasploit/model/translation_spec.rb +82 -0
- data/spec/lib/metasploit/model/version_spec.rb +141 -0
- data/spec/lib/metasploit/model/visitation/visit_spec.rb +316 -0
- data/spec/lib/metasploit/model_spec.rb +68 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/support/shared/contexts/metasploit/model/configuration.rb +11 -0
- data/spec/support/shared/contexts/metasploit/model/module/ancestor/contents/metasploit_module.rb +12 -0
- data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents.rb +10 -0
- data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents/metasploit_module.rb +15 -0
- data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +13 -0
- data/spec/support/shared/examples/derives.rb +115 -0
- data/spec/support/shared/examples/metasploit/model/architecture.rb +425 -0
- data/spec/support/shared/examples/metasploit/model/architecture/seed.rb +25 -0
- data/spec/support/shared/examples/metasploit/model/author.rb +27 -0
- data/spec/support/shared/examples/metasploit/model/authority.rb +124 -0
- data/spec/support/shared/examples/metasploit/model/authority/seed.rb +49 -0
- data/spec/support/shared/examples/metasploit/model/configuration/parent/child.rb +60 -0
- data/spec/support/shared/examples/metasploit/model/email_address.rb +220 -0
- data/spec/support/shared/examples/metasploit/model/module/action.rb +26 -0
- data/spec/support/shared/examples/metasploit/model/module/ancestor.rb +2004 -0
- data/spec/support/shared/examples/metasploit/model/module/ancestor/payload_factory.rb +63 -0
- data/spec/support/shared/examples/metasploit/model/module/architecture.rb +36 -0
- data/spec/support/shared/examples/metasploit/model/module/author.rb +29 -0
- data/spec/support/shared/examples/metasploit/model/module/class.rb +1514 -0
- data/spec/support/shared/examples/metasploit/model/module/handler.rb +21 -0
- data/spec/support/shared/examples/metasploit/model/module/instance.rb +1384 -0
- data/spec/support/shared/examples/metasploit/model/module/instance/class_methods.rb +537 -0
- data/spec/support/shared/examples/metasploit/model/module/instance/is_not_stanced_with_module_type.rb +22 -0
- data/spec/support/shared/examples/metasploit/model/module/instance/is_stanced_with_module_type.rb +38 -0
- data/spec/support/shared/examples/metasploit/model/module/instance/validates/dynamic_length_of.rb +131 -0
- data/spec/support/shared/examples/metasploit/model/module/path.rb +493 -0
- data/spec/support/shared/examples/metasploit/model/module/platform.rb +36 -0
- data/spec/support/shared/examples/metasploit/model/module/rank.rb +92 -0
- data/spec/support/shared/examples/metasploit/model/module/reference.rb +16 -0
- data/spec/support/shared/examples/metasploit/model/module/target.rb +29 -0
- data/spec/support/shared/examples/metasploit/model/module/target/architecture.rb +56 -0
- data/spec/support/shared/examples/metasploit/model/module/target/platform.rb +56 -0
- data/spec/support/shared/examples/metasploit/model/platform.rb +213 -0
- data/spec/support/shared/examples/metasploit/model/real_pathname.rb +29 -0
- data/spec/support/shared/examples/metasploit/model/reference.rb +410 -0
- data/spec/support/shared/examples/metasploit/model/search/operation/integer/value.rb +79 -0
- data/spec/support/shared/examples/metasploit/model/search/operation/string/value.rb +53 -0
- data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +134 -0
- data/spec/support/shared/examples/metasploit/model/translation.rb +37 -0
- data/spec/support/shared/examples/search/query.rb +43 -0
- data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/app.rb +44 -0
- data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +60 -0
- data/spec/support/shared/examples/search_association.rb +13 -0
- data/spec/support/shared/examples/search_attribute.rb +27 -0
- data/spec/support/shared/examples/search_with.rb +36 -0
- data/spec/support/shared/matchers/allow_attribute.rb +17 -0
- data/spec/support/templates/metasploit/model/module/ancestors/_attributes.rb.erb +9 -0
- data/spec/support/templates/metasploit/model/module/ancestors/_methods.rb.erb +8 -0
- data/spec/support/templates/metasploit/model/module/ancestors/_validations.rb.erb +6 -0
- data/spec/support/templates/metasploit/model/module/ancestors/base.rb.erb +3 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_auxiliary.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_encoder.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_exploit.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_non_payload.rb.erb +5 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_nop.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_payload.rb.erb +4 -0
- data/spec/support/templates/metasploit/model/module/ancestors/module_types/_post.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_handled.rb.erb +20 -0
- data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_single.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stage.rb.erb +0 -0
- data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stager.rb.erb +1 -0
- data/spec/support/templates/metasploit/model/module/classes/_methods.rb.erb +9 -0
- metadata +747 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
shared_examples_for 'Metasploit::Model::Module::Handler' do
|
2
|
+
it { should be_a Module }
|
3
|
+
|
4
|
+
context 'general_handler_type' do
|
5
|
+
subject(:general_handler_type) do
|
6
|
+
handler_module.general_handler_type
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be in Metasploit::Model::Module::Handler::GENERAL_TYPES' do
|
10
|
+
general_handler_type.should be_in Metasploit::Model::Module::Handler::GENERAL_TYPES
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'handler_type' do
|
15
|
+
subject(:handler_type) do
|
16
|
+
handler_module.handler_type
|
17
|
+
end
|
18
|
+
|
19
|
+
it { should be_a String }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,1384 @@
|
|
1
|
+
Metasploit::Model::Spec.shared_examples_for 'Module::Instance' do
|
2
|
+
#
|
3
|
+
# Classes
|
4
|
+
#
|
5
|
+
|
6
|
+
architecture_class = "#{namespace_name}::Architecture".constantize
|
7
|
+
platform_class = "#{namespace_name}::Platform".constantize
|
8
|
+
|
9
|
+
#
|
10
|
+
# Factories
|
11
|
+
#
|
12
|
+
|
13
|
+
module_action_factory = "#{factory_namespace}_module_action"
|
14
|
+
module_architecture_factory = "#{factory_namespace}_module_architecture"
|
15
|
+
module_class_factory = "#{factory_namespace}_module_class"
|
16
|
+
module_instance_factory = "#{factory_namespace}_module_instance"
|
17
|
+
module_platform_factory = "#{factory_namespace}_module_platform"
|
18
|
+
module_reference_factory = "#{factory_namespace}_module_reference"
|
19
|
+
module_target_factory = "#{factory_namespace}_module_target"
|
20
|
+
|
21
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance::ClassMethods' do
|
22
|
+
let(:singleton_class) do
|
23
|
+
base_class
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'CONSTANTS' do
|
28
|
+
context 'DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE' do
|
29
|
+
subject(:dynamic_length_validation_options) do
|
30
|
+
dynamic_length_validation_options_by_module_type[module_type]
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:dynamic_length_validation_options_by_module_type) do
|
34
|
+
dynamic_length_validation_options_by_module_type_by_attribute[attribute]
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:dynamic_length_validation_options_by_module_type_by_attribute) do
|
38
|
+
described_class::DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE
|
39
|
+
end
|
40
|
+
|
41
|
+
context "[:actions]" do
|
42
|
+
let(:attribute) do
|
43
|
+
:actions
|
44
|
+
end
|
45
|
+
|
46
|
+
context "['auxiliary']" do
|
47
|
+
let(:module_type) do
|
48
|
+
'auxiliary'
|
49
|
+
end
|
50
|
+
|
51
|
+
its([:minimum]) { should == 0 }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "['encoder']" do
|
55
|
+
let(:module_type) do
|
56
|
+
'encoder'
|
57
|
+
end
|
58
|
+
|
59
|
+
its([:is]) { should == 0 }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "['exploit']" do
|
63
|
+
let(:module_type) do
|
64
|
+
'exploit'
|
65
|
+
end
|
66
|
+
|
67
|
+
its([:is]) { should == 0 }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "['nop']" do
|
71
|
+
let(:module_type) do
|
72
|
+
'nop'
|
73
|
+
end
|
74
|
+
|
75
|
+
its([:is]) { should == 0 }
|
76
|
+
end
|
77
|
+
|
78
|
+
context "['payload']" do
|
79
|
+
let(:module_type) do
|
80
|
+
'payload'
|
81
|
+
end
|
82
|
+
|
83
|
+
its([:is]) { should == 0 }
|
84
|
+
end
|
85
|
+
|
86
|
+
context "['post']" do
|
87
|
+
let(:module_type) do
|
88
|
+
'post'
|
89
|
+
end
|
90
|
+
|
91
|
+
its([:minimum]) { should == 0 }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context '[:module_architectures:]' do
|
96
|
+
let(:attribute) do
|
97
|
+
:module_architectures
|
98
|
+
end
|
99
|
+
|
100
|
+
context "['auxiliary']" do
|
101
|
+
let(:module_type) do
|
102
|
+
'auxiliary'
|
103
|
+
end
|
104
|
+
|
105
|
+
its([:is]) { should == 0 }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "['encoder']" do
|
109
|
+
let(:module_type) do
|
110
|
+
'encoder'
|
111
|
+
end
|
112
|
+
|
113
|
+
its([:minimum]) { should == 1 }
|
114
|
+
end
|
115
|
+
|
116
|
+
context "['exploit']" do
|
117
|
+
let(:module_type) do
|
118
|
+
'exploit'
|
119
|
+
end
|
120
|
+
|
121
|
+
its([:minimum]) { should == 1 }
|
122
|
+
end
|
123
|
+
|
124
|
+
context "['nop']" do
|
125
|
+
let(:module_type) do
|
126
|
+
'nop'
|
127
|
+
end
|
128
|
+
|
129
|
+
its([:minimum]) { should == 1 }
|
130
|
+
end
|
131
|
+
|
132
|
+
context "['payload']" do
|
133
|
+
let(:module_type) do
|
134
|
+
'payload'
|
135
|
+
end
|
136
|
+
|
137
|
+
its([:minimum]) { should == 1 }
|
138
|
+
end
|
139
|
+
|
140
|
+
context "['post']" do
|
141
|
+
let(:module_type) do
|
142
|
+
'post'
|
143
|
+
end
|
144
|
+
|
145
|
+
its([:minimum]) { should == 1 }
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context '[:module_platforms]' do
|
150
|
+
let(:attribute) do
|
151
|
+
:module_platforms
|
152
|
+
end
|
153
|
+
|
154
|
+
context "['auxiliary']" do
|
155
|
+
let(:module_type) do
|
156
|
+
'auxiliary'
|
157
|
+
end
|
158
|
+
|
159
|
+
its([:is]) { should == 0 }
|
160
|
+
end
|
161
|
+
|
162
|
+
context "['encoder']" do
|
163
|
+
let(:module_type) do
|
164
|
+
'encoder'
|
165
|
+
end
|
166
|
+
|
167
|
+
its([:is]) { should == 0 }
|
168
|
+
end
|
169
|
+
|
170
|
+
context "['exploit']" do
|
171
|
+
let(:module_type) do
|
172
|
+
'exploit'
|
173
|
+
end
|
174
|
+
|
175
|
+
its([:minimum]) { should == 1 }
|
176
|
+
end
|
177
|
+
|
178
|
+
context "['nop']" do
|
179
|
+
let(:module_type) do
|
180
|
+
'nop'
|
181
|
+
end
|
182
|
+
|
183
|
+
its([:is]) { should == 0 }
|
184
|
+
end
|
185
|
+
|
186
|
+
context "['payload']" do
|
187
|
+
let(:module_type) do
|
188
|
+
'payload'
|
189
|
+
end
|
190
|
+
|
191
|
+
its([:minimum]) { should == 1 }
|
192
|
+
end
|
193
|
+
|
194
|
+
context "['post']" do
|
195
|
+
let(:module_type) do
|
196
|
+
'post'
|
197
|
+
end
|
198
|
+
|
199
|
+
its([:minimum]) { should == 1 }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context '[:module_references]' do
|
204
|
+
let(:attribute) do
|
205
|
+
:module_references
|
206
|
+
end
|
207
|
+
|
208
|
+
context "['auxiliary']" do
|
209
|
+
let(:module_type) do
|
210
|
+
'auxiliary'
|
211
|
+
end
|
212
|
+
|
213
|
+
its([:minimum]) { should == 0 }
|
214
|
+
end
|
215
|
+
|
216
|
+
context "['encoder']" do
|
217
|
+
let(:module_type) do
|
218
|
+
'encoder'
|
219
|
+
end
|
220
|
+
|
221
|
+
its([:is]) { should == 0 }
|
222
|
+
end
|
223
|
+
|
224
|
+
context "['exploit']" do
|
225
|
+
let(:module_type) do
|
226
|
+
'exploit'
|
227
|
+
end
|
228
|
+
|
229
|
+
its([:minimum]) { should == 1 }
|
230
|
+
end
|
231
|
+
|
232
|
+
context "['nop']" do
|
233
|
+
let(:module_type) do
|
234
|
+
'nop'
|
235
|
+
end
|
236
|
+
|
237
|
+
its([:is]) { should == 0 }
|
238
|
+
end
|
239
|
+
|
240
|
+
context "['payload']" do
|
241
|
+
let(:module_type) do
|
242
|
+
'payload'
|
243
|
+
end
|
244
|
+
|
245
|
+
its([:is]) { should == 0 }
|
246
|
+
end
|
247
|
+
|
248
|
+
context "['post']" do
|
249
|
+
let(:module_type) do
|
250
|
+
'post'
|
251
|
+
end
|
252
|
+
|
253
|
+
its([:minimum]) { should == 0 }
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context '[:targets]' do
|
258
|
+
let(:attribute) do
|
259
|
+
:targets
|
260
|
+
end
|
261
|
+
|
262
|
+
context "['auxiliary']" do
|
263
|
+
let(:module_type) do
|
264
|
+
'auxiliary'
|
265
|
+
end
|
266
|
+
|
267
|
+
its([:is]) { should == 0 }
|
268
|
+
end
|
269
|
+
|
270
|
+
context "['encoder']" do
|
271
|
+
let(:module_type) do
|
272
|
+
'encoder'
|
273
|
+
end
|
274
|
+
|
275
|
+
its([:is]) { should == 0 }
|
276
|
+
end
|
277
|
+
|
278
|
+
context "['exploit']" do
|
279
|
+
let(:module_type) do
|
280
|
+
'exploit'
|
281
|
+
end
|
282
|
+
|
283
|
+
its([:minimum]) { should == 1 }
|
284
|
+
end
|
285
|
+
|
286
|
+
context "['nop']" do
|
287
|
+
let(:module_type) do
|
288
|
+
'nop'
|
289
|
+
end
|
290
|
+
|
291
|
+
its([:is]) { should == 0 }
|
292
|
+
end
|
293
|
+
|
294
|
+
context "['payload']" do
|
295
|
+
let(:module_type) do
|
296
|
+
'payload'
|
297
|
+
end
|
298
|
+
|
299
|
+
its([:is]) { should == 0 }
|
300
|
+
end
|
301
|
+
|
302
|
+
context "['post']" do
|
303
|
+
let(:module_type) do
|
304
|
+
'post'
|
305
|
+
end
|
306
|
+
|
307
|
+
its([:is]) { should == 0 }
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
context 'MINIMUM_MODULE_AUTHORS_LENGTH' do
|
313
|
+
subject(:minimum_module_authors_length) do
|
314
|
+
described_class::MINIMUM_MODULE_AUTHORS_LENGTH
|
315
|
+
end
|
316
|
+
|
317
|
+
it { should == 1 }
|
318
|
+
end
|
319
|
+
|
320
|
+
context 'PRIVILEGES' do
|
321
|
+
subject(:privileges) do
|
322
|
+
described_class::PRIVILEGES
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'should contain both Boolean values' do
|
326
|
+
privileges.should include(false)
|
327
|
+
privileges.should include(true)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
context 'factories' do
|
333
|
+
context module_instance_factory do
|
334
|
+
subject(module_instance_factory) do
|
335
|
+
FactoryGirl.build(module_instance_factory)
|
336
|
+
end
|
337
|
+
|
338
|
+
it { should be_valid }
|
339
|
+
|
340
|
+
context 'Metasploit::Model::Module::Class#module_type' do
|
341
|
+
subject(module_class_factory) do
|
342
|
+
FactoryGirl.build(
|
343
|
+
module_instance_factory,
|
344
|
+
module_class: module_class
|
345
|
+
)
|
346
|
+
end
|
347
|
+
|
348
|
+
let(:module_class) do
|
349
|
+
FactoryGirl.create(
|
350
|
+
module_class_factory,
|
351
|
+
:module_type => module_type
|
352
|
+
)
|
353
|
+
end
|
354
|
+
|
355
|
+
context 'with auxiliary' do
|
356
|
+
let(:module_type) do
|
357
|
+
'auxiliary'
|
358
|
+
end
|
359
|
+
|
360
|
+
it { should be_valid }
|
361
|
+
|
362
|
+
it { should allow_attribute :actions }
|
363
|
+
it { should_not allow_attribute :module_architectures }
|
364
|
+
it { should_not allow_attribute :module_platforms }
|
365
|
+
it { should allow_attribute :module_references }
|
366
|
+
it { should_not allow_attribute :targets }
|
367
|
+
|
368
|
+
it { should be_stanced }
|
369
|
+
end
|
370
|
+
|
371
|
+
context 'with encoder' do
|
372
|
+
let(:module_type) do
|
373
|
+
'encoder'
|
374
|
+
end
|
375
|
+
|
376
|
+
it { should be_valid }
|
377
|
+
|
378
|
+
it { should_not allow_attribute :actions }
|
379
|
+
it { should allow_attribute :module_architectures }
|
380
|
+
it { should_not allow_attribute :module_platforms }
|
381
|
+
it { should_not allow_attribute :module_references }
|
382
|
+
it { should_not allow_attribute :targets }
|
383
|
+
|
384
|
+
it { should_not be_stanced }
|
385
|
+
end
|
386
|
+
|
387
|
+
context 'with exploit' do
|
388
|
+
let(:module_type) do
|
389
|
+
'exploit'
|
390
|
+
end
|
391
|
+
|
392
|
+
it { should be_valid }
|
393
|
+
|
394
|
+
it { should_not allow_attribute :actions }
|
395
|
+
it { should allow_attribute :module_architectures }
|
396
|
+
it { should allow_attribute :module_platforms }
|
397
|
+
it { should allow_attribute :module_references }
|
398
|
+
it { should allow_attribute :targets }
|
399
|
+
|
400
|
+
it { should be_stanced }
|
401
|
+
end
|
402
|
+
|
403
|
+
context 'with nop' do
|
404
|
+
let(:module_type) do
|
405
|
+
'nop'
|
406
|
+
end
|
407
|
+
|
408
|
+
it { should be_valid }
|
409
|
+
|
410
|
+
it { should_not allow_attribute :actions }
|
411
|
+
it { should allow_attribute :module_architectures }
|
412
|
+
it { should_not allow_attribute :module_platforms }
|
413
|
+
it { should_not allow_attribute :module_references }
|
414
|
+
it { should_not allow_attribute :targets }
|
415
|
+
|
416
|
+
it { should_not be_stanced }
|
417
|
+
end
|
418
|
+
|
419
|
+
context 'with payload' do
|
420
|
+
let(:module_type) do
|
421
|
+
'payload'
|
422
|
+
end
|
423
|
+
|
424
|
+
it { should be_valid }
|
425
|
+
|
426
|
+
it { should_not allow_attribute :actions }
|
427
|
+
it { should allow_attribute :module_architectures }
|
428
|
+
it { should allow_attribute :module_platforms }
|
429
|
+
it { should_not allow_attribute :module_references }
|
430
|
+
it { should_not allow_attribute :targets }
|
431
|
+
|
432
|
+
it { should_not be_stanced }
|
433
|
+
end
|
434
|
+
|
435
|
+
context 'with post' do
|
436
|
+
let(:module_type) do
|
437
|
+
'post'
|
438
|
+
end
|
439
|
+
|
440
|
+
it { should be_valid }
|
441
|
+
|
442
|
+
it { should allow_attribute :actions }
|
443
|
+
it { should allow_attribute :module_architectures }
|
444
|
+
it { should allow_attribute :module_platforms }
|
445
|
+
it { should allow_attribute :module_references }
|
446
|
+
it { should_not allow_attribute :targets }
|
447
|
+
|
448
|
+
it { should_not be_stanced }
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
context 'search' do
|
455
|
+
context 'associations' do
|
456
|
+
it_should_behave_like 'search_association', :actions
|
457
|
+
it_should_behave_like 'search_association', :architectures
|
458
|
+
it_should_behave_like 'search_association', :authorities
|
459
|
+
it_should_behave_like 'search_association', :authors
|
460
|
+
it_should_behave_like 'search_association', :email_addresses
|
461
|
+
it_should_behave_like 'search_association', :module_class
|
462
|
+
it_should_behave_like 'search_association', :platforms
|
463
|
+
it_should_behave_like 'search_association', :rank
|
464
|
+
it_should_behave_like 'search_association', :references
|
465
|
+
it_should_behave_like 'search_association', :targets
|
466
|
+
end
|
467
|
+
|
468
|
+
context 'attributes' do
|
469
|
+
it_should_behave_like 'search_attribute', :description, :type => :string
|
470
|
+
it_should_behave_like 'search_attribute', :disclosed_on, :type => :date
|
471
|
+
it_should_behave_like 'search_attribute', :license, :type => :string
|
472
|
+
it_should_behave_like 'search_attribute', :name, :type => :string
|
473
|
+
it_should_behave_like 'search_attribute', :privileged, :type => :boolean
|
474
|
+
it_should_behave_like 'search_attribute', :stance, :type => :string
|
475
|
+
end
|
476
|
+
|
477
|
+
context 'withs' do
|
478
|
+
it_should_behave_like 'search_with',
|
479
|
+
Metasploit::Model::Search::Operator::Deprecated::App,
|
480
|
+
:name => :app
|
481
|
+
it_should_behave_like 'search_with',
|
482
|
+
Metasploit::Model::Search::Operator::Deprecated::Author,
|
483
|
+
:name => :author
|
484
|
+
it_should_behave_like 'search_with',
|
485
|
+
Metasploit::Model::Search::Operator::Deprecated::Authority,
|
486
|
+
:abbreviation => :bid,
|
487
|
+
:name => :bid
|
488
|
+
it_should_behave_like 'search_with',
|
489
|
+
Metasploit::Model::Search::Operator::Deprecated::Authority,
|
490
|
+
:abbreviation => :cve,
|
491
|
+
:name => :cve
|
492
|
+
it_should_behave_like 'search_with',
|
493
|
+
Metasploit::Model::Search::Operator::Deprecated::Authority,
|
494
|
+
:abbreviation => :edb,
|
495
|
+
:name => :edb
|
496
|
+
it_should_behave_like 'search_with',
|
497
|
+
Metasploit::Model::Search::Operator::Deprecated::Authority,
|
498
|
+
:abbreviation => :osvdb,
|
499
|
+
:name => :osvdb
|
500
|
+
it_should_behave_like 'search_with',
|
501
|
+
Metasploit::Model::Search::Operator::Deprecated::Platform,
|
502
|
+
:name => :os
|
503
|
+
it_should_behave_like 'search_with',
|
504
|
+
Metasploit::Model::Search::Operator::Deprecated::Platform,
|
505
|
+
:name => :platform
|
506
|
+
it_should_behave_like 'search_with',
|
507
|
+
Metasploit::Model::Search::Operator::Deprecated::Ref,
|
508
|
+
:name => :ref
|
509
|
+
it_should_behave_like 'search_with',
|
510
|
+
Metasploit::Model::Search::Operator::Deprecated::Text,
|
511
|
+
:name => :text
|
512
|
+
end
|
513
|
+
|
514
|
+
context 'query' do
|
515
|
+
it_should_behave_like 'search query with Metasploit::Model::Search::Operator::Deprecated::App'
|
516
|
+
it_should_behave_like 'search query with Metasploit::Model::Search::Operator::Deprecated::Authority',
|
517
|
+
:formatted_operator => 'bid'
|
518
|
+
it_should_behave_like 'search query with Metasploit::Model::Search::Operator::Deprecated::Authority',
|
519
|
+
:formatted_operator => 'cve'
|
520
|
+
it_should_behave_like 'search query', :formatted_operator => 'description'
|
521
|
+
it_should_behave_like 'search query', :formatted_operator => 'disclosed_on'
|
522
|
+
it_should_behave_like 'search query with Metasploit::Model::Search::Operator::Deprecated::Authority',
|
523
|
+
:formatted_operator => 'edb'
|
524
|
+
it_should_behave_like 'search query', :formatted_operator => 'license'
|
525
|
+
it_should_behave_like 'search query', :formatted_operator => 'name'
|
526
|
+
it_should_behave_like 'search query', :formatted_operator => 'os'
|
527
|
+
it_should_behave_like 'search query with Metasploit::Model::Search::Operator::Deprecated::Authority',
|
528
|
+
:formatted_operator => 'osvdb'
|
529
|
+
it_should_behave_like 'search query', :formatted_operator => 'platform'
|
530
|
+
it_should_behave_like 'search query', :formatted_operator => 'privileged'
|
531
|
+
it_should_behave_like 'search query', :formatted_operator => 'ref'
|
532
|
+
it_should_behave_like 'search query', :formatted_operator => 'stance'
|
533
|
+
it_should_behave_like 'search query', :formatted_operator => 'text'
|
534
|
+
|
535
|
+
it_should_behave_like 'search query', :formatted_operator => 'actions.name'
|
536
|
+
|
537
|
+
context 'architectures' do
|
538
|
+
it_should_behave_like 'search query', :formatted_operator => 'architectures.abbreviation'
|
539
|
+
it_should_behave_like 'search query', :formatted_operator => 'architectures.bits'
|
540
|
+
it_should_behave_like 'search query', :formatted_operator => 'architectures.endianness'
|
541
|
+
it_should_behave_like 'search query', :formatted_operator => 'architectures.family'
|
542
|
+
end
|
543
|
+
|
544
|
+
it_should_behave_like 'search query', :formatted_operator => 'authorities.abbreviation'
|
545
|
+
it_should_behave_like 'search query', :formatted_operator => 'authors.name'
|
546
|
+
|
547
|
+
context 'email_addresses' do
|
548
|
+
it_should_behave_like 'search query', :formatted_operator => 'email_addresses.domain'
|
549
|
+
it_should_behave_like 'search query', :formatted_operator => 'email_addresses.local'
|
550
|
+
end
|
551
|
+
|
552
|
+
context 'module_class' do
|
553
|
+
it_should_behave_like 'search query', :formatted_operator => 'module_class.full_name'
|
554
|
+
it_should_behave_like 'search query', :formatted_operator => 'module_class.module_type'
|
555
|
+
it_should_behave_like 'search query', :formatted_operator => 'module_class.payload_type'
|
556
|
+
it_should_behave_like 'search query', :formatted_operator => 'module_class.reference_name'
|
557
|
+
end
|
558
|
+
|
559
|
+
it_should_behave_like 'search query', :formatted_operator => 'platforms.fully_qualified_name'
|
560
|
+
|
561
|
+
context 'rank' do
|
562
|
+
it_should_behave_like 'search query', :formatted_operator => 'rank.name'
|
563
|
+
it_should_behave_like 'search query', :formatted_operator => 'rank.number'
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'references' do
|
567
|
+
it_should_behave_like 'search query', :formatted_operator => 'references.designation'
|
568
|
+
it_should_behave_like 'search query', :formatted_operator => 'references.url'
|
569
|
+
end
|
570
|
+
|
571
|
+
it_should_behave_like 'search query', :formatted_operator => 'targets.name'
|
572
|
+
end
|
573
|
+
end
|
574
|
+
|
575
|
+
context 'validations' do
|
576
|
+
subject(:module_instance) do
|
577
|
+
FactoryGirl.build(
|
578
|
+
module_instance_factory,
|
579
|
+
module_class: module_class
|
580
|
+
)
|
581
|
+
end
|
582
|
+
|
583
|
+
let(:module_class) do
|
584
|
+
FactoryGirl.create(
|
585
|
+
module_class_factory,
|
586
|
+
module_type: module_type
|
587
|
+
)
|
588
|
+
end
|
589
|
+
|
590
|
+
let(:module_type) do
|
591
|
+
module_types.sample
|
592
|
+
end
|
593
|
+
|
594
|
+
let(:module_types) do
|
595
|
+
Metasploit::Model::Module::Type::ALL
|
596
|
+
end
|
597
|
+
|
598
|
+
it { should validate_presence_of :description }
|
599
|
+
it { should validate_presence_of :license }
|
600
|
+
it { should ensure_length_of(:module_authors) }
|
601
|
+
|
602
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance validates dynamic length of',
|
603
|
+
:actions,
|
604
|
+
factory: module_action_factory,
|
605
|
+
options_by_extreme_by_module_type: {
|
606
|
+
'auxiliary' => {
|
607
|
+
maximum: {
|
608
|
+
extreme: Float::INFINITY
|
609
|
+
},
|
610
|
+
minimum: {
|
611
|
+
extreme: 0
|
612
|
+
}
|
613
|
+
},
|
614
|
+
'encoder' => {
|
615
|
+
maximum: {
|
616
|
+
error_type: :wrong_length,
|
617
|
+
extreme: 0
|
618
|
+
},
|
619
|
+
minimum: {
|
620
|
+
extreme: 0
|
621
|
+
}
|
622
|
+
},
|
623
|
+
'exploit' => {
|
624
|
+
maximum: {
|
625
|
+
error_type: :wrong_length,
|
626
|
+
extreme: 0
|
627
|
+
},
|
628
|
+
minimum: {
|
629
|
+
extreme: 0
|
630
|
+
}
|
631
|
+
},
|
632
|
+
'nop' => {
|
633
|
+
maximum: {
|
634
|
+
error_type: :wrong_length,
|
635
|
+
extreme: 0
|
636
|
+
},
|
637
|
+
minimum: {
|
638
|
+
extreme: 0
|
639
|
+
}
|
640
|
+
},
|
641
|
+
'payload' => {
|
642
|
+
maximum: {
|
643
|
+
error_type: :wrong_length,
|
644
|
+
extreme: 0
|
645
|
+
},
|
646
|
+
minimum: {
|
647
|
+
extreme: 0
|
648
|
+
}
|
649
|
+
},
|
650
|
+
'post' => {
|
651
|
+
maximum: {
|
652
|
+
extreme: Float::INFINITY
|
653
|
+
},
|
654
|
+
minimum: {
|
655
|
+
extreme: 0
|
656
|
+
}
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance validates dynamic length of',
|
661
|
+
:module_architectures,
|
662
|
+
factory: module_architecture_factory,
|
663
|
+
options_by_extreme_by_module_type: {
|
664
|
+
'auxiliary' => {
|
665
|
+
maximum: {
|
666
|
+
error_type: :wrong_length,
|
667
|
+
extreme: 0
|
668
|
+
},
|
669
|
+
minimum: {
|
670
|
+
extreme: 0
|
671
|
+
}
|
672
|
+
},
|
673
|
+
'encoder' => {
|
674
|
+
maximum: {
|
675
|
+
extreme: Float::INFINITY
|
676
|
+
},
|
677
|
+
minimum: {
|
678
|
+
error_type: :too_short,
|
679
|
+
extreme: 1
|
680
|
+
}
|
681
|
+
},
|
682
|
+
'exploit' => {
|
683
|
+
maximum: {
|
684
|
+
extreme: Float::INFINITY
|
685
|
+
},
|
686
|
+
minimum: {
|
687
|
+
error_type: :too_short,
|
688
|
+
extreme: 1
|
689
|
+
}
|
690
|
+
},
|
691
|
+
'nop' => {
|
692
|
+
maximum: {
|
693
|
+
extreme: Float::INFINITY
|
694
|
+
},
|
695
|
+
minimum: {
|
696
|
+
error_type: :too_short,
|
697
|
+
extreme: 1
|
698
|
+
}
|
699
|
+
},
|
700
|
+
'payload' => {
|
701
|
+
maximum: {
|
702
|
+
extreme: Float::INFINITY
|
703
|
+
},
|
704
|
+
minimum: {
|
705
|
+
error_type: :too_short,
|
706
|
+
extreme: 1
|
707
|
+
}
|
708
|
+
},
|
709
|
+
'post' => {
|
710
|
+
maximum: {
|
711
|
+
extreme: Float::INFINITY
|
712
|
+
},
|
713
|
+
minimum: {
|
714
|
+
error_type: :too_short,
|
715
|
+
extreme: 1
|
716
|
+
}
|
717
|
+
}
|
718
|
+
}
|
719
|
+
|
720
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance validates dynamic length of',
|
721
|
+
:module_platforms,
|
722
|
+
factory: module_platform_factory,
|
723
|
+
options_by_extreme_by_module_type: {
|
724
|
+
'auxiliary' => {
|
725
|
+
maximum: {
|
726
|
+
error_type: :wrong_length,
|
727
|
+
extreme: 0
|
728
|
+
},
|
729
|
+
minimum: {
|
730
|
+
extreme: 0
|
731
|
+
}
|
732
|
+
},
|
733
|
+
'encoder' => {
|
734
|
+
maximum: {
|
735
|
+
error_type: :wrong_length,
|
736
|
+
extreme: 0
|
737
|
+
},
|
738
|
+
minimum: {
|
739
|
+
extreme: 0
|
740
|
+
}
|
741
|
+
},
|
742
|
+
'exploit' => {
|
743
|
+
maximum: {
|
744
|
+
extreme: Float::INFINITY
|
745
|
+
},
|
746
|
+
minimum: {
|
747
|
+
error_type: :too_short,
|
748
|
+
extreme: 1
|
749
|
+
}
|
750
|
+
},
|
751
|
+
'nop' => {
|
752
|
+
maximum: {
|
753
|
+
error_type: :wrong_length,
|
754
|
+
extreme: 0
|
755
|
+
},
|
756
|
+
minimum: {
|
757
|
+
extreme: 0
|
758
|
+
}
|
759
|
+
},
|
760
|
+
'payload' => {
|
761
|
+
maximum: {
|
762
|
+
extreme: Float::INFINITY
|
763
|
+
},
|
764
|
+
minimum: {
|
765
|
+
error_type: :too_short,
|
766
|
+
extreme: 1
|
767
|
+
}
|
768
|
+
},
|
769
|
+
'post' => {
|
770
|
+
maximum: {
|
771
|
+
extreme: Float::INFINITY
|
772
|
+
},
|
773
|
+
minimum: {
|
774
|
+
error_type: :too_short,
|
775
|
+
extreme: 1
|
776
|
+
}
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance validates dynamic length of',
|
781
|
+
:module_references,
|
782
|
+
factory: module_reference_factory,
|
783
|
+
options_by_extreme_by_module_type: {
|
784
|
+
'auxiliary' => {
|
785
|
+
maximum: {
|
786
|
+
extreme: Float::INFINITY,
|
787
|
+
},
|
788
|
+
minimum: {
|
789
|
+
extreme: 0
|
790
|
+
}
|
791
|
+
},
|
792
|
+
'encoder' => {
|
793
|
+
maximum: {
|
794
|
+
error_type: :wrong_length,
|
795
|
+
extreme: 0
|
796
|
+
},
|
797
|
+
minimum: {
|
798
|
+
extreme: 0
|
799
|
+
}
|
800
|
+
},
|
801
|
+
'exploit' => {
|
802
|
+
maximum: {
|
803
|
+
extreme: Float::INFINITY
|
804
|
+
},
|
805
|
+
minimum: {
|
806
|
+
error_type: :too_short,
|
807
|
+
extreme: 1
|
808
|
+
}
|
809
|
+
},
|
810
|
+
'nop' => {
|
811
|
+
maximum: {
|
812
|
+
error_type: :wrong_length,
|
813
|
+
extreme: 0
|
814
|
+
},
|
815
|
+
minimum: {
|
816
|
+
extreme: 0
|
817
|
+
}
|
818
|
+
},
|
819
|
+
'payload' => {
|
820
|
+
maximum: {
|
821
|
+
error_type: :wrong_length,
|
822
|
+
extreme: 0
|
823
|
+
},
|
824
|
+
minimum: {
|
825
|
+
extreme: 0
|
826
|
+
}
|
827
|
+
},
|
828
|
+
'post' => {
|
829
|
+
maximum: {
|
830
|
+
extreme: Float::INFINITY,
|
831
|
+
},
|
832
|
+
minimum: {
|
833
|
+
extreme: 0
|
834
|
+
}
|
835
|
+
}
|
836
|
+
}
|
837
|
+
|
838
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance validates dynamic length of',
|
839
|
+
:targets,
|
840
|
+
factory: module_target_factory,
|
841
|
+
options_by_extreme_by_module_type: {
|
842
|
+
'auxiliary' => {
|
843
|
+
maximum: {
|
844
|
+
error_type: :wrong_length,
|
845
|
+
extreme: 0
|
846
|
+
},
|
847
|
+
minimum: {
|
848
|
+
extreme: 0
|
849
|
+
}
|
850
|
+
},
|
851
|
+
'encoder' => {
|
852
|
+
maximum: {
|
853
|
+
error_type: :wrong_length,
|
854
|
+
extreme: 0
|
855
|
+
},
|
856
|
+
minimum: {
|
857
|
+
extreme: 0
|
858
|
+
}
|
859
|
+
},
|
860
|
+
'exploit' => {
|
861
|
+
maximum: {
|
862
|
+
extreme: Float::INFINITY
|
863
|
+
},
|
864
|
+
minimum: {
|
865
|
+
error_type: :too_short,
|
866
|
+
extreme: 1
|
867
|
+
}
|
868
|
+
},
|
869
|
+
'nop' => {
|
870
|
+
maximum: {
|
871
|
+
error_type: :wrong_length,
|
872
|
+
extreme: 0
|
873
|
+
},
|
874
|
+
minimum: {
|
875
|
+
extreme: 0
|
876
|
+
}
|
877
|
+
},
|
878
|
+
'payload' => {
|
879
|
+
maximum: {
|
880
|
+
error_type: :wrong_length,
|
881
|
+
extreme: 0
|
882
|
+
},
|
883
|
+
minimum: {
|
884
|
+
extreme: 0
|
885
|
+
}
|
886
|
+
},
|
887
|
+
'post' => {
|
888
|
+
maximum: {
|
889
|
+
error_type: :wrong_length,
|
890
|
+
extreme: 0
|
891
|
+
},
|
892
|
+
minimum: {
|
893
|
+
extreme: 0
|
894
|
+
}
|
895
|
+
}
|
896
|
+
}
|
897
|
+
|
898
|
+
context 'validate presence of module_class' do
|
899
|
+
before(:each) do
|
900
|
+
module_instance.valid?
|
901
|
+
end
|
902
|
+
|
903
|
+
context 'with module_class' do
|
904
|
+
let(:module_class) do
|
905
|
+
FactoryGirl.build(module_class_factory)
|
906
|
+
end
|
907
|
+
|
908
|
+
it 'should not record error on module_class' do
|
909
|
+
module_instance.errors[:module_class].should be_empty
|
910
|
+
end
|
911
|
+
end
|
912
|
+
|
913
|
+
context 'without module_class' do
|
914
|
+
let(:module_class) do
|
915
|
+
nil
|
916
|
+
end
|
917
|
+
|
918
|
+
it 'should record error on module_class' do
|
919
|
+
module_instance.errors[:module_class].should include("can't be blank")
|
920
|
+
end
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
it { should validate_presence_of :name }
|
925
|
+
|
926
|
+
context 'ensure inclusion of privileged is boolean' do
|
927
|
+
let(:error) do
|
928
|
+
'is not included in the list'
|
929
|
+
end
|
930
|
+
|
931
|
+
before(:each) do
|
932
|
+
module_instance.privileged = privileged
|
933
|
+
|
934
|
+
module_instance.valid?
|
935
|
+
end
|
936
|
+
|
937
|
+
context 'with nil' do
|
938
|
+
let(:privileged) do
|
939
|
+
nil
|
940
|
+
end
|
941
|
+
|
942
|
+
it 'should record error' do
|
943
|
+
module_instance.errors[:privileged].should include(error)
|
944
|
+
end
|
945
|
+
end
|
946
|
+
|
947
|
+
context 'with false' do
|
948
|
+
let(:privileged) do
|
949
|
+
false
|
950
|
+
end
|
951
|
+
|
952
|
+
it 'should not record error' do
|
953
|
+
module_instance.errors[:privileged].should be_empty
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
957
|
+
context 'with true' do
|
958
|
+
let(:privileged) do
|
959
|
+
true
|
960
|
+
end
|
961
|
+
|
962
|
+
it 'should not record error' do
|
963
|
+
module_instance.errors[:privileged].should be_empty
|
964
|
+
end
|
965
|
+
end
|
966
|
+
end
|
967
|
+
|
968
|
+
context 'stance' do
|
969
|
+
context 'module_type' do
|
970
|
+
subject(:module_instance) do
|
971
|
+
FactoryGirl.build(
|
972
|
+
module_instance_factory,
|
973
|
+
:module_class => module_class,
|
974
|
+
# set by shared examples
|
975
|
+
:stance => stance
|
976
|
+
)
|
977
|
+
end
|
978
|
+
|
979
|
+
let(:stance) do
|
980
|
+
nil
|
981
|
+
end
|
982
|
+
|
983
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is stanced with module_type', 'auxiliary'
|
984
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is stanced with module_type', 'exploit'
|
985
|
+
|
986
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is not stanced with module_type', 'encoder'
|
987
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is not stanced with module_type', 'nop'
|
988
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is not stanced with module_type', 'payload'
|
989
|
+
it_should_behave_like 'Metasploit::Model::Module::Instance is not stanced with module_type', 'post'
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
context 'with allows?(:targets)' do
|
994
|
+
let(:module_instance) do
|
995
|
+
FactoryGirl.build(
|
996
|
+
module_instance_factory,
|
997
|
+
module_class: module_class,
|
998
|
+
# create targets manually to control the number of target architectures and target platforms
|
999
|
+
targets_length: 0
|
1000
|
+
).tap { |module_instance|
|
1001
|
+
FactoryGirl.build(
|
1002
|
+
module_target_factory,
|
1003
|
+
module_instance: module_instance,
|
1004
|
+
# need to restrict to 1 architecture and platform to ensure there is an extra architecture or platform
|
1005
|
+
# available.
|
1006
|
+
target_architectures_length: 1,
|
1007
|
+
target_platforms_length: 1
|
1008
|
+
)
|
1009
|
+
}
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
let(:module_types) do
|
1013
|
+
Metasploit::Model::Module::Instance.module_types_that_allow(:targets)
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
context '#architectures errors' do
|
1017
|
+
subject(:architectures_errors) do
|
1018
|
+
module_instance.errors[:architectures]
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
context '#architectures_from_targets' do
|
1022
|
+
context 'with same architectures' do
|
1023
|
+
before(:each) do
|
1024
|
+
module_instance.valid?
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
it { should be_empty }
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
context 'without same architectures' do
|
1031
|
+
context 'with extra architectures' do
|
1032
|
+
#
|
1033
|
+
# Lets
|
1034
|
+
#
|
1035
|
+
|
1036
|
+
let(:error) do
|
1037
|
+
I18n.translate(
|
1038
|
+
'metasploit.model.errors.models.metasploit/model/module/instance.attributes.architectures.extra',
|
1039
|
+
extra: human_architecture_set
|
1040
|
+
)
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
let(:expected_architecture_set) do
|
1044
|
+
module_instance.targets.each_with_object(Set.new) do |module_target, set|
|
1045
|
+
module_target.target_architectures.each do |target_architecture|
|
1046
|
+
set.add target_architecture.architecture
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
let(:extra_architecture) do
|
1052
|
+
extra_architectures.sample
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
let(:extra_architectures) do
|
1056
|
+
architecture_class.all - expected_architecture_set.to_a
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
let(:human_architecture_set) do
|
1060
|
+
"{#{extra_architecture.abbreviation}}"
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
#
|
1064
|
+
# Callbacks
|
1065
|
+
#
|
1066
|
+
|
1067
|
+
before(:each) do
|
1068
|
+
module_instance.module_architectures << FactoryGirl.build(
|
1069
|
+
module_architecture_factory,
|
1070
|
+
architecture: extra_architecture,
|
1071
|
+
module_instance: module_instance
|
1072
|
+
)
|
1073
|
+
|
1074
|
+
module_instance.valid?
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
it 'includes extra error' do
|
1078
|
+
expect(architectures_errors).to include(error)
|
1079
|
+
end
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
context 'with missing architectures' do
|
1083
|
+
#
|
1084
|
+
# Lets
|
1085
|
+
#
|
1086
|
+
|
1087
|
+
let(:error) do
|
1088
|
+
I18n.translate(
|
1089
|
+
'metasploit.model.errors.models.metasploit/model/module/instance.attributes.architectures.missing',
|
1090
|
+
missing: human_architecture_set
|
1091
|
+
)
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
let(:human_architecture_set) do
|
1095
|
+
"{#{missing_architecture.abbreviation}}"
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
let(:missing_architecture) do
|
1099
|
+
missing_module_architecture.architecture
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
let(:missing_module_architecture) do
|
1103
|
+
module_instance.module_architectures.sample
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
#
|
1107
|
+
# Callbacks
|
1108
|
+
#
|
1109
|
+
|
1110
|
+
before(:each) do
|
1111
|
+
module_instance.module_architectures.reject! { |module_architecture|
|
1112
|
+
module_architecture == missing_module_architecture
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
module_instance.valid?
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
it 'includes missing error' do
|
1119
|
+
expect(architectures_errors).to include(error)
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
context '#platforms errors' do
|
1127
|
+
subject(:platforms_errors) do
|
1128
|
+
module_instance.errors[:platforms]
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
context '#platforms_from_targets' do
|
1132
|
+
context 'with same platforms' do
|
1133
|
+
before(:each) do
|
1134
|
+
module_instance.valid?
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
it { should be_empty }
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
context 'without same platforms' do
|
1141
|
+
context 'with extra platforms' do
|
1142
|
+
#
|
1143
|
+
# Lets
|
1144
|
+
#
|
1145
|
+
|
1146
|
+
let(:error) do
|
1147
|
+
I18n.translate(
|
1148
|
+
'metasploit.model.errors.models.metasploit/model/module/instance.attributes.platforms.extra',
|
1149
|
+
extra: human_platform_set
|
1150
|
+
)
|
1151
|
+
end
|
1152
|
+
|
1153
|
+
let(:expected_platform_set) do
|
1154
|
+
module_instance.targets.each_with_object(Set.new) do |module_target, set|
|
1155
|
+
module_target.target_platforms.each do |target_platform|
|
1156
|
+
set.add target_platform.platform
|
1157
|
+
end
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
let(:extra_platform) do
|
1162
|
+
extra_platforms.sample
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
let(:extra_platforms) do
|
1166
|
+
platform_class.all - expected_platform_set.to_a
|
1167
|
+
end
|
1168
|
+
|
1169
|
+
let(:human_platform_set) do
|
1170
|
+
"{#{extra_platform.fully_qualified_name}}"
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
#
|
1174
|
+
# Callbacks
|
1175
|
+
#
|
1176
|
+
|
1177
|
+
before(:each) do
|
1178
|
+
module_instance.module_platforms << FactoryGirl.build(
|
1179
|
+
module_platform_factory,
|
1180
|
+
platform: extra_platform,
|
1181
|
+
module_instance: module_instance
|
1182
|
+
)
|
1183
|
+
|
1184
|
+
module_instance.valid?
|
1185
|
+
end
|
1186
|
+
|
1187
|
+
it 'includes extra error' do
|
1188
|
+
expect(platforms_errors).to include(error)
|
1189
|
+
end
|
1190
|
+
end
|
1191
|
+
|
1192
|
+
context 'with missing platforms' do
|
1193
|
+
#
|
1194
|
+
# Lets
|
1195
|
+
#
|
1196
|
+
|
1197
|
+
let(:error) do
|
1198
|
+
I18n.translate(
|
1199
|
+
'metasploit.model.errors.models.metasploit/model/module/instance.attributes.platforms.missing',
|
1200
|
+
missing: human_platform_set
|
1201
|
+
)
|
1202
|
+
end
|
1203
|
+
|
1204
|
+
let(:human_platform_set) do
|
1205
|
+
"{#{missing_platform.fully_qualified_name}}"
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
let(:missing_platform) do
|
1209
|
+
missing_module_platform.platform
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
let(:missing_module_platform) do
|
1213
|
+
module_instance.module_platforms.sample
|
1214
|
+
end
|
1215
|
+
|
1216
|
+
#
|
1217
|
+
# Callbacks
|
1218
|
+
#
|
1219
|
+
|
1220
|
+
before(:each) do
|
1221
|
+
module_instance.module_platforms.reject! { |module_platform|
|
1222
|
+
module_platform == missing_module_platform
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
module_instance.valid?
|
1226
|
+
end
|
1227
|
+
|
1228
|
+
it 'includes missing error' do
|
1229
|
+
expect(platforms_errors).to include(error)
|
1230
|
+
end
|
1231
|
+
end
|
1232
|
+
end
|
1233
|
+
end
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
context '#allows?' do
|
1239
|
+
subject(:allows?) do
|
1240
|
+
module_instance.allows?(attribute)
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
let(:attribute) do
|
1244
|
+
double('Attribute')
|
1245
|
+
end
|
1246
|
+
|
1247
|
+
before(:each) do
|
1248
|
+
# can't set module_type in module_class factory because module_class would be invalid and not create then
|
1249
|
+
module_instance.module_class.module_type = module_type
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
context 'with valid #module_type' do
|
1253
|
+
let(:module_type) do
|
1254
|
+
FactoryGirl.generate :metasploit_model_module_type
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
it 'should call allows? on class' do
|
1258
|
+
# memoize module_instance first so it's calls to allows? do not trigger the should_receive
|
1259
|
+
module_instance
|
1260
|
+
|
1261
|
+
base_class.should_receive(:allows?).with(
|
1262
|
+
hash_including(
|
1263
|
+
attribute: attribute,
|
1264
|
+
module_type: module_type
|
1265
|
+
)
|
1266
|
+
)
|
1267
|
+
|
1268
|
+
allows?
|
1269
|
+
end
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
context 'without valid #module_type' do
|
1273
|
+
let(:module_type) do
|
1274
|
+
'invalid_module_type'
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
it { should be_false }
|
1278
|
+
end
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
context '#dynamic_length_validation_options' do
|
1282
|
+
subject(:dynamic_length_validation_options) do
|
1283
|
+
module_instance.dynamic_length_validation_options(attribute)
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
let(:attribute) do
|
1287
|
+
attributes.sample
|
1288
|
+
end
|
1289
|
+
|
1290
|
+
let(:attributes) do
|
1291
|
+
[
|
1292
|
+
:actions,
|
1293
|
+
:module_architectures,
|
1294
|
+
:module_platforms,
|
1295
|
+
:module_references,
|
1296
|
+
:targets
|
1297
|
+
]
|
1298
|
+
end
|
1299
|
+
|
1300
|
+
before(:each) do
|
1301
|
+
# can't be set on module_class_factory because module_class would fail to create then.
|
1302
|
+
module_instance.module_class.module_type = module_type
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
context 'with valid #module_type' do
|
1306
|
+
let(:module_type) do
|
1307
|
+
FactoryGirl.generate :metasploit_model_module_type
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
it 'should call dynamic_length_validation_options on class' do
|
1311
|
+
base_class.should_receive(:dynamic_length_validation_options).with(
|
1312
|
+
hash_including(
|
1313
|
+
attribute: attribute,
|
1314
|
+
module_type: module_type
|
1315
|
+
)
|
1316
|
+
)
|
1317
|
+
|
1318
|
+
dynamic_length_validation_options
|
1319
|
+
end
|
1320
|
+
end
|
1321
|
+
|
1322
|
+
context 'without valid #module_type' do
|
1323
|
+
let(:module_type) do
|
1324
|
+
'invalid_module_type'
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
it { should == {} }
|
1328
|
+
end
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
context '#module_type' do
|
1332
|
+
subject(:module_type) do
|
1333
|
+
module_instance.module_type
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
context 'with #module_class' do
|
1337
|
+
it 'should delegate to #module_type on #module_class' do
|
1338
|
+
expected_module_type = double('Expected #module_type')
|
1339
|
+
module_instance.module_class.should_receive(:module_type).and_return(expected_module_type)
|
1340
|
+
|
1341
|
+
module_type.should == expected_module_type
|
1342
|
+
end
|
1343
|
+
end
|
1344
|
+
|
1345
|
+
context 'without #module_class' do
|
1346
|
+
before(:each) do
|
1347
|
+
module_instance.module_class = nil
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
it { should be_nil }
|
1351
|
+
end
|
1352
|
+
end
|
1353
|
+
|
1354
|
+
context '#stanced?' do
|
1355
|
+
subject(:stanced?) do
|
1356
|
+
module_instance.stanced?
|
1357
|
+
end
|
1358
|
+
|
1359
|
+
before(:each) do
|
1360
|
+
# can't set module_type on module_class factory because it won't pass validations then
|
1361
|
+
module_instance.module_class.module_type = module_type
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
context 'with valid #module_type' do
|
1365
|
+
let(:module_type) do
|
1366
|
+
FactoryGirl.generate :metasploit_model_module_type
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
it 'should call stanced? on class' do
|
1370
|
+
base_class.should_receive(:stanced?).with(module_type)
|
1371
|
+
|
1372
|
+
stanced?
|
1373
|
+
end
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
context 'without valid #module_type' do
|
1377
|
+
let(:module_type) do
|
1378
|
+
'invalid_module_type'
|
1379
|
+
end
|
1380
|
+
|
1381
|
+
it { should be_false }
|
1382
|
+
end
|
1383
|
+
end
|
1384
|
+
end
|