arachni 1.2.1 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -0
- data/Gemfile +1 -1
- data/README.md +16 -5
- data/components/checks/active/ldap_injection/errors.txt +1 -0
- data/components/checks/active/source_code_disclosure.rb +1 -1
- data/components/checks/active/unvalidated_redirect.rb +6 -6
- data/components/checks/active/unvalidated_redirect_dom.rb +10 -7
- data/components/checks/passive/grep/captcha.rb +14 -5
- data/components/checks/passive/grep/form_upload.rb +7 -3
- data/components/checks/passive/grep/hsts.rb +3 -3
- data/components/checks/passive/grep/html_objects.rb +2 -3
- data/components/checks/passive/grep/http_only_cookies.rb +2 -3
- data/components/checks/passive/grep/insecure_cookies.rb +1 -1
- data/components/checks/passive/grep/password_autocomplete.rb +2 -2
- data/components/checks/passive/grep/unencrypted_password_forms.rb +7 -7
- data/components/checks/passive/grep/x_frame_options.rb +2 -2
- data/components/checks/passive/http_put.rb +2 -3
- data/components/path_extractors/comments.rb +3 -3
- data/components/path_extractors/scripts.rb +10 -1
- data/components/plugins/defaults/autothrottle.rb +27 -18
- data/components/plugins/defaults/meta/remedies/discovery.rb +30 -33
- data/components/plugins/defaults/meta/remedies/timing_attacks.rb +7 -11
- data/components/plugins/login_script.rb +9 -3
- data/components/plugins/proxy.rb +4 -3
- data/components/reporters/html.rb +11 -14
- data/components/reporters/html/default/issue.erb +13 -38
- data/components/reporters/html/default/issue/info.erb +1 -1
- data/components/reporters/html/default/summary/issues/by_name.erb +3 -3
- data/components/reporters/stdout.rb +62 -71
- data/components/reporters/xml.rb +26 -40
- data/components/reporters/xml/schema.xsd +43 -89
- data/lib/arachni/browser.rb +52 -3
- data/lib/arachni/browser/javascript.rb +3 -3
- data/lib/arachni/browser/javascript/scripts/taint_tracer.js +46 -25
- data/lib/arachni/browser_cluster.rb +61 -0
- data/lib/arachni/browser_cluster/job.rb +21 -1
- data/lib/arachni/browser_cluster/jobs/browser_provider.rb +3 -1
- data/lib/arachni/browser_cluster/jobs/resource_exploration.rb +2 -1
- data/lib/arachni/browser_cluster/jobs/resource_exploration/event_trigger.rb +2 -1
- data/lib/arachni/browser_cluster/jobs/taint_trace.rb +3 -2
- data/lib/arachni/browser_cluster/jobs/taint_trace/event_trigger.rb +1 -1
- data/lib/arachni/browser_cluster/worker.rb +5 -0
- data/lib/arachni/check/auditor.rb +22 -12
- data/lib/arachni/data/framework.rb +13 -1
- data/lib/arachni/data/issues.rb +9 -25
- data/lib/arachni/element/base.rb +9 -3
- data/lib/arachni/element/capabilities/analyzable.rb +2 -6
- data/lib/arachni/element/capabilities/analyzable/differential.rb +24 -7
- data/lib/arachni/element/capabilities/analyzable/{taint.rb → signature.rb} +23 -23
- data/lib/arachni/element/capabilities/auditable.rb +0 -6
- data/lib/arachni/element/capabilities/dom_only.rb +61 -0
- data/lib/arachni/element/capabilities/with_dom.rb +3 -1
- data/lib/arachni/element/cookie.rb +35 -5
- data/lib/arachni/element/cookie/dom.rb +13 -4
- data/lib/arachni/element/{capabilities/auditable/dom.rb → dom.rb} +20 -68
- data/lib/arachni/element/dom/capabilities/auditable.rb +29 -0
- data/lib/arachni/element/dom/capabilities/inputtable.rb +27 -0
- data/lib/arachni/element/dom/capabilities/mutable.rb +21 -0
- data/lib/arachni/element/dom/capabilities/submittable.rb +52 -0
- data/lib/arachni/element/form.rb +12 -1
- data/lib/arachni/element/form/capabilities/mutable.rb +2 -1
- data/lib/arachni/element/form/capabilities/with_dom.rb +0 -1
- data/lib/arachni/element/form/dom.rb +9 -3
- data/lib/arachni/element/header.rb +14 -33
- data/lib/arachni/element/header/capabilities/inputtable.rb +29 -0
- data/lib/arachni/element/header/capabilities/mutable.rb +51 -0
- data/lib/arachni/element/input/dom.rb +71 -0
- data/lib/arachni/element/json.rb +2 -0
- data/lib/arachni/element/link.rb +3 -0
- data/lib/arachni/element/link/capabilities/with_dom.rb +0 -1
- data/lib/arachni/element/link/dom.rb +16 -3
- data/lib/arachni/element/link/dom/capabilities/submittable.rb +29 -0
- data/lib/arachni/element/link_template.rb +3 -5
- data/lib/arachni/element/link_template/capabilities/inputtable.rb +5 -0
- data/lib/arachni/element/link_template/capabilities/with_dom.rb +0 -1
- data/lib/arachni/element/link_template/dom.rb +16 -3
- data/lib/arachni/element/link_template/dom/capabilities/submittable.rb +29 -0
- data/lib/arachni/element/server.rb +3 -5
- data/lib/arachni/element/ui_form.rb +106 -0
- data/lib/arachni/element/ui_form/dom.rb +107 -0
- data/lib/arachni/element/ui_input.rb +62 -0
- data/lib/arachni/element/xml.rb +2 -1
- data/lib/arachni/framework.rb +7 -5
- data/lib/arachni/framework/parts/audit.rb +0 -1
- data/lib/arachni/framework/parts/check.rb +1 -0
- data/lib/arachni/framework/parts/data.rb +4 -0
- data/lib/arachni/framework/parts/state.rb +0 -2
- data/lib/arachni/http/client.rb +17 -6
- data/lib/arachni/http/proxy_server.rb +52 -5
- data/lib/arachni/http/request.rb +1 -1
- data/lib/arachni/issue.rb +34 -179
- data/lib/arachni/issue/severity.rb +2 -0
- data/lib/arachni/option_groups/audit.rb +22 -2
- data/lib/arachni/option_groups/browser_cluster.rb +15 -0
- data/lib/arachni/page.rb +3 -2
- data/lib/arachni/parser.rb +24 -5
- data/lib/arachni/platform/manager.rb +1 -2
- data/lib/arachni/rpc/server/framework.rb +3 -4
- data/lib/arachni/rpc/server/framework/multi_instance.rb +2 -1
- data/lib/arachni/session.rb +1 -1
- data/lib/arachni/trainer.rb +4 -7
- data/lib/arachni/watir/element.rb +12 -1
- data/lib/version +1 -1
- data/spec/arachni/browser/element_locator_spec.rb +43 -43
- data/spec/arachni/browser/javascript/dom_monitor_spec.rb +44 -44
- data/spec/arachni/browser/javascript/proxy/stub_spec.rb +17 -14
- data/spec/arachni/browser/javascript/proxy_spec.rb +24 -24
- data/spec/arachni/browser/javascript/taint_tracer/frame/called_function_spec.rb +11 -11
- data/spec/arachni/browser/javascript/taint_tracer/frame_spec.rb +7 -7
- data/spec/arachni/browser/javascript/taint_tracer/sink/data_flow_spec.rb +13 -13
- data/spec/arachni/browser/javascript/taint_tracer/sink/execution_flow_spec.rb +7 -7
- data/spec/arachni/browser/javascript/taint_tracer_spec.rb +568 -558
- data/spec/arachni/browser/javascript_spec.rb +73 -63
- data/spec/arachni/browser_cluster/job/result_spec.rb +3 -3
- data/spec/arachni/browser_cluster/job_spec.rb +68 -48
- data/spec/arachni/browser_cluster/jobs/resource_exploration/event_trigger/result_spec.rb +2 -2
- data/spec/arachni/browser_cluster/jobs/resource_exploration/event_trigger_spec.rb +5 -4
- data/spec/arachni/browser_cluster/jobs/resource_exploration/result_spec.rb +2 -2
- data/spec/arachni/browser_cluster/jobs/resource_exploration_spec.rb +5 -5
- data/spec/arachni/browser_cluster/worker_spec.rb +87 -70
- data/spec/arachni/browser_cluster_spec.rb +64 -39
- data/spec/arachni/browser_spec.rb +692 -527
- data/spec/arachni/check/auditor_spec.rb +177 -147
- data/spec/arachni/check/base_spec.rb +33 -33
- data/spec/arachni/check/manager_spec.rb +15 -15
- data/spec/arachni/component/base_spec.rb +8 -8
- data/spec/arachni/component/manager_spec.rb +100 -99
- data/spec/arachni/component/options/address_spec.rb +3 -3
- data/spec/arachni/component/options/base_spec.rb +7 -7
- data/spec/arachni/component/options/bool_spec.rb +9 -9
- data/spec/arachni/component/options/float_spec.rb +6 -6
- data/spec/arachni/component/options/int_spec.rb +5 -5
- data/spec/arachni/component/options/multiple_choice_spec.rb +12 -12
- data/spec/arachni/component/options/object_spec.rb +2 -2
- data/spec/arachni/component/options/path_spec.rb +3 -3
- data/spec/arachni/component/options/port_spec.rb +5 -5
- data/spec/arachni/component/options/string_spec.rb +3 -3
- data/spec/arachni/component/options/url_spec.rb +4 -4
- data/spec/arachni/component/utilities_spec.rb +2 -2
- data/spec/arachni/data/framework/rpc_spec.rb +10 -9
- data/spec/arachni/data/framework_spec.rb +65 -46
- data/spec/arachni/data/issues_spec.rb +39 -77
- data/spec/arachni/data/plugins_spec.rb +11 -11
- data/spec/arachni/data/session_spec.rb +6 -6
- data/spec/arachni/data_spec.rb +8 -8
- data/spec/arachni/element/body_spec.rb +10 -10
- data/spec/arachni/element/capabilities/analyzable/differential_spec.rb +39 -21
- data/spec/arachni/element/capabilities/analyzable/{taint_spec.rb → signature_spec.rb} +63 -63
- data/spec/arachni/element/capabilities/analyzable/timeout_spec.rb +51 -51
- data/spec/arachni/element/capabilities/with_scope/scope_spec.rb +5 -5
- data/spec/arachni/element/cookie/dom_spec.rb +37 -18
- data/spec/arachni/element/cookie_spec.rb +206 -139
- data/spec/arachni/element/form/dom_spec.rb +36 -19
- data/spec/arachni/element/form_spec.rb +210 -187
- data/spec/arachni/element/generic_dom_spec.rb +14 -14
- data/spec/arachni/element/header_spec.rb +35 -17
- data/spec/arachni/element/json_spec.rb +53 -31
- data/spec/arachni/element/link/dom_spec.rb +46 -28
- data/spec/arachni/element/link_spec.rb +58 -40
- data/spec/arachni/element/link_template/dom_spec.rb +47 -29
- data/spec/arachni/element/link_template_spec.rb +79 -61
- data/spec/arachni/element/path_spec.rb +1 -1
- data/spec/arachni/element/server_spec.rb +33 -32
- data/spec/arachni/element/ui_form/ui_form_dom_spec.rb +164 -0
- data/spec/arachni/element/ui_form_spec.rb +242 -0
- data/spec/arachni/element/ui_input/dom_spec.rb +157 -0
- data/spec/arachni/element/ui_input_spec.rb +136 -0
- data/spec/arachni/element/xml_spec.rb +42 -24
- data/spec/arachni/element_filter_spec.rb +49 -48
- data/spec/arachni/error_spec.rb +3 -3
- data/spec/arachni/framework/parts/audit_spec.rb +64 -63
- data/spec/arachni/framework/parts/browser_spec.rb +16 -16
- data/spec/arachni/framework/parts/check_spec.rb +3 -3
- data/spec/arachni/framework/parts/data_spec.rb +48 -48
- data/spec/arachni/framework/parts/platform_spec.rb +3 -3
- data/spec/arachni/framework/parts/plugin_spec.rb +7 -6
- data/spec/arachni/framework/parts/report_spec.rb +7 -7
- data/spec/arachni/framework/parts/scope_spec.rb +16 -16
- data/spec/arachni/framework/parts/state_spec.rb +68 -69
- data/spec/arachni/framework_spec.rb +39 -31
- data/spec/arachni/http/client/dynamic_404_handlers_spec.rb +32 -32
- data/spec/arachni/http/client_spec.rb +219 -208
- data/spec/arachni/http/cookie_jar_spec.rb +72 -72
- data/spec/arachni/http/headers_spec.rb +14 -14
- data/spec/arachni/http/proxy_server_spec.rb +43 -42
- data/spec/arachni/http/request_spec.rb +105 -103
- data/spec/arachni/http/response/scope_spec.rb +24 -24
- data/spec/arachni/http/response_spec.rb +50 -49
- data/spec/arachni/issue/severity_spec.rb +10 -9
- data/spec/arachni/issue_spec.rb +71 -369
- data/spec/arachni/option_groups/audit_spec.rb +114 -114
- data/spec/arachni/option_groups/browser_cluster_spec.rb +20 -3
- data/spec/arachni/option_groups/datastore_spec.rb +6 -6
- data/spec/arachni/option_groups/dispatcher_spec.rb +19 -19
- data/spec/arachni/option_groups/http_spec.rb +11 -11
- data/spec/arachni/option_groups/input_spec.rb +31 -27
- data/spec/arachni/option_groups/output_spec.rb +2 -2
- data/spec/arachni/option_groups/paths_spec.rb +17 -17
- data/spec/arachni/option_groups/rpc_spec.rb +2 -2
- data/spec/arachni/option_groups/scope_spec.rb +40 -40
- data/spec/arachni/option_groups/session_spec.rb +6 -5
- data/spec/arachni/option_groups/snapshot_spec.rb +4 -4
- data/spec/arachni/options_spec.rb +46 -45
- data/spec/arachni/page/dom/transition_spec.rb +74 -72
- data/spec/arachni/page/dom_spec.rb +35 -35
- data/spec/arachni/page/scope_spec.rb +15 -15
- data/spec/arachni/page_spec.rb +217 -217
- data/spec/arachni/parser_spec.rb +106 -104
- data/spec/arachni/platform/fingerprinter_spec.rb +17 -14
- data/spec/arachni/platform/list_spec.rb +33 -33
- data/spec/arachni/platform/manager_spec.rb +67 -64
- data/spec/arachni/plugin/base_spec.rb +10 -10
- data/spec/arachni/plugin/manager_spec.rb +38 -37
- data/spec/arachni/report_spec.rb +43 -40
- data/spec/arachni/reporter/base_spec.rb +15 -15
- data/spec/arachni/reporter/manager_spec.rb +4 -4
- data/spec/arachni/reporter/options_spec.rb +6 -6
- data/spec/arachni/rpc/client/base_spec.rb +6 -6
- data/spec/arachni/rpc/client/dispatcher_spec.rb +2 -2
- data/spec/arachni/rpc/client/instance_spec.rb +6 -6
- data/spec/arachni/rpc/server/active_options_spec.rb +11 -8
- data/spec/arachni/rpc/server/base_spec.rb +5 -5
- data/spec/arachni/rpc/server/checks/manager_spec.rb +8 -8
- data/spec/arachni/rpc/server/dispatcher/node_spec.rb +37 -37
- data/spec/arachni/rpc/server/dispatcher/service_spec.rb +15 -14
- data/spec/arachni/rpc/server/dispatcher_spec.rb +36 -35
- data/spec/arachni/rpc/server/framework/distributor_spec.rb +36 -36
- data/spec/arachni/rpc/server/framework_multi_spec.rb +340 -336
- data/spec/arachni/rpc/server/framework_spec.rb +90 -85
- data/spec/arachni/rpc/server/instance_spec.rb +126 -107
- data/spec/arachni/rpc/server/output_spec.rb +1 -1
- data/spec/arachni/rpc/server/plugin/manager_spec.rb +6 -6
- data/spec/arachni/ruby/array_spec.rb +42 -42
- data/spec/arachni/ruby/hash_spec.rb +20 -18
- data/spec/arachni/ruby/io_spec.rb +2 -2
- data/spec/arachni/ruby/object_spec.rb +1 -1
- data/spec/arachni/ruby/set_spec.rb +3 -3
- data/spec/arachni/ruby/string_spec.rb +30 -30
- data/spec/arachni/ruby/webrick_spec.rb +2 -2
- data/spec/arachni/scope_spec.rb +1 -1
- data/spec/arachni/session_spec.rb +67 -64
- data/spec/arachni/snapshot_spec.rb +15 -15
- data/spec/arachni/state/audit_spec.rb +11 -11
- data/spec/arachni/state/element_filter_spec.rb +6 -6
- data/spec/arachni/state/framework/rpc_spec.rb +12 -12
- data/spec/arachni/state/framework_spec.rb +125 -121
- data/spec/arachni/state/http_spec.rb +7 -7
- data/spec/arachni/state/options_spec.rb +7 -7
- data/spec/arachni/state/plugins_spec.rb +8 -8
- data/spec/arachni/state_spec.rb +10 -10
- data/spec/arachni/support/buffer/autoflush_spec.rb +16 -16
- data/spec/arachni/support/buffer/base_spec.rb +39 -39
- data/spec/arachni/support/cache/least_cost_replacement_spec.rb +18 -18
- data/spec/arachni/support/cache/least_recently_pushed_spec.rb +24 -24
- data/spec/arachni/support/cache/least_recently_used_spec.rb +20 -20
- data/spec/arachni/support/cache/preference_spec.rb +4 -4
- data/spec/arachni/support/cache/random_replacement_spec.rb +8 -8
- data/spec/arachni/support/crypto/rsa_aes_cbc_spec.rb +1 -1
- data/spec/arachni/support/database/hash_spec.rb +44 -43
- data/spec/arachni/support/database/queue_spec.rb +27 -27
- data/spec/arachni/support/lookup/hash_set_spec.rb +8 -8
- data/spec/arachni/support/lookup/moolb_spec.rb +3 -3
- data/spec/arachni/support/mixins/observable_spec.rb +6 -6
- data/spec/arachni/support/signature_spec.rb +19 -19
- data/spec/arachni/trainer_spec.rb +39 -39
- data/spec/arachni/typhoeus/hydra_spec.rb +2 -2
- data/spec/arachni/uri/scope_spec.rb +66 -66
- data/spec/arachni/uri_spec.rb +107 -105
- data/spec/arachni/utilities_spec.rb +40 -40
- data/spec/components/checks/active/csrf_spec.rb +8 -8
- data/spec/components/checks/active/no_sql_injection_spec.rb +1 -1
- data/spec/components/checks/active/sql_injection_spec.rb +16 -16
- data/spec/components/checks/active/trainer_spec.rb +4 -4
- data/spec/components/checks/active/unvalidated_redirect_dom_spec.rb +4 -2
- data/spec/components/checks/active/xpath_injection_spec.rb +1 -1
- data/spec/components/checks/active/xss_dom_script_context_spec.rb +51 -21
- data/spec/components/checks/active/xss_dom_spec.rb +46 -24
- data/spec/components/checks/passive/allowed_methods_spec.rb +1 -1
- data/spec/components/checks/passive/grep/cookie_set_for_parent_domain_spec.rb +1 -1
- data/spec/components/checks/passive/grep/hsts_spec.rb +2 -2
- data/spec/components/checks/passive/grep/http_only_cookies_spec.rb +1 -1
- data/spec/components/checks/passive/grep/insecure_cookies_spec.rb +1 -1
- data/spec/components/checks/passive/grep/insecure_cors_policy_spec.rb +2 -2
- data/spec/components/checks/passive/grep/password_autocomplete_spec.rb +1 -1
- data/spec/components/checks/passive/grep/private_ip_spec.rb +3 -3
- data/spec/components/checks/passive/grep/unencrypted_password_forms_spec.rb +1 -1
- data/spec/components/checks/passive/grep/x_frame_options_spec.rb +2 -2
- data/spec/components/checks/passive/interesting_responses_spec.rb +2 -2
- data/spec/components/checks/passive/webdav_spec.rb +1 -1
- data/spec/components/checks/passive/xst_spec.rb +1 -1
- data/spec/components/fingerprinters/servers/apache_spec.rb +2 -2
- data/spec/components/path_extractors/comments_spec.rb +5 -1
- data/spec/components/path_extractors/scripts_spec.rb +5 -2
- data/spec/components/plugins/autologin_spec.rb +22 -22
- data/spec/components/plugins/autothrottle_spec.rb +6 -5
- data/spec/components/plugins/content_types_spec.rb +4 -4
- data/spec/components/plugins/cookie_collector_spec.rb +5 -5
- data/spec/components/plugins/exec_spec.rb +12 -12
- data/spec/components/plugins/form_dicattack_spec.rb +3 -3
- data/spec/components/plugins/headers_collector_spec.rb +8 -8
- data/spec/components/plugins/healthmap_spec.rb +3 -3
- data/spec/components/plugins/http_dicattack_spec.rb +3 -3
- data/spec/components/plugins/login_script_spec.rb +79 -22
- data/spec/components/plugins/meta/remedies/discovery_spec.rb +3 -2
- data/spec/components/plugins/meta/remedies/timing_attacks_spec.rb +3 -3
- data/spec/components/plugins/meta/uniformity_spec.rb +2 -2
- data/spec/components/plugins/restrict_to_dom_state_spec.rb +1 -1
- data/spec/components/plugins/script_spec.rb +1 -1
- data/spec/components/plugins/uncommon_headers_spec.rb +2 -2
- data/spec/components/plugins/vector_collector_spec.rb +2 -2
- data/spec/components/plugins/vector_feed_spec.rb +40 -40
- data/spec/components/plugins/waf_detector_spec.rb +6 -6
- data/spec/components/reporters/json_spec.rb +4 -4
- data/spec/components/reporters/marshal_spec.rb +2 -2
- data/spec/components/reporters/yaml_spec.rb +3 -2
- data/spec/external/wavsep/active/sqli_spec.rb +1 -3
- data/spec/spec_helper.rb +4 -0
- data/spec/support/factories/element/ui_form.rb +14 -0
- data/spec/support/factories/element/ui_input.rb +13 -0
- data/spec/support/factories/issue.rb +0 -13
- data/spec/support/fixtures/report.afr +0 -0
- data/spec/support/fixtures/{taint_check/taint.rb → signature_check/signature.rb} +2 -2
- data/spec/support/helpers/browser_cluster/jobs/taint_tracer.rb +11 -11
- data/spec/support/helpers/framework.rb +1 -1
- data/spec/support/helpers/pages.rb +2 -2
- data/spec/support/servers/arachni/browser.rb +139 -0
- data/spec/support/servers/arachni/browser/javascript/taint_tracer.rb +40 -0
- data/spec/support/servers/arachni/element/capabilities/analyzable/{taint.rb → signature.rb} +0 -0
- data/spec/support/servers/arachni/element/input/input_dom.rb +102 -0
- data/spec/support/servers/arachni/element/ui_form/ui_form_dom.rb +238 -0
- data/spec/support/servers/checks/active/trainer_check.rb +7 -7
- data/spec/support/servers/checks/active/unvalidated_redirect_dom.rb +22 -6
- data/spec/support/servers/checks/active/xss_dom.rb +50 -0
- data/spec/support/servers/checks/active/xss_dom_script_context.rb +53 -0
- data/spec/support/shared/browser/javascript/taint_tracer/sink/base.rb +6 -6
- data/spec/support/shared/check.rb +10 -12
- data/spec/support/shared/component/options/base.rb +24 -24
- data/spec/support/shared/element/base.rb +25 -25
- data/spec/support/shared/element/capabilities/auditable.rb +116 -140
- data/spec/support/shared/element/capabilities/dom_only.rb +65 -0
- data/spec/support/shared/element/capabilities/inputtable.rb +71 -86
- data/spec/support/shared/element/capabilities/mutable.rb +122 -111
- data/spec/support/shared/element/capabilities/refreshable.rb +10 -10
- data/spec/support/shared/element/capabilities/{submitable.rb → submittable.rb} +26 -26
- data/spec/support/shared/element/capabilities/with_auditor.rb +10 -10
- data/spec/support/shared/element/capabilities/with_dom.rb +8 -8
- data/spec/support/shared/element/capabilities/with_node.rb +4 -6
- data/spec/support/shared/element/capabilities/with_scope.rb +2 -2
- data/spec/support/shared/element/capabilities/with_source.rb +6 -8
- data/spec/support/shared/element/dom.rb +144 -0
- data/spec/support/shared/element/dom/auditable.rb +42 -0
- data/spec/support/shared/element/dom/inputtable.rb +5 -0
- data/spec/support/shared/element/dom/mutable.rb +3 -0
- data/spec/support/shared/element/dom/submittable.rb +119 -0
- data/spec/support/shared/external/wavsep.rb +3 -3
- data/spec/support/shared/fingerprinter.rb +2 -2
- data/spec/support/shared/framework.rb +1 -1
- data/spec/support/shared/http/message.rb +9 -9
- data/spec/support/shared/option_group.rb +17 -17
- data/spec/support/shared/path_extractor.rb +1 -1
- data/spec/support/shared/plugin.rb +2 -2
- data/spec/support/shared/support/cache.rb +57 -57
- data/spec/support/shared/support/lookup.rb +25 -25
- data/ui/cli/framework.rb +22 -11
- data/ui/cli/framework/option_parser.rb +15 -0
- data/ui/cli/option_parser.rb +8 -1
- data/ui/cli/output.rb +2 -1
- metadata +54 -20
- data/components/checks/active/xss_dom_inputs.rb +0 -236
- data/spec/components/checks/active/xss_dom_inputs_spec.rb +0 -30
- data/spec/support/servers/checks/active/xss_dom_inputs.rb +0 -59
- data/spec/support/shared/element/capabilities/auditable/dom.rb +0 -322
@@ -0,0 +1,42 @@
|
|
1
|
+
shared_examples_for 'auditable_dom' do
|
2
|
+
it_should_behave_like 'auditable'
|
3
|
+
|
4
|
+
describe '#with_browser_cluster' do
|
5
|
+
context 'when a browser cluster is' do
|
6
|
+
context 'available' do
|
7
|
+
it 'passes a BrowserCluster to the given block' do
|
8
|
+
worker = nil
|
9
|
+
|
10
|
+
subject.with_browser_cluster do |cluster|
|
11
|
+
worker = cluster
|
12
|
+
end
|
13
|
+
|
14
|
+
expect(worker).to eq(subject.auditor.browser_cluster)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#with_browser' do
|
21
|
+
context 'when a browser cluster is' do
|
22
|
+
context 'available' do
|
23
|
+
it 'passes a BrowserCluster::Worker to the given block' do
|
24
|
+
worker = nil
|
25
|
+
|
26
|
+
expect(subject.with_browser do |browser|
|
27
|
+
worker = browser
|
28
|
+
end).to be_truthy
|
29
|
+
subject.auditor.browser_cluster.wait
|
30
|
+
|
31
|
+
expect(worker).to be_kind_of Arachni::BrowserCluster::Worker
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#auditor' do
|
38
|
+
it 'returns the assigned auditor' do
|
39
|
+
expect(subject.auditor).to be_kind_of Arachni::Check::Auditor
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
shared_examples_for 'submittable_dom' do
|
2
|
+
it_should_behave_like 'submittable'
|
3
|
+
|
4
|
+
describe '#submit' do
|
5
|
+
it 'submits the element' do
|
6
|
+
inputs = { subject.inputs.keys.first => subject.inputs.values.first + '1' }
|
7
|
+
subject.inputs = inputs
|
8
|
+
|
9
|
+
called = false
|
10
|
+
subject.submit do |page|
|
11
|
+
expect(inputs).to eq(auditable_extract_parameters( page ))
|
12
|
+
called = true
|
13
|
+
end
|
14
|
+
|
15
|
+
subject.auditor.browser_cluster.wait
|
16
|
+
expect(called).to be_truthy
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'sets the #performer on the returned page' do
|
20
|
+
called = false
|
21
|
+
subject.submit do |page|
|
22
|
+
expect(page.performer).to be_kind_of described_class
|
23
|
+
called = true
|
24
|
+
end
|
25
|
+
|
26
|
+
subject.auditor.browser_cluster.wait
|
27
|
+
expect(called).to be_truthy
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sets the #browser on the #performer' do
|
31
|
+
called = false
|
32
|
+
subject.submit do |page|
|
33
|
+
expect(page.performer.browser).to be_kind_of Arachni::BrowserCluster::Worker
|
34
|
+
called = true
|
35
|
+
end
|
36
|
+
|
37
|
+
subject.auditor.browser_cluster.wait
|
38
|
+
expect(called).to be_truthy
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'sets the #element on the #performer',
|
42
|
+
if: described_class.ancestors.include?( Arachni::Element::Capabilities::WithNode ) do
|
43
|
+
|
44
|
+
called = false
|
45
|
+
subject.submit do |page|
|
46
|
+
expect(page.performer.element).to be_kind_of Watir::HTMLElement
|
47
|
+
called = true
|
48
|
+
end
|
49
|
+
|
50
|
+
subject.auditor.browser_cluster.wait
|
51
|
+
expect(called).to be_truthy
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'adds the submission transitions to the Page::DOM#transitions' do
|
55
|
+
transitions = []
|
56
|
+
subject.with_browser do |browser|
|
57
|
+
subject.browser = browser
|
58
|
+
browser.load subject.page
|
59
|
+
transitions = subject.trigger
|
60
|
+
end
|
61
|
+
subject.auditor.browser_cluster.wait
|
62
|
+
|
63
|
+
submitted_page = nil
|
64
|
+
subject.dup.submit do |page|
|
65
|
+
submitted_page = page
|
66
|
+
end
|
67
|
+
subject.auditor.browser_cluster.wait
|
68
|
+
|
69
|
+
transitions.each do |transition|
|
70
|
+
expect(subject.page.dom.transitions).not_to include transition
|
71
|
+
expect(submitted_page.dom.transitions).to include transition
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when the element could not be submitted' do
|
76
|
+
it 'does not call the block' do
|
77
|
+
allow(subject).to receive( :trigger ) { false }
|
78
|
+
|
79
|
+
called = false
|
80
|
+
subject.submit do
|
81
|
+
called = true
|
82
|
+
end
|
83
|
+
subject.auditor.browser_cluster.wait
|
84
|
+
expect(called).to be_falsey
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe :options do
|
89
|
+
describe :custom_code do
|
90
|
+
it 'injects the given code' do
|
91
|
+
called = false
|
92
|
+
title = 'Injected title'
|
93
|
+
|
94
|
+
subject.submit custom_code: "document.title = #{title.inspect}" do |page|
|
95
|
+
expect(page.document.css('title').text).to eq(title)
|
96
|
+
called = true
|
97
|
+
end
|
98
|
+
|
99
|
+
subject.auditor.browser_cluster.wait
|
100
|
+
expect(called).to be_truthy
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe :taint do
|
105
|
+
it 'sets the Browser::Javascript#taint' do
|
106
|
+
taint = Arachni::Utilities.generate_token
|
107
|
+
|
108
|
+
set_taint = nil
|
109
|
+
subject.submit taint: taint do |page|
|
110
|
+
set_taint = page.performer.browser.javascript.taint
|
111
|
+
end
|
112
|
+
|
113
|
+
subject.auditor.browser_cluster.wait
|
114
|
+
expect(set_taint).to eq(taint)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -69,9 +69,9 @@ shared_examples_for 'wavsep' do
|
|
69
69
|
test_cases( http_method ).each do |description, info|
|
70
70
|
context description do
|
71
71
|
it "logs #{(info[:vulnerable] || []).size + (info[:vulnerable_absolute] || []).size} unique resources using #{[info[:checks]].flatten.join( ', ' )}" do
|
72
|
-
|
72
|
+
skip "'WAVSEP_URL' env variable has not been set." if !wavsep_url
|
73
73
|
|
74
|
-
Arachni::Data.issues.
|
74
|
+
expect(Arachni::Data.issues).to be_empty
|
75
75
|
|
76
76
|
if info[:root_url]
|
77
77
|
@framework.options.url = wavsep_url
|
@@ -96,7 +96,7 @@ shared_examples_for 'wavsep' do
|
|
96
96
|
# pp resources.map { |u| u.gsub( @framework.options.url, '' ) }
|
97
97
|
# puts format_error( urls, resources, expected )
|
98
98
|
|
99
|
-
resources.
|
99
|
+
expect(resources).to eq(expected), format_error( urls, resources, expected )
|
100
100
|
|
101
101
|
instance_eval &block if block_given?
|
102
102
|
end
|
@@ -7,13 +7,13 @@ shared_examples_for 'fingerprinter' do
|
|
7
7
|
|
8
8
|
def check_platforms( page )
|
9
9
|
platforms.each do |p|
|
10
|
-
platforms_for( page ).
|
10
|
+
expect(platforms_for( page )).to include p
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def platforms_for( page )
|
15
15
|
Arachni::Platform::Manager.reset
|
16
|
-
page.platforms.
|
16
|
+
expect(page.platforms).to be_empty
|
17
17
|
|
18
18
|
described_class.new( page ).run
|
19
19
|
page.platforms
|
@@ -10,7 +10,7 @@ shared_examples_for 'framework' do
|
|
10
10
|
before( :each ) do
|
11
11
|
reset_options
|
12
12
|
@options.paths.reporters = fixtures_path + '/reporters/manager_spec/'
|
13
|
-
@options.paths.checks = fixtures_path + '/
|
13
|
+
@options.paths.checks = fixtures_path + '/signature_check/'
|
14
14
|
|
15
15
|
@f = Arachni::Framework.new
|
16
16
|
@f.options.url = @url
|
@@ -12,25 +12,25 @@ shared_examples_for 'Arachni::HTTP::Message' do
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
r = described_class.new(options)
|
15
|
-
r.headers.
|
15
|
+
expect(r.headers).to eq(options[:headers])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#scope' do
|
20
20
|
it "returns #{described_class::Scope}" do
|
21
|
-
subject.scope.
|
21
|
+
expect(subject.scope).to be_kind_of described_class::Scope
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#url=' do
|
26
26
|
it 'sets the #url' do
|
27
27
|
subject.url = "#{url}/2"
|
28
|
-
subject.url.
|
28
|
+
expect(subject.url).to eq("#{url}/2")
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'forces it to a string' do
|
32
32
|
subject.url = nil
|
33
|
-
subject.url.
|
33
|
+
expect(subject.url).to eq('')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'it freezes it' do
|
@@ -38,34 +38,34 @@ shared_examples_for 'Arachni::HTTP::Message' do
|
|
38
38
|
|
39
39
|
r = described_class.new( url: url )
|
40
40
|
r.url = url
|
41
|
-
r.url.
|
41
|
+
expect(r.url).to be_frozen
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'normalizes it' do
|
45
45
|
url = 'HttP://Stuff.Com/'
|
46
46
|
r = described_class.new( url: url )
|
47
47
|
r.url = url
|
48
|
-
r.url.
|
48
|
+
expect(r.url).to eq(url.downcase)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#headers' do
|
53
53
|
context 'when not configured' do
|
54
54
|
it 'defaults to an empty Hash' do
|
55
|
-
subject.headers.
|
55
|
+
expect(subject.headers).to eq({})
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns the configured value' do
|
60
60
|
headers = { 'Content-Type' => 'text/plain' }
|
61
|
-
described_class.new(url: url, headers: headers).headers.
|
61
|
+
expect(described_class.new(url: url, headers: headers).headers).to eq(headers)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe '#body' do
|
66
66
|
it 'returns the configured body' do
|
67
67
|
body = 'Stuff...'
|
68
|
-
described_class.new(url: url, body: body).body.
|
68
|
+
expect(described_class.new(url: url, body: body).body).to eq(body)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -1,23 +1,23 @@
|
|
1
1
|
shared_examples_for 'option_group' do
|
2
|
-
it {
|
2
|
+
it { is_expected.to respond_to :to_h }
|
3
3
|
|
4
4
|
describe '#to_rpc_data' do
|
5
5
|
let(:data) { subject.to_rpc_data }
|
6
6
|
|
7
7
|
it 'converts self to a serializable hash' do
|
8
|
-
data.
|
8
|
+
expect(data).to be_kind_of Hash
|
9
9
|
|
10
|
-
Arachni::RPC::Serializer.load(
|
10
|
+
expect(Arachni::RPC::Serializer.load(
|
11
11
|
Arachni::RPC::Serializer.dump( data )
|
12
|
-
).
|
12
|
+
)).to eq(data)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
described_class.defaults.each do |k, v|
|
17
17
|
describe "##{k}" do
|
18
18
|
it "defaults to #{v}" do
|
19
|
-
subject.instance_variable_get( "@#{k}".to_sym ).
|
20
|
-
subject.send( k ).
|
19
|
+
expect(subject.instance_variable_get( "@#{k}".to_sym )).to eq(v)
|
20
|
+
expect(subject.send( k )).to eq(v)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -25,35 +25,35 @@ shared_examples_for 'option_group' do
|
|
25
25
|
it 'honors default values for attributes' do
|
26
26
|
subject.defaults.each do |k, v|
|
27
27
|
subject.send "#{k}=", nil
|
28
|
-
subject.instance_variable_get( "@#{k}".to_sym ).
|
29
|
-
subject.send( k ).
|
28
|
+
expect(subject.instance_variable_get( "@#{k}".to_sym )).to eq(v)
|
29
|
+
expect(subject.send( k )).to eq(v)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#to_hash' do
|
34
34
|
it 'returns a hash' do
|
35
|
-
subject.to_hash.
|
35
|
+
expect(subject.to_hash).to be_kind_of Hash
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#to_h' do
|
40
40
|
it 'returns a hash' do
|
41
|
-
subject.to_h.
|
41
|
+
expect(subject.to_h).to be_kind_of Hash
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'only includes attributes with accessors' do
|
45
45
|
method = subject.methods.find { |m| m.to_s.end_with? '=' }
|
46
46
|
if method == :=== || method == :==
|
47
|
-
subject.to_h.
|
47
|
+
expect(subject.to_h).to be_empty
|
48
48
|
next
|
49
49
|
end
|
50
50
|
|
51
51
|
subject.send( method, subject.defaults[method.to_s[0..-1].to_sym] )
|
52
52
|
|
53
53
|
hash = subject.to_h
|
54
|
-
hash.
|
54
|
+
expect(hash).to be_any
|
55
55
|
hash.each do |k, v|
|
56
|
-
subject.
|
56
|
+
expect(subject).to respond_to "#{k}="
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -67,11 +67,11 @@ shared_examples_for 'option_group' do
|
|
67
67
|
value = subject.defaults[method.to_s[0..-1].to_sym]
|
68
68
|
|
69
69
|
subject.update( { method => value } )
|
70
|
-
subject.send( method ).
|
70
|
+
expect(subject.send( method )).to eq(value)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'returns self' do
|
74
|
-
subject.update({}).
|
74
|
+
expect(subject.update({})).to eq(subject)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -87,12 +87,12 @@ shared_examples_for 'option_group' do
|
|
87
87
|
group.update( { method => value } )
|
88
88
|
|
89
89
|
subject.merge( group )
|
90
|
-
subject.send( method ).
|
90
|
+
expect(subject.send( method )).to eq(value)
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'returns self' do
|
94
94
|
group = described_class.new
|
95
|
-
subject.merge( group ).
|
95
|
+
expect(subject.merge( group )).to eq(subject)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -19,7 +19,7 @@ shared_examples_for "path_extractor" do
|
|
19
19
|
it "extracts the expected paths" do
|
20
20
|
raise 'No paths provided via #results, use \':nil\' for \'nil\' results.' if !results
|
21
21
|
|
22
|
-
actual_results.sort.
|
22
|
+
expect(actual_results.sort).to eq results.sort
|
23
23
|
instance_eval &block if block_given?
|
24
24
|
end
|
25
25
|
end
|
@@ -19,12 +19,12 @@ shared_examples_for 'plugin' do
|
|
19
19
|
def results
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.easy_test( &block )
|
22
|
+
def self.easy_test( match = true, &block )
|
23
23
|
it 'logs the expected results' do
|
24
24
|
raise 'No results provided via #results, use \':nil\' for \'nil\' results.' if !results
|
25
25
|
|
26
26
|
run
|
27
|
-
actual_results.
|
27
|
+
expect(actual_results).to eq( expected_results ) if match
|
28
28
|
|
29
29
|
instance_eval &block if block_given?
|
30
30
|
end
|
@@ -7,12 +7,12 @@ shared_examples_for 'cache' do
|
|
7
7
|
describe 'max_size' do
|
8
8
|
describe 'nil' do
|
9
9
|
it 'leaves the cache uncapped' do
|
10
|
-
described_class.new.capped
|
10
|
+
expect(described_class.new.capped?).to be_falsey
|
11
11
|
end
|
12
12
|
end
|
13
13
|
describe Integer do
|
14
14
|
it 'imposes a limit to the size of the cache' do
|
15
|
-
described_class.new( 10 ).capped
|
15
|
+
expect(described_class.new( 10 ).capped?).to be_truthy
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -21,13 +21,13 @@ shared_examples_for 'cache' do
|
|
21
21
|
describe '#max_size' do
|
22
22
|
context 'when just initialized' do
|
23
23
|
it 'returns nil (unlimited)' do
|
24
|
-
subject.max_size.
|
24
|
+
expect(subject.max_size).to be_nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
context 'when set' do
|
28
28
|
it 'returns the set value' do
|
29
|
-
(subject.max_size = 50).
|
30
|
-
subject.max_size.
|
29
|
+
expect(subject.max_size = 50).to eq(50)
|
30
|
+
expect(subject.max_size).to eq(50)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -44,14 +44,14 @@ shared_examples_for 'cache' do
|
|
44
44
|
context 'when the cache has no size limit' do
|
45
45
|
it 'returns false' do
|
46
46
|
subject.uncap
|
47
|
-
subject.capped
|
48
|
-
subject.max_size.
|
47
|
+
expect(subject.capped?).to be_falsey
|
48
|
+
expect(subject.max_size).to be_nil
|
49
49
|
end
|
50
50
|
end
|
51
51
|
context 'when the cache has a size limit' do
|
52
52
|
it 'returns true' do
|
53
53
|
subject.max_size = 1
|
54
|
-
subject.capped
|
54
|
+
expect(subject.capped?).to be_truthy
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -60,15 +60,15 @@ shared_examples_for 'cache' do
|
|
60
60
|
context 'when the cache has no size limit' do
|
61
61
|
it 'returns true' do
|
62
62
|
subject.uncap
|
63
|
-
subject.uncapped
|
64
|
-
subject.max_size.
|
63
|
+
expect(subject.uncapped?).to be_truthy
|
64
|
+
expect(subject.max_size).to be_nil
|
65
65
|
end
|
66
66
|
end
|
67
67
|
context 'when the cache has a size limit' do
|
68
68
|
it 'returns false' do
|
69
69
|
subject.max_size = 1
|
70
|
-
subject.max_size.
|
71
|
-
subject.uncapped
|
70
|
+
expect(subject.max_size).to eq(1)
|
71
|
+
expect(subject.uncapped?).to be_falsey
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -76,19 +76,19 @@ shared_examples_for 'cache' do
|
|
76
76
|
describe '#uncap' do
|
77
77
|
it 'removes the size limit' do
|
78
78
|
subject.max_size = 1
|
79
|
-
subject.uncapped
|
80
|
-
subject.max_size.
|
79
|
+
expect(subject.uncapped?).to be_falsey
|
80
|
+
expect(subject.max_size).to eq(1)
|
81
81
|
|
82
82
|
subject.uncap
|
83
|
-
subject.uncapped
|
84
|
-
subject.max_size.
|
83
|
+
expect(subject.uncapped?).to be_truthy
|
84
|
+
expect(subject.max_size).to be_nil
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe '#max_size=' do
|
89
89
|
it 'sets the maximum size for the cache' do
|
90
|
-
(subject.max_size = 100).
|
91
|
-
subject.max_size.
|
90
|
+
expect(subject.max_size = 100).to eq(100)
|
91
|
+
expect(subject.max_size).to eq(100)
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when passed < 0' do
|
@@ -99,7 +99,7 @@ shared_examples_for 'cache' do
|
|
99
99
|
rescue
|
100
100
|
raised = true
|
101
101
|
end
|
102
|
-
raised.
|
102
|
+
expect(raised).to be_truthy
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -107,14 +107,14 @@ shared_examples_for 'cache' do
|
|
107
107
|
describe '#size' do
|
108
108
|
context 'when the cache is empty' do
|
109
109
|
it 'returns 0' do
|
110
|
-
subject.size.
|
110
|
+
expect(subject.size).to eq(0)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
context 'when the cache is not empty' do
|
115
115
|
it 'returns a value > 0' do
|
116
116
|
subject['stuff'] = [ 'ff ' ]
|
117
|
-
subject.size.
|
117
|
+
expect(subject.size).to be > 0
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -122,13 +122,13 @@ shared_examples_for 'cache' do
|
|
122
122
|
describe '#empty?' do
|
123
123
|
context 'when the cache is empty' do
|
124
124
|
it 'returns true' do
|
125
|
-
subject.empty
|
125
|
+
expect(subject.empty?).to be_truthy
|
126
126
|
end
|
127
127
|
end
|
128
128
|
context 'when the cache is not empty' do
|
129
129
|
it 'returns false' do
|
130
130
|
subject['stuff2'] = 'ff'
|
131
|
-
subject.empty
|
131
|
+
expect(subject.empty?).to be_falsey
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -136,13 +136,13 @@ shared_examples_for 'cache' do
|
|
136
136
|
describe '#any?' do
|
137
137
|
context 'when the cache is empty' do
|
138
138
|
it 'returns true' do
|
139
|
-
subject.any
|
139
|
+
expect(subject.any?).to be_falsey
|
140
140
|
end
|
141
141
|
end
|
142
142
|
context 'when the cache is not empty' do
|
143
143
|
it 'returns false' do
|
144
144
|
subject['stuff3'] = [ 'ff ' ]
|
145
|
-
subject.any
|
145
|
+
expect(subject.any?).to be_truthy
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -150,13 +150,13 @@ shared_examples_for 'cache' do
|
|
150
150
|
describe '#[]=' do
|
151
151
|
it 'stores an object' do
|
152
152
|
v = 'val'
|
153
|
-
(subject[:key] = v).
|
154
|
-
subject[:key].
|
153
|
+
expect(subject[:key] = v).to eq(v)
|
154
|
+
expect(subject[:key]).to eq(v)
|
155
155
|
end
|
156
156
|
it 'is alias of #store' do
|
157
157
|
v = 'val2'
|
158
|
-
subject.store( :key2, v ).
|
159
|
-
subject[:key2].
|
158
|
+
expect(subject.store( :key2, v )).to eq(v)
|
159
|
+
expect(subject[:key2]).to eq(v)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -164,13 +164,13 @@ shared_examples_for 'cache' do
|
|
164
164
|
it 'retrieves an object by key' do
|
165
165
|
v = 'val2'
|
166
166
|
subject[:key] = v
|
167
|
-
subject[:key].
|
168
|
-
subject.empty
|
167
|
+
expect(subject[:key]).to eq(v)
|
168
|
+
expect(subject.empty?).to be_falsey
|
169
169
|
end
|
170
170
|
|
171
171
|
context 'when the key does not exist' do
|
172
172
|
it 'returns nil' do
|
173
|
-
subject[:some_key].
|
173
|
+
expect(subject[:some_key]).to be_nil
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
@@ -185,7 +185,7 @@ shared_examples_for 'cache' do
|
|
185
185
|
cache[:my_key] = old_val
|
186
186
|
cache.fetch_or_store( :my_key ) { new_val }
|
187
187
|
|
188
|
-
cache[:my_key].
|
188
|
+
expect(cache[:my_key]).to eq(old_val)
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -195,7 +195,7 @@ shared_examples_for 'cache' do
|
|
195
195
|
cache = described_class.new
|
196
196
|
cache.fetch_or_store( :my_key ) { new_val }
|
197
197
|
|
198
|
-
cache[:my_key].
|
198
|
+
expect(cache[:my_key]).to eq(new_val)
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
@@ -204,12 +204,12 @@ shared_examples_for 'cache' do
|
|
204
204
|
context 'when the key exists' do
|
205
205
|
it 'returns true' do
|
206
206
|
subject[:key1] = 'v'
|
207
|
-
subject.include?( :key1 ).
|
207
|
+
expect(subject.include?( :key1 )).to be_truthy
|
208
208
|
end
|
209
209
|
end
|
210
210
|
context 'when the key does not exist' do
|
211
211
|
it 'returns false' do
|
212
|
-
subject.include?( :key2 ).
|
212
|
+
expect(subject.include?( :key2 )).to be_falsey
|
213
213
|
end
|
214
214
|
end
|
215
215
|
end
|
@@ -219,21 +219,21 @@ shared_examples_for 'cache' do
|
|
219
219
|
it 'deletes a key' do
|
220
220
|
v = 'my_val'
|
221
221
|
subject[:my_key] = v
|
222
|
-
subject.delete( :my_key ).
|
223
|
-
subject[:my_key].
|
224
|
-
subject.include?( :my_key ).
|
222
|
+
expect(subject.delete( :my_key )).to eq(v)
|
223
|
+
expect(subject[:my_key]).to be_nil
|
224
|
+
expect(subject.include?( :my_key )).to be_falsey
|
225
225
|
end
|
226
226
|
it 'returns its value' do
|
227
227
|
v = 'my_val'
|
228
228
|
subject[:my_key] = v
|
229
|
-
subject.delete( :my_key ).
|
230
|
-
subject[:my_key].
|
231
|
-
subject.include?( :my_key ).
|
229
|
+
expect(subject.delete( :my_key )).to eq(v)
|
230
|
+
expect(subject[:my_key]).to be_nil
|
231
|
+
expect(subject.include?( :my_key )).to be_falsey
|
232
232
|
end
|
233
233
|
end
|
234
234
|
context 'when the key does not exist' do
|
235
235
|
it 'should return nil' do
|
236
|
-
subject.delete( :my_key2 ).
|
236
|
+
expect(subject.delete( :my_key2 )).to be_nil
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -241,13 +241,13 @@ shared_examples_for 'cache' do
|
|
241
241
|
describe '#empty?' do
|
242
242
|
context 'when cache is empty' do
|
243
243
|
it 'returns true' do
|
244
|
-
subject.empty
|
244
|
+
expect(subject.empty?).to be_truthy
|
245
245
|
end
|
246
246
|
end
|
247
247
|
context 'when cache is not empty' do
|
248
248
|
it 'returns false' do
|
249
249
|
subject['ee'] = 'rr'
|
250
|
-
subject.empty
|
250
|
+
expect(subject.empty?).to be_falsey
|
251
251
|
end
|
252
252
|
end
|
253
253
|
end
|
@@ -255,13 +255,13 @@ shared_examples_for 'cache' do
|
|
255
255
|
describe '#any?' do
|
256
256
|
context 'when cache is empty' do
|
257
257
|
it 'returns false' do
|
258
|
-
subject.any
|
258
|
+
expect(subject.any?).to be_falsey
|
259
259
|
end
|
260
260
|
end
|
261
261
|
context 'when cache is not empty' do
|
262
262
|
it 'returns true' do
|
263
263
|
subject['ee'] = 'rr'
|
264
|
-
subject.any
|
264
|
+
expect(subject.any?).to be_truthy
|
265
265
|
end
|
266
266
|
end
|
267
267
|
end
|
@@ -269,12 +269,12 @@ shared_examples_for 'cache' do
|
|
269
269
|
describe '#clear' do
|
270
270
|
it 'empties the cache' do
|
271
271
|
subject[:my_key2] = 'v'
|
272
|
-
subject.size.
|
273
|
-
subject.empty
|
272
|
+
expect(subject.size).to be > 0
|
273
|
+
expect(subject.empty?).to be_falsey
|
274
274
|
subject.clear
|
275
275
|
|
276
|
-
subject.size.
|
277
|
-
subject.empty
|
276
|
+
expect(subject.size).to eq(0)
|
277
|
+
expect(subject.empty?).to be_truthy
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
@@ -286,7 +286,7 @@ shared_examples_for 'cache' do
|
|
286
286
|
subject[:test_key] = 'test_val'
|
287
287
|
new[:test_key] = 'test_val'
|
288
288
|
|
289
|
-
subject.
|
289
|
+
expect(subject).to eq(new)
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
@@ -297,7 +297,7 @@ shared_examples_for 'cache' do
|
|
297
297
|
subject[:test_key] = 'test_val'
|
298
298
|
new[:test_key] = 'test_val2'
|
299
299
|
|
300
|
-
subject.
|
300
|
+
expect(subject).not_to eq(new)
|
301
301
|
end
|
302
302
|
end
|
303
303
|
end
|
@@ -310,7 +310,7 @@ shared_examples_for 'cache' do
|
|
310
310
|
subject[:test_key] = 'test_val'
|
311
311
|
new[:test_key] = 'test_val'
|
312
312
|
|
313
|
-
subject.hash.
|
313
|
+
expect(subject.hash).to eq(new.hash)
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
@@ -321,7 +321,7 @@ shared_examples_for 'cache' do
|
|
321
321
|
subject[:test_key] = 'test_val'
|
322
322
|
new[:test_key] = 'test_val2'
|
323
323
|
|
324
|
-
subject.hash.
|
324
|
+
expect(subject.hash).not_to eq(new.hash)
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
@@ -331,11 +331,11 @@ shared_examples_for 'cache' do
|
|
331
331
|
subject[:test_key] = 'test_val'
|
332
332
|
copy = subject.dup
|
333
333
|
|
334
|
-
copy.
|
334
|
+
expect(copy).to eq(subject)
|
335
335
|
|
336
336
|
copy[:test_key] = 'test_val2'
|
337
337
|
|
338
|
-
copy.
|
338
|
+
expect(copy).not_to eq(subject)
|
339
339
|
end
|
340
340
|
end
|
341
341
|
end
|