Restrict methods accessible from javascript on python objects
-
Paul J. Davis
- State changed from new to open
- Tag set to python, wrapping
- Milestone set to Version 0.1.0
Richard,
Sorry it took me so long to respond to this. I had it on the todo list and then lost the list. :/
The parts of the code that you'd need to look at are the bits in spidermonkey/context.c where the global handler is registered and consulted for attributes. This would be a good example of how to add the infrastructure for having a access handler. Once you have that registration working, it should only be a matter of adding checks before python objects are consulted which should be semi-localized to spidermonkey/context.c:get_prop and spidermonkey/pyobject.c:js_get_prop
Let me know if you need anything else.
-
Richard Boulton
I've put together an initial implementation of this, thanks to your hints, and it just about works, I think!
It needs more testing, and a bit of an audit to check if this catches everything, but it feels like a nice approach for this.
-
Paul J. Davis
That looks right in line with what I was thinking. I've just read through the diff so I might be missing bits, but it looks like a call to check_key_access is missing in context.c when grabbing data from the global handler.
I'll go through this more thoroughly tomorrow and get it committed. Thanks for your help.
Paul
-
Richard Boulton
I assume you're referring to adding a check somewhere in context.c:get_prop() - around line 95, just before PyObject_GetItem. That's probably a good idea, yes.
I've tried implementing this, but am currently getting a segfault from my effort. My code's in my fork at http://github.com/rboulton/python-spidermonkey/tree/master , in case it's of any help to you (I'm going out now, so won't be able to look at it any further for a while).
-
Paul J. Davis
- State changed from open to resolved
Forgot to do the state update in the commit. Filtering access should now work:
http://github.com/davisp/python-spidermonkey/commit/e8e69e9f5644907...
I uploaded a 0.0.7 version to PyPi in case people prefer that.
Thanks for the patch Richard.
-
Richard Boulton
Excellent - your updated patch all looks good here. Thanks for tidying up (lots!) and applying so quickly. :)
-
Paul J. Davis
No problem. If you have time, try and think of more tests. I get the feeling I'm missing edge cases but I'm lacking the creativity to figure out what they might be.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
