0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Secure Rails parameters by default
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

 Project Readme

Scrub Params

đź”’ Safer Rails parameters by default

JavaScript and HTML have no business in most parameters. Take the whitelist approach and remove them by default.

Note: Rails does amazing work to prevent cross-site scripting (XSS), but storing <script>badThings()</script> in your database makes it much easier to make mistakes.

Works with Rails 3.2 and above

Get Started

Add this line to your application’s Gemfile:

gem 'scrub_params'

You now have another line of defense against XSS.

Test It

Submit HTML in one of your forms.

Hello <script>alert('World')</script>

This becomes:

Hello alert('World')

And you should see this in your logs:

Scrubbed parameters: name

Original Parameters

Access the original parameters with:

unscrubbed_params

Whitelist Actions

To skip scrubbing for certain actions, use:

skip_before_filter :scrub_params, only: [:create, :update]

TODO

  • whitelist parameters
  • whitelist tags

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: