I like your analogy to toys and children, except that the danger of these toys is not immediately apparent to adults either. But the toy company has been very prompt and transparent in finding ways for people to avoid the danger once it becomes apparent.
Can you give a concrete example of this?
So in ActionController::Metal (a superclass of ActionController::Base) you have:
def params
@_params ||= request.params
end
which is simply a case of a method in a super class being called in a subclass in your controller action. The rack request object in turn provides: def params
@params ||= self.GET.merge(self.POST)
rescue EOFError
self.GET
end
The Rack request object itself does the things you describe with GET/POST in each respective method.A few points:
* It took me about 25 seconds to find this code.
* Making a method available in a subclass doesn't strike me as magic, its just inheritance.
* Aside from the aforementioned inheritance "magic", the rest of the things you described come from Rack, not Rails.
The condescending attitude is not necessary. I never claimed that it is somehow impossible or prohibitively difficult to determine how things in Rails work - it is very possible and I do it myself all the time. What I claimed is that Rails has chosen abstraction over obviousness, and gave an example of a place where I believe that is demonstrated.
People usually inherit from AC::Base, not AC::Metal, which includes a number of modules, any of which may change the behavior of `params`.
You didn't take your expose far enough. As I mentioned in my post, `params` is an already-parsed representation of user data. You traced the call chain a couple of steps, but did not get to the point where parameters are actually parsed.
That's fine, I'm not at all interested in the specifics of how parameter parsing works, and I'm certain that you or I could go track it down when necessary. My point is only that it involves a number of layers of abstraction to get there - cataloging those layers is not a very compelling counterpoint.
1. Provide the action with the raw request body as a string. It is then solely responsible for any and all parsing.
2. Provide the action with the raw request body as a string, but provide standard parsing classes that the action can use depending on what they are specifically doing.
Both of those solutions would make the parsing code less abstract than the Rails solution, with different trade-offs.
I believe this entire thread started because I claimed that Rails has chosen to be further toward the abstraction side of the scale. I can't tell if you really think I am wrong about that, or if you merely think that the choice Rails has made is the right one. If it's the latter, I agree with you, and never claimed otherwise. But it is a choice, and it has trade-offs.
Not even security related. If I decide to move from rails to django, now I have to wonder if somebody out there decided to talk to my app using json instead of regular get/post, and deal with migrating/breaking that client.
If you didn't publicly document the fact that you accept a particular format you have no obligation to continue supporting it.
Your point about the XML stands though, that sucked!
All software deals in layers of abstraction, which makes it easier to reason about general function, but obscures specific function. All users of all software must make a constant trade-off between assuming abstractions are functioning properly and personally verifying their function, and all software must decide where the line between too little abstraction and too much obscurity should be drawn. When people talk about the "magic" in Rails, they mean that Rails has drawn that line quite far toward the abstraction side, which is true.
There are some abstractions that are a net positive for security, and some that hinder it. While I don't agree with the condescending attitude of your parent and the many similar commenters, who seem to think no software they've ever written or integrated with has ever had a security issue, I think it is fair at this point to say that the level of abstraction in Rails' handling of user data has been a hindrance to its security. I think that is probably also a fair thing to say about most pieces of software that have ever handled potentially-malicious user data.