TryGhost/Ghost — pull request #2679 by appleYaks (2014-05-02 05:46:29+00:00)
Title: Sanitize models' attributes/options before passing to bookshelf/knex

This isn't necessarily ready-to-merge right away. I took Hannah's advice and kept BaseModel as strict as possible, by porting methods from Base over to each model where it made logical sense to me. The only place where Base accepts an option is in `base#findOne` since many models use `transacting` as an option. In some cases I had to remove calls to the Base parent methods and copy such functionality in order to keep Base clean.

I added a class method `base#permittedAttributes` that pulls the schema attributes from a method of the same name on its prototype, in order to filter them where I saw it was needed. I recreated this function on the PostModel as it seems `tags` is a necessary attribute for at least one test, but it's not listed in the schema. It's manually added to the whitelist in that case.

Please let me know if you see any issues with this PR. I wanted to add tests, but thought I'd leave it up to discussion how I might best accomplish it. In many cases trying to use certain options that are necessary but not yet whitelisted causes tests to timeout without any indication that the whitelist is the issue.