Merge pull request #246 from rposborne/params-filtering

Add params filtering on new column.
This commit is contained in:
Jonas Grau 2017-06-02 10:12:38 +02:00 committed by GitHub
commit e818c21dd3
2 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,7 @@ module ImpressionistController
# creates a statment hash that contains default values for creating an impression via an AR relation. # creates a statment hash that contains default values for creating an impression via an AR relation.
def associative_create_statement(query_params={}) def associative_create_statement(query_params={})
filter = ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
query_params.reverse_merge!( query_params.reverse_merge!(
:controller_name => controller_name, :controller_name => controller_name,
:action_name => action_name, :action_name => action_name,
@ -59,7 +60,7 @@ module ImpressionistController
:session_hash => session_hash, :session_hash => session_hash,
:ip_address => request.remote_ip, :ip_address => request.remote_ip,
:referrer => request.referer, :referrer => request.referer,
:params => params_hash :params => filter.filter(params_hash)
) )
end end

View File

@ -71,4 +71,20 @@ describe ArticlesController do
Impression.last.session_hash.size.should eq 32 Impression.last.session_hash.size.should eq 32
Impression.last.referrer.should eq nil Impression.last.referrer.should eq nil
end end
describe "when filtering params" do
before do
@_filtered_params = Rails.application.config.filter_parameters
Rails.application.config.filter_parameters = [:password]
end
it "values should not be recorded" do
get "index", password: "best-password-ever"
Impression.last.params.should eq("password" => "[FILTERED]")
end
after do
Rails.application.config.filter_parameters = @_filtered_params
end
end
end end