public
Description: Ruby on Rails Plugin that automatically wraps html_escape() around ActiveRecord attribute methods associated with string and text fields in the database.
Homepage:
Clone URL: git://github.com/wwidea/cross_site_sniper.git
jsgarvin (author)
Tue Feb 17 21:08:36 -0800 2009
commit  abe6bd2c491ac2b3e35d97c0fb205f5e83868403
tree    2f6950cf9cb911c3a0366752e6a6694397e84b03
parent  0791bd6cc2eb0ebe5a4077b0dac503f23c2a1a31
name age message
file MIT-LICENSE Tue Jan 29 08:22:58 -0800 2008 Initial import. [jsgarvin]
file README Tue Feb 17 21:08:36 -0800 2009 update readme with github installation instruct... [jsgarvin]
file Rakefile Wed Jan 30 09:13:35 -0800 2008 add tests [jsgarvin]
file init.rb Wed Jan 30 14:17:04 -0800 2008 Add ability to fine tune which fields get autom... [jsgarvin]
directory lib/ Tue Feb 17 21:05:45 -0800 2009 Fix turning off escaping on methods that call o... [jsgarvin]
directory test/ Tue Feb 17 21:05:45 -0800 2009 Fix turning off escaping on methods that call o... [jsgarvin]
README
= Cross Site Sniper (XSS)

Cross Site Sniper is a Ruby on Rails Plugin that automatically wraps html_escape() around 
ActiveRecord attribute methods associated with string and text fields in the
database.  This provides a convenient and DRY method to protect a Rails site from Cross
Site Scripting (XSS) attacks from malicious users.

Data used to pre-populate form fields is *not* auto escaped, allowing for user friendly
legitimate uses of normally escaped characters and painless integration into 
existing Rails applications without modifying forms or controllers.

You will probably want to remove any calls to h() in helpers and views, otherwise fields
will be double escaped. This will only be of concern however in cases of legitimate uses of
escaped characters, where, for instance, users may actually see '&' displayed on a webpage
instead of an expected '&'.

See the html_escape[link:classes/ActiveRecord/CrossSiteSniperExtensions/ClassMethods.html#M000001] method to fine tune 
which fields to automatically escape.

== Example

=== Before Cross Site Sniper

* @user.first_name  => "Haxor<script>alert('Gotcha!')</script>"

=== After Cross Site Sniper

Attribute Methods are Automatically Escaped
* @user.first_name => "Haxor&lt;script&gt;alert('Gotcha!')&lt;/script&gt;"

Two convenient ways to get at the unescaped data when needed.
* @user.first_name_without_html_escaping => "HaXor<script>alert('Gotcha!')</script>"
* @quiz[:question] => "True or False, 5/8 < 3/5?"

By not escaping data accessed via the hash method (eg. @quiz[:question]), forms
prepopulate with the *unescaped* data, allowing user friendly legitimate uses of
usually escaped characters. 

Cross Site Sniper also supports calling <method_name>_without_html_escaping on
non-column methods to temporarily disable html escaping for that method call.
(eg. @person.some_computed_value_without_html_escaping)
== Installation

  script/plugin install git://github.com/wwidea/cross_site_sniper.git

== Copyright

Copyright (c) 2008 World Wide IDEA, Inc., released under the MIT license. [ http://www.wwidea.org ]