Skip to content

Scrub file_data from logs #270

Closed
bamnet opened this Issue Jan 3, 2013 · 6 comments

2 participants

@bamnet
Concerto Digital Signage member
bamnet commented Jan 3, 2013

file_data should never be logged, this fills logs with binary content for the media table.

Usually this is logged in development mode as part of an INSERT sql statement against the medias table, like:

INSERT INTO "media" ("attachable_id", "attachable_type", "created_at", "file_data", "file_name", "file_size", "file_type", "key", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) [["attachable_id", 12], ["attachable_type", "Content"], ["created_at", Thu, 03 Jan 2013 04:20:45 UTC +00:00], ["file_data", "<?xml version=\"1.0\"?>\n\n BlueSwoo........ <>

@kench kench closed this in 6ab80ea Jan 3, 2013
@bamnet
Concerto Digital Signage member
bamnet commented Jan 3, 2013

This doesn't work for me, I believe config.filter_parameters only applies to controller-level params hash, not the underlying SQL INSERT statement.

I clarified the initial bug a bit.

@bamnet bamnet reopened this Jan 3, 2013
@kench
Concerto Digital Signage member
kench commented Jan 3, 2013

That's bit more complicated than I assumed. Does the following regex /\["file_data", ".*, \["file_name/ as input into gsub() look good for capturing the file data?

@bamnet
Concerto Digital Signage member
bamnet commented Jan 3, 2013

LGTM. Do test the performance with a larger file, I'd be interested to see if Rails OOMs

@kench kench closed this in c275113 Jan 3, 2013
@kench
Concerto Digital Signage member
kench commented Jan 3, 2013

I tested the scrubber with a high-resolution JPEG from a hockey game.

@bamnet
Concerto Digital Signage member
bamnet commented Jan 3, 2013

Thanks @kench, this is great!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.