Closed Bug 655921 Opened 14 years ago Closed 14 years ago

Do CSP checks fast and early in Function function

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla6

People

(Reporter: Waldo, Assigned: Waldo)

References

(Depends on 1 open bug)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

Attached patch PatchSplinter Review
Right now Function creates the function it'll return (minus its script), then it does CSP checks to see whether to reject the attempt to create dynamic code. And it does this by unconditionally calling the security callback, when it really should use GlobalObject::isEvalAllowed to take advantage of its cache of the eval-prohibited setting. It should check for prohibition first, then proceed to creating an object to return, and it should do so using the is-prohibited fast path. This builds atop bug 655192 and bug 655907 for no particular reason beyond adding a new explicit-global NewFunction overload, which is the direction we need to start heading for all APIs that can create an object, in order to eventually fully fix bug 631135. I trust the minimal reliance on those patches (for the obviously-named GlobalObject::getOrCreateFunctionPrototype) won't present a difficulty.
Attachment #531225 - Flags: review?(mrbkap)
It was tempting to rename isEvalAllowed, but that made the overlap with the other two bugs a bit more than I wanted, before those bugs land. That can be a followup or something, probably touches enough code to deserve it.
Comment on attachment 531225 [details] [diff] [review] Patch I was just going to suggest changing the function name when I saw comment 1!
Attachment #531225 - Flags: review?(mrbkap) → review+
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla6
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: