ensnare 0.1beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +10 -0
- data/README.md +77 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/application.js +10 -0
- data/app/assets/javascripts/ensnare/ZeroClipboard.js +474 -0
- data/app/assets/javascripts/ensnare/ZeroClipboard.min.js +9 -0
- data/app/assets/javascripts/ensnare/ZeroClipboard.swf +0 -0
- data/app/assets/javascripts/ensnare/application.js +20 -0
- data/app/assets/javascripts/ensnare/bootstrap-switch.js +382 -0
- data/app/assets/javascripts/ensnare/bootstrap_and_overrides.js +4 -0
- data/app/assets/javascripts/ensnare/clippy.js +18 -0
- data/app/assets/javascripts/ensnare/config_switch.js +19 -0
- data/app/assets/javascripts/ensnare/on_handler.js +9 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +30 -0
- data/app/assets/stylesheets/ensnare/application.css +13 -0
- data/app/assets/stylesheets/ensnare/bootstrap-switch.css +408 -0
- data/app/assets/stylesheets/ensnare/bootstrap_and_overrides.css +7 -0
- data/app/assets/stylesheets/ensnare/dashboard.css +4 -0
- data/app/assets/stylesheets/ensnare/toggle-switch.css +310 -0
- data/app/assets/stylesheets/ensnare/violation.css +4 -0
- data/app/controllers/ensnare/application_controller.rb +22 -0
- data/app/controllers/ensnare/configuration_controller.rb +15 -0
- data/app/controllers/ensnare/dashboard_controller.rb +32 -0
- data/app/controllers/ensnare/violations_controller.rb +36 -0
- data/app/helpers/ensnare/application_helper.rb +4 -0
- data/app/helpers/ensnare/dashboard_helper.rb +6 -0
- data/app/helpers/ensnare/violation_helper.rb +4 -0
- data/app/models/ensnare/violation.rb +6 -0
- data/app/views/ensnare/dashboard/configs.html.erb +1191 -0
- data/app/views/ensnare/dashboard/edit.html.erb +2 -0
- data/app/views/ensnare/dashboard/metrics.html.erb +38 -0
- data/app/views/ensnare/dashboard/metrics/_table.html.erb +17 -0
- data/app/views/ensnare/dashboard/mode.html.erb +75 -0
- data/app/views/ensnare/dashboard/violations.html.erb +32 -0
- data/app/views/ensnare/violations/captcha.html.erb +11 -0
- data/app/views/ensnare/violations/redirect.html.erb +2 -0
- data/app/views/ensnare/violations/show.html.erb +2 -0
- data/app/views/layouts/ensnare/application.html.erb +77 -0
- data/app/views/layouts/ensnare/captcha.html.erb +51 -0
- data/config/locales/en.bootstrap.yml +18 -0
- data/config/routes.rb +14 -0
- data/db/migrate/20131007205246_create_ensnare_violations.rb +10 -0
- data/db/migrate/20131007210137_rename_violation_type_field.rb +6 -0
- data/db/migrate/20131029010445_add_fields_to_violation.rb +8 -0
- data/db/migrate/20131031001835_add_name_to_ensnare_violation.rb +5 -0
- data/db/migrate/20131121163305_add_weight_to_violations.rb +5 -0
- data/lib/ensnare.rb +306 -0
- data/lib/ensnare/controllers/helpers.rb +143 -0
- data/lib/ensnare/engine.rb +30 -0
- data/lib/ensnare/form_tag_helper.rb +116 -0
- data/lib/ensnare/responses/block.rb +8 -0
- data/lib/ensnare/responses/captcha.rb +20 -0
- data/lib/ensnare/responses/flash_error.rb +11 -0
- data/lib/ensnare/responses/none.rb +10 -0
- data/lib/ensnare/responses/not_found.rb +9 -0
- data/lib/ensnare/responses/random_content.rb +11 -0
- data/lib/ensnare/responses/redirect.rb +8 -0
- data/lib/ensnare/responses/redirect_loop.rb +10 -0
- data/lib/ensnare/responses/response.rb +19 -0
- data/lib/ensnare/responses/server_error.rb +8 -0
- data/lib/ensnare/responses/throttle.rb +8 -0
- data/lib/ensnare/traps/cookie.rb +98 -0
- data/lib/ensnare/traps/parameter.rb +88 -0
- data/lib/ensnare/traps/reg_ex.rb +26 -0
- data/lib/ensnare/traps/routing_error.rb +25 -0
- data/lib/ensnare/traps/trap.rb +36 -0
- data/lib/ensnare/version.rb +3 -0
- data/lib/generators/ensnare/install_generator.rb +12 -0
- data/lib/generators/templates/ensnare.rb +44 -0
- data/lib/tasks/ensnare_tasks.rb +4 -0
- data/test/dummy/Gemfile +46 -0
- data/test/dummy/Gemfile.lock +149 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/images/rails.png +0 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/bootstrap.js +4 -0
- data/test/dummy/app/assets/javascripts/bootstrap.js.coffee +3 -0
- data/test/dummy/app/assets/javascripts/widgets.js.coffee +3 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
- data/test/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/test/dummy/app/assets/stylesheets/widgets.css.scss +3 -0
- data/test/dummy/app/controllers/application_controller.rb +12 -0
- data/test/dummy/app/controllers/widgets_controller.rb +94 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/widgets_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +15 -0
- data/test/dummy/app/models/widget.rb +4 -0
- data/test/dummy/app/views/layouts/application.html.erb +108 -0
- data/test/dummy/app/views/widgets/_form.html.erb +25 -0
- data/test/dummy/app/views/widgets/edit.html.erb +6 -0
- data/test/dummy/app/views/widgets/index.html.erb +25 -0
- data/test/dummy/app/views/widgets/new.html.erb +5 -0
- data/test/dummy/app/views/widgets/show.html.erb +15 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +65 -0
- data/test/dummy/config/boot.rb +6 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/captcha.rb +5 -0
- data/test/dummy/config/initializers/devise.rb +258 -0
- data/test/dummy/config/initializers/ensnare.rb +272 -0
- data/test/dummy/config/initializers/ensnare.sample +323 -0
- data/test/dummy/config/initializers/examples.example +323 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/quiet_assets.rb +13 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/devise.en.yml +60 -0
- data/test/dummy/config/locales/en.bootstrap.yml +18 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +68 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20131007193540_create_widgets.rb +10 -0
- data/test/dummy/db/migrate/20131031153254_devise_create_users.rb +42 -0
- data/test/dummy/db/migrate/20140405051634_create_ensnare_violations.ensnare.rb +11 -0
- data/test/dummy/db/migrate/20140405051635_rename_violation_type_field.ensnare.rb +7 -0
- data/test/dummy/db/migrate/20140405051636_add_fields_to_violation.ensnare.rb +9 -0
- data/test/dummy/db/migrate/20140405051637_add_name_to_ensnare_violation.ensnare.rb +6 -0
- data/test/dummy/db/migrate/20140405051638_add_weight_to_violations.ensnare.rb +6 -0
- data/test/dummy/db/schema.rb +54 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/doc/README_FOR_APP +2 -0
- data/test/dummy/lib/ensnare/responses/custom.rb_sample +11 -0
- data/test/dummy/lib/ensnare/traps/custom.rb_sample +26 -0
- data/test/dummy/log/development.log +92903 -0
- data/test/dummy/log/production.log +158 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/users.yml +11 -0
- data/test/dummy/test/fixtures/widgets.yml +9 -0
- data/test/dummy/test/functional/widgets_controller_test.rb +49 -0
- data/test/dummy/test/performance/browsing_test.rb +12 -0
- data/test/dummy/test/test_helper.rb +13 -0
- data/test/dummy/test/unit/helpers/widgets_helper_test.rb +4 -0
- data/test/dummy/test/unit/user_test.rb +7 -0
- data/test/dummy/test/unit/widget_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/C10/FA0/sprockets%2F269fa26485a91206814a45af06210315 +0 -0
- data/test/dummy/tmp/cache/assets/C23/310/sprockets%2Fc79437284218b38e613366d14284ac07 +0 -0
- data/test/dummy/tmp/cache/assets/C40/710/sprockets%2F545779172fbf9cf79082774a07841659 +0 -0
- data/test/dummy/tmp/cache/assets/C48/0D0/sprockets%2F75b535a43e06025546821f95d011d85b +0 -0
- data/test/dummy/tmp/cache/assets/C4E/110/sprockets%2Fb806449c86337e3e06070c462280e90b +0 -0
- data/test/dummy/tmp/cache/assets/C57/BD0/sprockets%2Facd987410b744152d157762609194e8c +0 -0
- data/test/dummy/tmp/cache/assets/C5D/9E0/sprockets%2F0d79b66115628050357f99d36aa4876d +0 -0
- data/test/dummy/tmp/cache/assets/C80/840/sprockets%2F562c2d168da585f80579347d10790a0a +0 -0
- data/test/dummy/tmp/cache/assets/C84/DD0/sprockets%2F3e508585142de6585818df6a2290bf11 +0 -0
- data/test/dummy/tmp/cache/assets/C85/E00/sprockets%2Fcbe2d565923657893e41f9160d30e540 +0 -0
- data/test/dummy/tmp/cache/assets/C88/BC0/sprockets%2F341dd4748a8a73570a59264e9f9540b2 +0 -0
- data/test/dummy/tmp/cache/assets/C8D/F80/sprockets%2F81e191073a2f74b9eca460537339789f +0 -0
- data/test/dummy/tmp/cache/assets/C98/B10/sprockets%2F94976d41a9fc1279e0cd996c78087410 +0 -0
- data/test/dummy/tmp/cache/assets/C9F/190/sprockets%2Fb8f3f499dc494543381d55292e346e99 +0 -0
- data/test/dummy/tmp/cache/assets/CA4/1A0/sprockets%2F629131c0f22f0d55ed1725737a343bd7 +0 -0
- data/test/dummy/tmp/cache/assets/CAD/EB0/sprockets%2F481955f78ac093b746e0512b4a9c1b24 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/8D0/sprockets%2Fba6342b6172d4ee18e951f667e237313 +0 -0
- data/test/dummy/tmp/cache/assets/CB4/DC0/sprockets%2F48af5bbf36e6f2720f4144f928129612 +0 -0
- data/test/dummy/tmp/cache/assets/CB7/5B0/sprockets%2F67a1cdb0edc3998371d944050583e358 +0 -0
- data/test/dummy/tmp/cache/assets/CB8/F00/sprockets%2F089f52a057d7a14247c7f93e8b59143b +0 -0
- data/test/dummy/tmp/cache/assets/CBD/0E0/sprockets%2F662f42b5efa6584377436f1d94318cd4 +0 -0
- data/test/dummy/tmp/cache/assets/CBF/4D0/sprockets%2F1462d4ee75c877880447a02b2f58e6b9 +0 -0
- data/test/dummy/tmp/cache/assets/CC3/220/sprockets%2F218c30380a6f2bae6b7402068da50f01 +0 -0
- data/test/dummy/tmp/cache/assets/CC7/200/sprockets%2F5366d8fff996ca22271713d1ca987379 +0 -0
- data/test/dummy/tmp/cache/assets/CCE/810/sprockets%2F90453c5b48e1f0a4f1a6836135c1c4b1 +0 -0
- data/test/dummy/tmp/cache/assets/CD4/E90/sprockets%2F5464e430cbb52421e1f9c23947fe31c1 +0 -0
- data/test/dummy/tmp/cache/assets/CD5/2C0/sprockets%2F166c056119ebdfb8b7104c97b424b423 +0 -0
- data/test/dummy/tmp/cache/assets/CD7/6F0/sprockets%2Fbd3936370d0f952ada5774e2230046ed +0 -0
- data/test/dummy/tmp/cache/assets/CD7/C90/sprockets%2F5382f60c349e1511eefc83803fa450c1 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CDC/5C0/sprockets%2F9767868b3b77f9164f290797f1d8fe5c +0 -0
- data/test/dummy/tmp/cache/assets/CDE/570/sprockets%2F0e30065c6148a1ef8d5e42439e148f4d +0 -0
- data/test/dummy/tmp/cache/assets/CE0/CC0/sprockets%2F2b38c3fb549036de5c4666637a0c80c6 +0 -0
- data/test/dummy/tmp/cache/assets/CE0/F80/sprockets%2F487624acd392c0310f0c7434e88d48bf +0 -0
- data/test/dummy/tmp/cache/assets/CE4/570/sprockets%2F306a61edb38d739bb2f81b448b376818 +0 -0
- data/test/dummy/tmp/cache/assets/CE5/C70/sprockets%2F681ae890ae2f44aee1099119d04a7938 +0 -0
- data/test/dummy/tmp/cache/assets/CE5/CE0/sprockets%2F9d186abc5f6a106511502d60d98ff939 +0 -0
- data/test/dummy/tmp/cache/assets/CE6/B90/sprockets%2F5997a940521ec92b2ea92eb63c49a562 +0 -0
- data/test/dummy/tmp/cache/assets/CE6/DE0/sprockets%2F9889a2fbf25b223583561299dfca004e +0 -0
- data/test/dummy/tmp/cache/assets/CE7/6F0/sprockets%2F6ac42c22840f7d853b6184b6f94a65c8 +0 -0
- data/test/dummy/tmp/cache/assets/CE7/E70/sprockets%2F704fcbd6f72c99767550538053a0bc7d +0 -0
- data/test/dummy/tmp/cache/assets/CE8/6E0/sprockets%2F51f80f23e41678e790edd8710c6d75c0 +0 -0
- data/test/dummy/tmp/cache/assets/CE9/510/sprockets%2F0c8887733a9e311fd348f21029d6bef6 +0 -0
- data/test/dummy/tmp/cache/assets/CEA/BA0/sprockets%2F98e291b46a924814292e2daf17ad8c84 +0 -0
- data/test/dummy/tmp/cache/assets/CF4/140/sprockets%2F22a3157d204c1f8e417a25f01a2dbe45 +0 -0
- data/test/dummy/tmp/cache/assets/CF6/EE0/sprockets%2F9e92e631fb88a8e23180da66c77859f0 +0 -0
- data/test/dummy/tmp/cache/assets/CF7/8B0/sprockets%2F0f091833381aa52e100fb74924fdc1aa +0 -0
- data/test/dummy/tmp/cache/assets/CF9/AF0/sprockets%2Fe6cf7ff483a7c68902418a2f4b374889 +0 -0
- data/test/dummy/tmp/cache/assets/CFF/C60/sprockets%2F0889d12d44383c7e7a859966f686badf +0 -0
- data/test/dummy/tmp/cache/assets/D04/D90/sprockets%2F617b1ad4f3ced27a38b689309c3240a2 +0 -0
- data/test/dummy/tmp/cache/assets/D06/D60/sprockets%2Fa09118ec6cd7033eb762b64a1ae58274 +0 -0
- data/test/dummy/tmp/cache/assets/D07/8B0/sprockets%2Ff123328eedad10b6f547eba992560504 +0 -0
- data/test/dummy/tmp/cache/assets/D09/740/sprockets%2Fb4177155aa0b2a846458b4da378dbe56 +0 -0
- data/test/dummy/tmp/cache/assets/D0A/6F0/sprockets%2Fa394b21853c45302cad3b17f7de2489e +0 -0
- data/test/dummy/tmp/cache/assets/D0B/E00/sprockets%2Fce33d32f3235ad54031338e689a8bdc7 +0 -0
- data/test/dummy/tmp/cache/assets/D0C/3B0/sprockets%2Ff34ef114cb808f84780a11082ade91d7 +0 -0
- data/test/dummy/tmp/cache/assets/D0F/3E0/sprockets%2F6654975eaa53a225d976278fcb6baa00 +0 -0
- data/test/dummy/tmp/cache/assets/D0F/550/sprockets%2F9927550095e029ace0d4d5add6901ce5 +0 -0
- data/test/dummy/tmp/cache/assets/D10/790/sprockets%2F31d2271940e9d19a9a5fb42fc70f26d7 +0 -0
- data/test/dummy/tmp/cache/assets/D12/1F0/sprockets%2Fce0c803f16e21317768892d42f1a8efc +0 -0
- data/test/dummy/tmp/cache/assets/D12/8E0/sprockets%2F93656a1c9a1db15ff824a84f3867c3b0 +0 -0
- data/test/dummy/tmp/cache/assets/D14/380/sprockets%2F7d5975b3efc5ace265c437a91539101f +0 -0
- data/test/dummy/tmp/cache/assets/D14/890/sprockets%2F2cb018dd1879c96fa83d4909b04f21e5 +0 -0
- data/test/dummy/tmp/cache/assets/D16/1F0/sprockets%2Fb19e1a25f43ad7167231aee857288f6f +0 -0
- data/test/dummy/tmp/cache/assets/D18/150/sprockets%2F524feca5ed7674507bd2e517943f45c4 +0 -0
- data/test/dummy/tmp/cache/assets/D19/6F0/sprockets%2Fc63725cd8e7d8f30818f7a82a75cc331 +0 -0
- data/test/dummy/tmp/cache/assets/D1A/600/sprockets%2F56bf56fa14222faef68241a4866f9e28 +0 -0
- data/test/dummy/tmp/cache/assets/D1E/AF0/sprockets%2F38fb02a7c41a3f3956e1f8b783885af8 +0 -0
- data/test/dummy/tmp/cache/assets/D21/2A0/sprockets%2F1fa2a4758d368a4ed74af19d94958d53 +0 -0
- data/test/dummy/tmp/cache/assets/D23/C30/sprockets%2F30a075c86c0057f03ed03a1a6c1ac74f +0 -0
- data/test/dummy/tmp/cache/assets/D2C/3A0/sprockets%2F5fb3206e15e73cbac0463d4e0633b9c1 +0 -0
- data/test/dummy/tmp/cache/assets/D2D/B40/sprockets%2F214ba38cd9bae5351510b85c60b1cf66 +0 -0
- data/test/dummy/tmp/cache/assets/D31/410/sprockets%2F1fb41a8351cfe74b19081d3a0a8cd186 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D34/3C0/sprockets%2Fd6f33bf9ea577a425537e31a1b1436aa +0 -0
- data/test/dummy/tmp/cache/assets/D36/A50/sprockets%2F4c5a2303a78ff5007cba199ec980b41d +0 -0
- data/test/dummy/tmp/cache/assets/D38/300/sprockets%2F231189114e3e16c0af8cbbfb922a7c89 +0 -0
- data/test/dummy/tmp/cache/assets/D3A/320/sprockets%2Fb4e466a4108157e7bbdf8a80530e76ab +0 -0
- data/test/dummy/tmp/cache/assets/D3C/430/sprockets%2Fc1850205179d6bc0315cf87db4edd7a8 +0 -0
- data/test/dummy/tmp/cache/assets/D3C/600/sprockets%2F6cb9fa003e4ae915755dbc429d54b255 +0 -0
- data/test/dummy/tmp/cache/assets/D3D/970/sprockets%2F9e70fe2b22f4504ee45029b9d04ce46c +0 -0
- data/test/dummy/tmp/cache/assets/D3F/4A0/sprockets%2F9d1d25fb38006ddc0e6fcf42190d8583 +0 -0
- data/test/dummy/tmp/cache/assets/D3F/D70/sprockets%2Fa7d40ead3d8014db7e90ec643e323969 +0 -0
- data/test/dummy/tmp/cache/assets/D43/7F0/sprockets%2F05ba12f3e980c9658d979415aca6a3ce +0 -0
- data/test/dummy/tmp/cache/assets/D45/7E0/sprockets%2Fc24e2e08818f34b11af78c7b4467fb5f +0 -0
- data/test/dummy/tmp/cache/assets/D45/970/sprockets%2Ff0e7b8648d5a2519256c1eeb2d9f08d2 +0 -0
- data/test/dummy/tmp/cache/assets/D45/F90/sprockets%2F6b6e959a5f0990831a196b6bddb05f3b +0 -0
- data/test/dummy/tmp/cache/assets/D47/E90/sprockets%2Fa578fc0e68c5d167fc5c365e2c09a616 +0 -0
- data/test/dummy/tmp/cache/assets/D48/090/sprockets%2F7a07a493490b7ac1cc0466a9eed8e589 +0 -0
- data/test/dummy/tmp/cache/assets/D4A/820/sprockets%2Feb00ebb7f262bff8638844571e1a859f +0 -0
- data/test/dummy/tmp/cache/assets/D4B/160/sprockets%2F78835ac7e39b080e262f9a4b76cbd65d +0 -0
- data/test/dummy/tmp/cache/assets/D4B/320/sprockets%2F4a570986eef4f2707130eb8c9c36d9ad +0 -0
- data/test/dummy/tmp/cache/assets/D4C/7F0/sprockets%2F5c0e220ac801d18f4bd1bd65e043d20a +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D4F/E20/sprockets%2F2da45938fca5e6979baa57c61b43b689 +0 -0
- data/test/dummy/tmp/cache/assets/D51/C40/sprockets%2F9c881f9a0edd974bf6ff0f83a4308192 +0 -0
- data/test/dummy/tmp/cache/assets/D52/6A0/sprockets%2F8b5de085dffa4897817e72a1b75348cd +0 -0
- data/test/dummy/tmp/cache/assets/D54/210/sprockets%2F8d24b46f6838cc66ddb9c7b07d32e939 +0 -0
- data/test/dummy/tmp/cache/assets/D56/C20/sprockets%2F4ce9229c7c971ce590189cfea1e74d95 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/310/sprockets%2F7f968e95238c9866f6ebd76a16b2aab6 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/7B0/sprockets%2Fda913ea979b742f1f7418f488e32fe8f +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D5C/1F0/sprockets%2Fed34fbbec82818204a214b5114d3dce5 +0 -0
- data/test/dummy/tmp/cache/assets/D64/700/sprockets%2F76c71d55a65dae34d0f60d62ee3a63b0 +0 -0
- data/test/dummy/tmp/cache/assets/D64/DE0/sprockets%2F655e1ca6a735ac75093c0e01febce293 +0 -0
- data/test/dummy/tmp/cache/assets/D72/4B0/sprockets%2F34ba5dd43adc2c826b79ce9a944f8620 +0 -0
- data/test/dummy/tmp/cache/assets/D76/710/sprockets%2F6740efeff28c623e091100f28f7c9eaf +0 -0
- data/test/dummy/tmp/cache/assets/D77/3D0/sprockets%2F76515b80ab945bb46f93cdace3993c4e +0 -0
- data/test/dummy/tmp/cache/assets/D78/C60/sprockets%2F3ed4e68ec22d09a66c1ea96e6b733d66 +0 -0
- data/test/dummy/tmp/cache/assets/D92/5E0/sprockets%2F17d03aff61dbd220217eb7f159bb8df2 +0 -0
- data/test/dummy/tmp/cache/assets/D96/CE0/sprockets%2Fff431fe62bbb5f0e9d63c43c4010fd56 +0 -0
- data/test/dummy/tmp/cache/assets/D9C/CF0/sprockets%2Fde9afe6f38620c4144b5a5fd1dc36f23 +0 -0
- data/test/dummy/tmp/cache/assets/D9C/EA0/sprockets%2Ff1cdf6c71079c7b373b1b842bf4e9a3a +0 -0
- data/test/dummy/tmp/cache/assets/D9D/590/sprockets%2F93ee64febc21345494bfbd0a8aad6446 +0 -0
- data/test/dummy/tmp/cache/assets/D9E/490/sprockets%2Fe231e8b6ec488aecaf61d84bb542e029 +0 -0
- data/test/dummy/tmp/cache/assets/D9E/6A0/sprockets%2F0a9e2c29287a00d9b9cc94cd9b3af63a +0 -0
- data/test/dummy/tmp/cache/assets/DA0/110/sprockets%2F29a7ddee7ded49b2613bb26f5d0980a3 +0 -0
- data/test/dummy/tmp/cache/assets/DA2/580/sprockets%2F35d3674fac89e6235b3fa6b251fbc3ff +0 -0
- data/test/dummy/tmp/cache/assets/DA2/780/sprockets%2F83886a2d2dba19d6cf5a2ea7fe7213d7 +0 -0
- data/test/dummy/tmp/cache/assets/DA3/9C0/sprockets%2F7f2d6495f1f675acc353e0a37adc94ae +0 -0
- data/test/dummy/tmp/cache/assets/DA6/B80/sprockets%2F60bbf1fc573c8bc35c8da9082888cb6c +0 -0
- data/test/dummy/tmp/cache/assets/DA6/EB0/sprockets%2F83015053ed9a581994cafcbbf9e7e6ab +0 -0
- data/test/dummy/tmp/cache/assets/DA7/0C0/sprockets%2Fc9194b0b488f53a9afc0540ced96ad9e +0 -0
- data/test/dummy/tmp/cache/assets/DA7/6D0/sprockets%2F28ce714e9b9d6aa16c4604bc9b5afd79 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/490/sprockets%2F9815ad0a7dab6fbdfb2856654298acf7 +0 -0
- data/test/dummy/tmp/cache/assets/DAC/E40/sprockets%2Fec3c6d68d0e246ed889fe31471dc44fc +0 -0
- data/test/dummy/tmp/cache/assets/DAE/050/sprockets%2F6a3d58d879f5afbf0ad526425fe76a5f +0 -0
- data/test/dummy/tmp/cache/assets/DB8/040/sprockets%2F218aaca004d507da6f207ce9de821bea +0 -0
- data/test/dummy/tmp/cache/assets/DBB/E80/sprockets%2Fa01bf17ca00dc2b43f749abe69cad680 +0 -0
- data/test/dummy/tmp/cache/assets/DBD/170/sprockets%2Fc229df8cfb1c041769d0bb3c8eb310ac +0 -0
- data/test/dummy/tmp/cache/assets/DBF/770/sprockets%2F89c90a5f9259fc5b1b6ed69efe7c88d2 +0 -0
- data/test/dummy/tmp/cache/assets/DBF/850/sprockets%2Fb37d146f03d1ab72bd81afa3b7c295bf +0 -0
- data/test/dummy/tmp/cache/assets/DC3/E90/sprockets%2F63fce83ccf6fed1a634c00ec9623ba30 +0 -0
- data/test/dummy/tmp/cache/assets/DC4/1B0/sprockets%2Fedae9235cb5ca2fc97c2d335ba27a660 +0 -0
- data/test/dummy/tmp/cache/assets/DC7/2B0/sprockets%2Fda49c151b0b2be5bf6e8e135bd6f80d6 +0 -0
- data/test/dummy/tmp/cache/assets/DC9/C70/sprockets%2Fba5f2321c2ee8c42d0ff498a12e5bf7e +0 -0
- data/test/dummy/tmp/cache/assets/DCA/DC0/sprockets%2F7ed2addf814bfd28c3bad7790e005d53 +0 -0
- data/test/dummy/tmp/cache/assets/DCB/320/sprockets%2F672cc04c39b0a37cbe89cecbf3580ad7 +0 -0
- data/test/dummy/tmp/cache/assets/DCB/AE0/sprockets%2Fd14638ac9aaefa36ca75c1d66cb727e3 +0 -0
- data/test/dummy/tmp/cache/assets/DCC/1D0/sprockets%2Ff6defe1375c5acb57e141263b70fe5eb +0 -0
- data/test/dummy/tmp/cache/assets/DD1/DB0/sprockets%2Fc7a35f025c7fb33a2d9ce83ce4bd4f86 +0 -0
- data/test/dummy/tmp/cache/assets/DD2/5B0/sprockets%2F91c620bad817c7ffa64d5ea8b446db6f +0 -0
- data/test/dummy/tmp/cache/assets/DD2/D60/sprockets%2Fcc373f8a8e1d94ed2154dc37ca0f3ff6 +0 -0
- data/test/dummy/tmp/cache/assets/DD5/8E0/sprockets%2F0dde6f938e5addbdab55f6e7037e1482 +0 -0
- data/test/dummy/tmp/cache/assets/DD5/B80/sprockets%2Fdd3beb4c76fbf877171fd66192ebc4b2 +0 -0
- data/test/dummy/tmp/cache/assets/DD7/F30/sprockets%2Fe5fedf2dc39b7a678447c63ee2601ebc +0 -0
- data/test/dummy/tmp/cache/assets/DDB/200/sprockets%2F9dd434d9f9a3f7f4b35d90a0ddd6fb19 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/1F0/sprockets%2F7533abdaee852b1c7bb05cabe3b2040a +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DDD/190/sprockets%2F85d9f2c43cee7e82bdf893e0d35ac66a +0 -0
- data/test/dummy/tmp/cache/assets/DDD/1E0/sprockets%2F951cfc59ce1918fcb37c28fa20e9ebf7 +0 -0
- data/test/dummy/tmp/cache/assets/DDE/590/sprockets%2F2e7b6f67b665649ced381dfe37ce2abe +0 -0
- data/test/dummy/tmp/cache/assets/DDE/660/sprockets%2Ff64ad0798dfc7f6da9fcd83b53c8c250 +0 -0
- data/test/dummy/tmp/cache/assets/DE8/2A0/sprockets%2F37ceb226c01db0bd317e3f3fcfcf1c51 +0 -0
- data/test/dummy/tmp/cache/assets/DE8/440/sprockets%2F5559ecfd0ee508d816e4dc889cd8fe3b +0 -0
- data/test/dummy/tmp/cache/assets/DEE/730/sprockets%2F8121bbae4961aeba50bdb2cbd939c09f +0 -0
- data/test/dummy/tmp/cache/assets/DEF/AB0/sprockets%2Ff8c08dc2009dc1c91a4da29cc852badb +0 -0
- data/test/dummy/tmp/cache/assets/DF1/9C0/sprockets%2F7bbd18d10dc4ea3f5d6b137a5b0c9e7b +0 -0
- data/test/dummy/tmp/cache/assets/DF8/6B0/sprockets%2F3b2dfa4e62529eeedd6de03ab7b26b19 +0 -0
- data/test/dummy/tmp/cache/assets/DFA/CE0/sprockets%2F11f1769f11ddfe50ae1ec399fafa1cf3 +0 -0
- data/test/dummy/tmp/cache/assets/DFE/C50/sprockets%2F0af9ec26a81ea5fa1e72f6de4f7a8e03 +0 -0
- data/test/dummy/tmp/cache/assets/DFF/900/sprockets%2Fd6d6cf5ff58edce3840dc45621fb1a1d +0 -0
- data/test/dummy/tmp/cache/assets/E02/C30/sprockets%2Fecc53a781b3bf1fbcc94fc77c951c5c5 +0 -0
- data/test/dummy/tmp/cache/assets/E04/440/sprockets%2F28fe8df46cdf880c8aa0cced70bb7570 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E08/200/sprockets%2Fed91cd00ed3e395eef48f19c62de6e1d +0 -0
- data/test/dummy/tmp/cache/assets/E10/340/sprockets%2F7ebd866bfd5a89bfdbf6d928b1d7341d +0 -0
- data/test/dummy/tmp/cache/assets/E19/2A0/sprockets%2F10fcfbe6ebae11a40c8eac41939a1b9a +0 -0
- data/test/dummy/tmp/cache/assets/E23/A10/sprockets%2F03c4303cddb0cfd8cc9e67aa76c70aee +0 -0
- data/test/dummy/tmp/cache/assets/E24/670/sprockets%2Fb857c29efff63c768fbb48ef8e79aae7 +0 -0
- data/test/dummy/tmp/cache/assets/E2E/550/sprockets%2Ffb7d8bb50347f4edae6b56ca4bdf07b7 +0 -0
- data/test/dummy/tmp/cache/assets/E3B/080/sprockets%2F09e2a090befacdae0db10cafb1893a0a +0 -0
- data/test/dummy/tmp/cache/assets/E3E/DE0/sprockets%2Fa977ff5dc4e348f89fe35af4bd2aae3c +0 -0
- data/test/dummy/tmp/cache/assets/E45/C30/sprockets%2F69ccc9abc9b338aeee9ee4f1958fb64c +0 -0
- data/test/dummy/tmp/cache/assets/E83/1F0/sprockets%2F936cdaaa3e9ff0aafac3bc95ea45a3c6 +0 -0
- data/test/dummy/tmp/cache/assets/E85/370/sprockets%2Fca34a37aca7a3f4fe4b2d9ad46ecccc9 +0 -0
- data/test/dummy/tmp/cache/assets/E89/CE0/sprockets%2F86a2fd89bf33cbbacf438bb6ef0f3aca +0 -0
- data/test/dummy/tmp/cache/assets/F45/590/sprockets%2Fedcf9d1288bc0cfabaccf35fa6ecceca +0 -0
- data/test/dummy/tmp/cache/sass/867224f66ea2bfec241b4cee6d1fd9626cb72b7e/scaffolds.css.scssc +0 -0
- data/test/dummy/tmp/cache/sass/867224f66ea2bfec241b4cee6d1fd9626cb72b7e/widgets.css.scssc +0 -0
- data/test/ensnare_test.rb +7 -0
- data/test/fixtures/ensnare/violations.yml +9 -0
- data/test/functional/ensnare/dashboard_controller_test.rb +16 -0
- data/test/functional/ensnare/violation_controller_test.rb +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/ensnare/violation_test.rb +9 -0
- data/test/unit/helpers/ensnare/dashboard_helper_test.rb +6 -0
- data/test/unit/helpers/ensnare/violation_helper_test.rb +6 -0
- metadata +692 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<div class="container">
|
|
2
|
+
<div class="row">
|
|
3
|
+
<div class="span12">
|
|
4
|
+
<% if Ensnare.error_message %>
|
|
5
|
+
<div class="alert alert-error">
|
|
6
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
7
|
+
<%= Ensnare.error_message %>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% if Ensnare.warning_message %>
|
|
11
|
+
<div class="alert alert-warning">
|
|
12
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
13
|
+
<%= Ensnare.warning_message %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
16
|
+
<h2>Metrics</h2><br>
|
|
17
|
+
<div class="well">
|
|
18
|
+
<h3>Basic</h3>
|
|
19
|
+
<dl class="dl-horizontal">
|
|
20
|
+
<dt>Violation Count:</dt>
|
|
21
|
+
<dd><%= @violations.count %></dd>
|
|
22
|
+
<dt>Unique IPs:</dt>
|
|
23
|
+
<dd><%= @violations_by_ip.count %></dd>
|
|
24
|
+
<dt>Unique Sessions:</dt>
|
|
25
|
+
<dd><%= @violations_by_session.count %></dd>
|
|
26
|
+
</dl>
|
|
27
|
+
|
|
28
|
+
<%= render :partial=>'ensnare/dashboard/metrics/table', :locals=>{:title=>"Violation Type", :objects=>@violations_by_type} %>
|
|
29
|
+
|
|
30
|
+
<%= render :partial=>'ensnare/dashboard/metrics/table', :locals=>{:title=>"IP Address", :objects=>@violations_by_ip} %>
|
|
31
|
+
|
|
32
|
+
<%= render :partial=>'ensnare/dashboard/metrics/table', :locals=>{:title=>"Session ID", :objects=>@violations_by_session} %>
|
|
33
|
+
|
|
34
|
+
<%= render :partial=>'ensnare/dashboard/metrics/table', :locals=>{:title=>"User ID", :objects=>@violations_by_user_id} %>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<h3><%= title %></h3>
|
|
2
|
+
<table class="table">
|
|
3
|
+
<thead>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Id</th>
|
|
6
|
+
<th>Count</th>
|
|
7
|
+
</tr>
|
|
8
|
+
</thead>
|
|
9
|
+
<tbody>
|
|
10
|
+
<% objects.each do |key, value| %>
|
|
11
|
+
<tr>
|
|
12
|
+
<td><%= key.blank? ? "<blank>" : key %></td>
|
|
13
|
+
<td><%= value %></td>
|
|
14
|
+
</tr>
|
|
15
|
+
<% end %>
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
</div><!--/.nav-collapse -->
|
|
2
|
+
</div>
|
|
3
|
+
</div>
|
|
4
|
+
</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="container">
|
|
8
|
+
<div class="row">
|
|
9
|
+
<div class="span6">
|
|
10
|
+
<% if Ensnare.error_message %>
|
|
11
|
+
<div class="alert alert-error">
|
|
12
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
13
|
+
|
|
14
|
+
<%= Ensnare.error_message %>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if Ensnare.warning_message %>
|
|
18
|
+
<div class="alert alert-warning">
|
|
19
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
20
|
+
|
|
21
|
+
<%= Ensnare.warning_message %>
|
|
22
|
+
</div>
|
|
23
|
+
<% end %>
|
|
24
|
+
<% if @mode == :enforce %>
|
|
25
|
+
<div class="alert alert-warning">
|
|
26
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
27
|
+
Ensnare is in <strong>'Enforce'</strong> mode.
|
|
28
|
+
</div>
|
|
29
|
+
<% elsif @mode == :log %>
|
|
30
|
+
<div class="alert alert-warning">
|
|
31
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
32
|
+
Ensnare is in <strong>'Log Only'</strong> mode.
|
|
33
|
+
</div>
|
|
34
|
+
<% elsif @mode == :disabled %>
|
|
35
|
+
<div class="alert alert-warning">
|
|
36
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
37
|
+
Ensnare is in <strong>'Disabled'</strong> mode.
|
|
38
|
+
</div>
|
|
39
|
+
<% end %>
|
|
40
|
+
<h2>Ensnare Setup</h2><br>
|
|
41
|
+
<div class="alert hidden" id="error_display">
|
|
42
|
+
<button type="button" class="close" data-dismiss="alert">×</button>
|
|
43
|
+
<strong>Invalid settings or server is down!</strong>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="well">
|
|
46
|
+
These changes are not persistent. Edit "ensnare.rb" config file for persistent changes.
|
|
47
|
+
<hr>
|
|
48
|
+
<%= form_tag change_mode_url do %>
|
|
49
|
+
|
|
50
|
+
<div class="control-group">
|
|
51
|
+
<div class="options">
|
|
52
|
+
<label>
|
|
53
|
+
<input type="radio" name="mode" id="disabled" value="disabled">
|
|
54
|
+
Disabled.
|
|
55
|
+
</label>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="options">
|
|
58
|
+
<label>
|
|
59
|
+
<input type="radio" name="mode" id="log" value="log">
|
|
60
|
+
Log only mode.
|
|
61
|
+
</label>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="options">
|
|
64
|
+
<label>
|
|
65
|
+
<input type="radio" name="mode" id="enforce" value="enforce">
|
|
66
|
+
Enforce.
|
|
67
|
+
</label>
|
|
68
|
+
</div>
|
|
69
|
+
</br>
|
|
70
|
+
<%= submit_tag "Submit Settings", :class => "btn btn-primary"%>
|
|
71
|
+
<% end %>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<table class="table">
|
|
2
|
+
<thead>
|
|
3
|
+
<tr>
|
|
4
|
+
<th>Event Time</th>
|
|
5
|
+
<th>Weight</th>
|
|
6
|
+
<th>IP Address</th>
|
|
7
|
+
<th>Session Id</th>
|
|
8
|
+
<th>User Id</th>
|
|
9
|
+
<th>Type</th>
|
|
10
|
+
<th>Name</th>
|
|
11
|
+
<th>Expected Value</th>
|
|
12
|
+
<th>Observed Value</th>
|
|
13
|
+
</tr>
|
|
14
|
+
</thead>
|
|
15
|
+
<tbody>
|
|
16
|
+
<% @violations.each do |v| %>
|
|
17
|
+
<tr>
|
|
18
|
+
<td><%= v.created_at.to_s %></td>
|
|
19
|
+
<td><%= v.weight.to_s %></td>
|
|
20
|
+
<td><%= v.ip_address.to_s %></td>
|
|
21
|
+
<td><%= v.session_id.to_s %></td>
|
|
22
|
+
<td><%= v.user_id.to_s %></td>
|
|
23
|
+
<td><%= v.violation_type.to_s %></td>
|
|
24
|
+
<td><%= v.name.to_s %></td>
|
|
25
|
+
<td><%= v.expected.to_s %></td>
|
|
26
|
+
<td><%= v.observed.to_s %></td>
|
|
27
|
+
</tr>
|
|
28
|
+
<% end %>
|
|
29
|
+
</tbody>
|
|
30
|
+
</table>
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<h1>Uh oh!</h1>
|
|
2
|
+
<% if(request.post?) %>
|
|
3
|
+
<p class="text-error">Unable to validate your response. Please try again.</p>
|
|
4
|
+
<% end %>
|
|
5
|
+
<p>Something has gone wrong. Please confirm you are human.<p>
|
|
6
|
+
<%= form_tag captcha_path do %>
|
|
7
|
+
<%= recaptcha_tags %>
|
|
8
|
+
<%= submit_tag %>
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
11
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<!-- saved from url=(0060)http://getbootstrap.com/2.3.2/examples/starter-template.html -->
|
|
3
|
+
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title><%= content_for?(:title) ? yield(:title) : "Ensnare" %></title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<meta name="description" content="Ensnare">
|
|
8
|
+
<meta name="author" content="Andy Hoernecke and Scott Behrens">
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<%= stylesheet_link_tag "ensnare/application", :media => "all" %>
|
|
12
|
+
<%= javascript_include_tag "ensnare/application" %>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
body {
|
|
16
|
+
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<!-- Fav and touch icons -->
|
|
23
|
+
<!-- Size should be 144 x 144 pixels -->
|
|
24
|
+
<%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
|
|
25
|
+
|
|
26
|
+
<!-- For iPhone with high-resolution Retina display: -->
|
|
27
|
+
<!-- Size should be 114 x 114 pixels -->
|
|
28
|
+
<%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
|
|
29
|
+
|
|
30
|
+
<!-- For first- and second-generation iPad: -->
|
|
31
|
+
<!-- Size should be 72 x 72 pixels -->
|
|
32
|
+
<%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
|
|
33
|
+
|
|
34
|
+
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
|
35
|
+
<!-- Size should be 57 x 57 pixels -->
|
|
36
|
+
<%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
|
|
37
|
+
|
|
38
|
+
<!-- For all other devices -->
|
|
39
|
+
<!-- Size should be 32 x 32 pixels -->
|
|
40
|
+
</head>
|
|
41
|
+
|
|
42
|
+
<body>
|
|
43
|
+
|
|
44
|
+
<div class="navbar navbar-inverse navbar-fixed-top">
|
|
45
|
+
<div class="navbar-inner">
|
|
46
|
+
<div class="container">
|
|
47
|
+
|
|
48
|
+
<a class="brand" href="http://getbootstrap.com/2.3.2/examples/starter-template.html#">Ensnare</a>
|
|
49
|
+
<div class="nav-collapse collapse">
|
|
50
|
+
<ul class="nav">
|
|
51
|
+
<li class=""><%= link_to('Mode', mode_path) %> </li>
|
|
52
|
+
<li class=""><%= link_to('Configuration', configs_path) %> </li>
|
|
53
|
+
<li class=""><%= link_to('Metrics', metrics_path) %> </li>
|
|
54
|
+
<li class=""><%= link_to('Violations', dashboard_violations_path) %> </li>
|
|
55
|
+
<li class=""></li>
|
|
56
|
+
|
|
57
|
+
</ul>
|
|
58
|
+
<div class="pull-right">
|
|
59
|
+
<% if Ensnare.mode == :enforce %>
|
|
60
|
+
<button type="button" class="btn btn-success disabled" id="activated" value="Save">
|
|
61
|
+
<span class="glyphicon icon-thumbs-up" id="iconed"> Ensnare Activated</span>
|
|
62
|
+
<% elsif Ensnare.mode == :log %>
|
|
63
|
+
<button type="button" class="btn btn-warning disabled" id="activated" value="Save">
|
|
64
|
+
<span class="glyphicon icon-pencil" id="iconed"> Log Only</span>
|
|
65
|
+
<% elsif Ensnare.mode == :disabled %>
|
|
66
|
+
<button type="button" class="btn btn-danger disabled" id="activated" value="Save">
|
|
67
|
+
<span class="glyphicon icon-thumbs-down" id="iconed"> Ensnare Disabled</span>
|
|
68
|
+
<% end %>
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
</div><!--/.nav-collapse -->
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
<%= yield %>
|
|
77
|
+
</body></html>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<!-- saved from url=(0060)http://getbootstrap.com/2.3.2/examples/starter-template.html -->
|
|
4
|
+
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<title><%= content_for?(:title) ? yield(:title) : "Ensnare" %></title>
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
|
|
9
|
+
<%= stylesheet_link_tag "ensnare/application", :media => "all" %>
|
|
10
|
+
<%= javascript_include_tag "ensnare/application" %>
|
|
11
|
+
|
|
12
|
+
<!-- <link rel="stylesheet" href="css/bootstrap-switch.css">
|
|
13
|
+
|
|
14
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
|
15
|
+
<script src="js/bootstrap-switch.js"></script>
|
|
16
|
+
|
|
17
|
+
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/1.7/bootstrap-switch.min.js"> </script>
|
|
18
|
+
<link href="css/bootstrap.css" rel="stylesheet">
|
|
19
|
+
<link rel="stylesheet" href="css/toggle-switch.css"> -->
|
|
20
|
+
<style>
|
|
21
|
+
body {
|
|
22
|
+
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<!-- Fav and touch icons -->
|
|
29
|
+
<!-- Size should be 144 x 144 pixels -->
|
|
30
|
+
<%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
|
|
31
|
+
|
|
32
|
+
<!-- For iPhone with high-resolution Retina display: -->
|
|
33
|
+
<!-- Size should be 114 x 114 pixels -->
|
|
34
|
+
<%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
|
|
35
|
+
|
|
36
|
+
<!-- For first- and second-generation iPad: -->
|
|
37
|
+
<!-- Size should be 72 x 72 pixels -->
|
|
38
|
+
<%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
|
|
39
|
+
|
|
40
|
+
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
|
41
|
+
<!-- Size should be 57 x 57 pixels -->
|
|
42
|
+
<%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
|
|
43
|
+
|
|
44
|
+
<!-- For all other devices -->
|
|
45
|
+
<!-- Size should be 32 x 32 pixels -->
|
|
46
|
+
</head>
|
|
47
|
+
|
|
48
|
+
<body>
|
|
49
|
+
<%= yield %>
|
|
50
|
+
</body>
|
|
51
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
|
2
|
+
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
|
3
|
+
|
|
4
|
+
en:
|
|
5
|
+
helpers:
|
|
6
|
+
actions: "Actions"
|
|
7
|
+
links:
|
|
8
|
+
back: "Back"
|
|
9
|
+
cancel: "Cancel"
|
|
10
|
+
confirm: "Are you sure?"
|
|
11
|
+
destroy: "Delete"
|
|
12
|
+
new: "New"
|
|
13
|
+
edit: "Edit"
|
|
14
|
+
titles:
|
|
15
|
+
edit: "Edit %{model}"
|
|
16
|
+
save: "Save %{model}"
|
|
17
|
+
new: "New %{model}"
|
|
18
|
+
delete: "Delete %{model}"
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Ensnare::Engine.routes.draw do
|
|
2
|
+
|
|
3
|
+
get "dashboard/metrics", to: "dashboard#metrics", :as=> 'metrics'
|
|
4
|
+
get "dashboard/mode", to: "dashboard#mode", :as=> 'mode'
|
|
5
|
+
get "dashboard/configuration", to: "dashboard#configs", :as=> 'configs'
|
|
6
|
+
get "dashboard/edit"
|
|
7
|
+
get "dashboard/violations", to: "dashboard#violations"
|
|
8
|
+
|
|
9
|
+
root to: "violations#redirect", :as=>:redir
|
|
10
|
+
match "violations/captcha", to: "violations#captcha", :as => 'captcha'
|
|
11
|
+
|
|
12
|
+
post "configuration/change_mode", to: "configuration#change_mode", as: 'change_mode'
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AddFieldsToViolation < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
add_column :ensnare_violations, :session_id, :string
|
|
4
|
+
add_column :ensnare_violations, :user_id, :string
|
|
5
|
+
add_column :ensnare_violations, :expected, :string
|
|
6
|
+
add_column :ensnare_violations, :observed, :string
|
|
7
|
+
end
|
|
8
|
+
end
|
data/lib/ensnare.rb
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
require "ensnare/engine"
|
|
2
|
+
|
|
3
|
+
module Ensnare
|
|
4
|
+
mattr_accessor :type
|
|
5
|
+
mattr_accessor :trap_on
|
|
6
|
+
mattr_accessor :mode
|
|
7
|
+
mattr_accessor :global_timer
|
|
8
|
+
mattr_accessor :enabled_traps
|
|
9
|
+
mattr_accessor :cookie_trap
|
|
10
|
+
mattr_accessor :cookie_names
|
|
11
|
+
mattr_accessor :randomizer
|
|
12
|
+
mattr_accessor :predefined_cookies
|
|
13
|
+
mattr_accessor :parameter_trap
|
|
14
|
+
mattr_accessor :parameter_names
|
|
15
|
+
mattr_accessor :predefined_parameters
|
|
16
|
+
mattr_accessor :thresholds
|
|
17
|
+
mattr_accessor :captcha_private_key
|
|
18
|
+
mattr_accessor :captcha_public_key
|
|
19
|
+
mattr_accessor :current_user_method
|
|
20
|
+
mattr_accessor :current_user_identifier
|
|
21
|
+
mattr_accessor :dashboard_user_method
|
|
22
|
+
mattr_accessor :dashboard_authorization_method
|
|
23
|
+
mattr_accessor :error_message
|
|
24
|
+
mattr_accessor :warning_message
|
|
25
|
+
mattr_accessor :testing
|
|
26
|
+
|
|
27
|
+
def self.setup
|
|
28
|
+
yield self
|
|
29
|
+
|
|
30
|
+
foo = validate_config
|
|
31
|
+
result = parse_thresholds
|
|
32
|
+
|
|
33
|
+
unless Ensnare.error_message.nil?
|
|
34
|
+
puts Ensnare.error_message
|
|
35
|
+
exit(1)
|
|
36
|
+
end
|
|
37
|
+
puts Ensnare.warning_message
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def self.validate_config
|
|
44
|
+
#Ensnare.error_message = ''
|
|
45
|
+
Ensnare.warning_message = ""
|
|
46
|
+
puts 'If you are having issues, please see the example configuration file located in: your_app/config/initalizers/ensnare.rb'
|
|
47
|
+
puts 'Validating ensnare config...'
|
|
48
|
+
# Check that these methods exist in the setup file
|
|
49
|
+
begin
|
|
50
|
+
no_method_check = [Ensnare.mode, Ensnare.trap_on, Ensnare.global_timer, Ensnare.enabled_traps]
|
|
51
|
+
rescue Exception => e
|
|
52
|
+
Ensnare.error_message = "no method error: " + e.message + ". You should have the following defined (exp. mode, trap_on, global_timer, enable_traps"
|
|
53
|
+
return false
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Look for methods that Ensnare database knows about but are nil
|
|
57
|
+
if Ensnare.mode.nil? || Ensnare.trap_on.nil? || Ensnare.global_timer.nil? || Ensnare.enabled_traps.nil?
|
|
58
|
+
Ensnare.error_message = "nil settings found: are you sure you have defined mode, trap_on, global_timer, enable_traps?"
|
|
59
|
+
return false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Check if a mode is set for Ensnare
|
|
63
|
+
unless [:enforce,:disable,:log].include?(Ensnare.mode)
|
|
64
|
+
Ensnare.error_message = ":mode error: you must specify either :enforce, :disable, or :log"
|
|
65
|
+
return false
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Check if user specified what to trap on
|
|
69
|
+
begin
|
|
70
|
+
Ensnare.trap_on.length.times do |i|
|
|
71
|
+
unless [:ip, :user, :session].include?(Ensnare.trap_on[i])
|
|
72
|
+
Ensnare.error_message = "trap_on error: you must specify :ip, :user, and/or :session"
|
|
73
|
+
return false
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
rescue
|
|
77
|
+
Ensnare.error_message = "trap_on error: you must have a trap_on config setting"
|
|
78
|
+
return false
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Checks to make sure a user idneitifer is set in conjunction with user method
|
|
82
|
+
if (Ensnare.current_user_method.nil?) and (Ensnare.current_user_identifier.nil? == false)
|
|
83
|
+
Ensnare.error_message = "current_user error: you cannot specificy an identifier without a user_method"
|
|
84
|
+
return false
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Make sure the global timer is an integer if it's set
|
|
88
|
+
unless Ensnare.global_timer.is_a? Integer
|
|
89
|
+
Ensnare.error_message = "global_timer error: the global timer must be an integer"
|
|
90
|
+
return false
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Check to make sure thresholds are defined
|
|
94
|
+
if Ensnare.thresholds.length <= 0
|
|
95
|
+
Ensnare.error_message = "thresholds error: you must have at least one threshold defined"
|
|
96
|
+
return false
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Capture the largest timer from thresholds to compare global timer
|
|
100
|
+
timers = []
|
|
101
|
+
biggest_threshold_timer = ""
|
|
102
|
+
# If thresholds do not have timers, throw an error
|
|
103
|
+
Ensnare.thresholds.each do |t|
|
|
104
|
+
if t[:timer].nil?
|
|
105
|
+
Ensnare.error_message = "threshold timer error: are you sure you set timers in your thresholds?"
|
|
106
|
+
return false
|
|
107
|
+
else
|
|
108
|
+
timers.push(t[:timer])
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Threshold validations
|
|
113
|
+
number_compare = 0
|
|
114
|
+
begin
|
|
115
|
+
responses = ["none", "message", "redirect", "redirect_loop", "throttle", "captcha", "not_found",
|
|
116
|
+
"server_error", "random_content", "block", "flash_error"]
|
|
117
|
+
|
|
118
|
+
# Throw an error if no tresholds are found
|
|
119
|
+
if Ensnare.thresholds.nil?
|
|
120
|
+
Ensnare.error_message = "threshold error: no thresholds defined"
|
|
121
|
+
return false
|
|
122
|
+
end
|
|
123
|
+
if Ensnare.thresholds.length <= 0
|
|
124
|
+
Ensnare.error_message = "threshold error: no thresholds defined"
|
|
125
|
+
return false
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Ensnare.thresholds.length.times do |i|
|
|
129
|
+
|
|
130
|
+
# Check that each threshold has a timer and it's valid
|
|
131
|
+
if Ensnare.thresholds[i][:timer].nil?
|
|
132
|
+
Ensnare.error_message = "threshold timer error: missing a threshold timer"
|
|
133
|
+
return false
|
|
134
|
+
end
|
|
135
|
+
if Ensnare.thresholds[i][:timer] <= 0
|
|
136
|
+
Ensnare.error_message = "threshold timer error: timer must be greater than 0"
|
|
137
|
+
return false
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Check that each threshold has a trap_count and is valid
|
|
141
|
+
if Ensnare.thresholds[i][:trap_count].nil?
|
|
142
|
+
Ensnare.error_message = "trap_count : missing a trap_count"
|
|
143
|
+
return false
|
|
144
|
+
end
|
|
145
|
+
if Ensnare.thresholds[i][:trap_count] <= 0
|
|
146
|
+
Ensnare.error_message = "trap_count error: trap_count must be greater than 0"
|
|
147
|
+
return false
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# This check ensures that each subsequent threshold has a larger trap count
|
|
151
|
+
if number_compare < Ensnare.thresholds[i][:trap_count]
|
|
152
|
+
number_compare = Ensnare.thresholds[i][:trap_count]
|
|
153
|
+
else
|
|
154
|
+
Ensnare.error_message = "trap_count error: the threshold trap_count of " + Ensnare.thresholds[i][:trap_count].to_s +
|
|
155
|
+
" is less then the previous trap_count of " + Ensnare.thresholds[i-1][:trap_count].to_s
|
|
156
|
+
return false
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Check that the response type is valid based on the responses we have coded
|
|
160
|
+
begin
|
|
161
|
+
Ensnare.thresholds[i][:traps].length.times do |p|
|
|
162
|
+
unless responses.include?(Ensnare.thresholds[i][:traps][p][:trap])
|
|
163
|
+
Ensnare.warning_message += "response type #{Ensnare.thresholds[i][:traps][p][:trap]} is not a built-in response. You are on your own for validation!\n"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
rescue Exception=>e
|
|
167
|
+
puts "#{e.message} #{e.backtrace}"
|
|
168
|
+
Ensnare.error_message = "trap threshold error: did you define any traps?"
|
|
169
|
+
return false
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
rescue
|
|
173
|
+
Ensnare.error_message = "threshold parsing: unknown error"
|
|
174
|
+
return false
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Check to make sure threshold timers are actually integers
|
|
178
|
+
begin
|
|
179
|
+
biggest_threshold_timer = timers.sort[-1]
|
|
180
|
+
rescue
|
|
181
|
+
Ensnare.error_message = "timer error: Check that you have integer timers set for thresholds"
|
|
182
|
+
return false
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# If global timer is smaller than biggest threshold timer, adjust and warn user
|
|
186
|
+
begin
|
|
187
|
+
if (Ensnare.global_timer <= biggest_threshold_timer)
|
|
188
|
+
Ensnare.global_timer = biggest_threshold_timer + 3600
|
|
189
|
+
Ensnare.warning_message += "global timer warning: global timer is too small, using " + Ensnare.global_timer.to_s + " as the default timer\n"
|
|
190
|
+
end
|
|
191
|
+
rescue
|
|
192
|
+
# If the global timer isn't specified, set global timer to biggest threshold time plus 5 minutes
|
|
193
|
+
Ensnare.global_timer = biggest_threshold_timer + 3600
|
|
194
|
+
Ensnare.warning_message += "global timer warning: no timer specified, using " + Ensnare.global_timer.to_s + " as the default timer\n"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Check to make sure at least one trap is enabled or configured
|
|
198
|
+
if Ensnare.enabled_traps.length == 0
|
|
199
|
+
Ensnare.error_message = "enabled traps error: You have no enabled traps defined"
|
|
200
|
+
return false
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# If something goes wrong when parsing enabled_traps, throw a generic error
|
|
204
|
+
begin
|
|
205
|
+
# This does not check for cookie_names or parameter_names
|
|
206
|
+
# Is there a better way to pull in predefined defaults?
|
|
207
|
+
predefined_defaults = [:admin, :random, :google, :uid, :gid, :debug]
|
|
208
|
+
Ensnare.enabled_traps.length.times do |i|
|
|
209
|
+
|
|
210
|
+
# Check if the trap type is built-in
|
|
211
|
+
unless [:cookie,:parameter,:routing_error,:reg_ex].include?(Ensnare.enabled_traps[i][:type])
|
|
212
|
+
Ensnare.warning_message += "trap type #{Ensnare.enabled_traps[i][:type]} is not a built-in type (:cookie, :parameter, :routing_error, :reg_ex). You are on your own for validation!\n"
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
begin
|
|
217
|
+
# Check if predefined cookies are correct
|
|
218
|
+
if Ensnare.enabled_traps[i][:type] == :cookie
|
|
219
|
+
if (Ensnare.enabled_traps[i][:options][:cookie_names].nil?) and (Ensnare.enabled_traps[i][:options][:predefined_cookies].nil?)
|
|
220
|
+
puts 'in here'
|
|
221
|
+
# At least one predfeined cookie or custom cookie needs to be defined
|
|
222
|
+
if (Ensnare.enabled_traps[i][:options][:cookie_names].length == 0) and (Ensnare.enabled_traps[i][:options][:predefined_cookies].length == 0)
|
|
223
|
+
Ensnare.error_message = "no cookies error: you need either a cookie_name or predefined_cookie specified"
|
|
224
|
+
return false
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
Ensnare.enabled_traps[i][:options][:predefined_cookies].each do |cookie_defaults|
|
|
228
|
+
unless predefined_defaults.include?(cookie_defaults)
|
|
229
|
+
Ensnare.error_message = "predefined cookie error: FILL ME IN WITH COOKIES"
|
|
230
|
+
return false
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
rescue
|
|
235
|
+
Ensnare.error_message = "trap cookie error: Do you have options defined (exp. cookie_names or predefined_cookies?)"
|
|
236
|
+
return false
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
begin
|
|
240
|
+
if Ensnare.enabled_traps[i][:type] == :parameter
|
|
241
|
+
# If both parameter_names and predefined_names are present, check to make sure that at least one has something defined
|
|
242
|
+
if (Ensnare.enabled_traps[i][:options][:parameter_names].nil?) and (Ensnare.enabled_traps[i][:options][:predefined_parameters].nil?)
|
|
243
|
+
if (Ensnare.enabled_traps[i][:options][:parameter_names].length == 0) and (Ensnare.enabled_traps[i][:options][:predefined_parameters].length == 0)
|
|
244
|
+
Ensnare.error_message = "no parameters error: you need either a predefined_parameter or parameter_name specified"
|
|
245
|
+
return false
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# If there are predefined_parameters, make sure they are really 'predefined'
|
|
250
|
+
if (Ensnare.enabled_traps[i][:options][:predefined_parameters].length >= 0)
|
|
251
|
+
Ensnare.enabled_traps[i][:options][:predefined_parameters].each do |parameter_defaults|
|
|
252
|
+
unless predefined_defaults.include?(parameter_defaults)
|
|
253
|
+
Ensnare.error_message = "predefined parameter error: are you sure you have a valid parameter?"
|
|
254
|
+
return false
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
rescue
|
|
260
|
+
# General error catch for misconfigured parameters
|
|
261
|
+
Ensnare.error_message = "Trap parameter error: Do you have options defined (exp. cookie_names or predefined_cookies?)"
|
|
262
|
+
return false
|
|
263
|
+
end
|
|
264
|
+
# begin
|
|
265
|
+
begin
|
|
266
|
+
if Ensnare.enabled_traps[i][:type] == :routing_error
|
|
267
|
+
Ensnare.enabled_traps[i][:options][:bad_paths].each do |path|
|
|
268
|
+
unless /^\/[a-z0-9]+([\-\_]{1}[a-z0-9]+)*|\/[a-z0-9]+([\-\_]{1}[a-z0-9]+)?$/ =~ path
|
|
269
|
+
Ensnare.warning_message += "routing warning: Invalid path (" + path + ") and will be ignored"
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
rescue Exception => e
|
|
274
|
+
Ensnare.error_message = "Trap error: Do you have options and bad_paths defined?"
|
|
275
|
+
return false
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
rescue
|
|
279
|
+
Ensnare.error_message = 'Trap types error: some sort of unkonwn error'
|
|
280
|
+
return false
|
|
281
|
+
end
|
|
282
|
+
puts 'Validation succeeded.'
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def self.parse_thresholds
|
|
286
|
+
|
|
287
|
+
Ensnare.thresholds.each do |t|
|
|
288
|
+
|
|
289
|
+
if(t[:traps].find_all{|x| x[:persist] != true}.map{|x| x[:weight]}.include?(nil))
|
|
290
|
+
Rails.logger.error "No weight found. Defaulting to even weight"
|
|
291
|
+
t[:traps].find_all{|x| x[:persist] != true}.each do |x|
|
|
292
|
+
x[:weight] = 1
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
total_weight = t[:traps].find_all{|x| x[:persist] != true}.map{|x| x[:weight]}.sum
|
|
297
|
+
|
|
298
|
+
cumulative_weight = 0
|
|
299
|
+
t[:traps].find_all{|x| x[:persist] != true}.each { |x|
|
|
300
|
+
x[:weight] = cumulative_weight+=(1.0/total_weight)*x[:weight];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
end
|
|
306
|
+
end
|