Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: src/objects.cc

Issue 8834: Introduce access control in propertyIsEnumerable.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 620)
+++ src/objects.cc (working copy)
@@ -266,6 +266,55 @@
}
+PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
+ Object* receiver,
Mads Ager (chromium) 2008/10/28 20:02:38 Parameters should be indented by four spaces inste
+ LookupResult* result,
+ String* name) {
+ if (result->IsValid()) {
+ switch (result->type()) {
+ case CALLBACKS: {
+ // Only allow API accessors.
+ Object* obj = result->GetCallbackObject();
+ if (obj->IsAccessorInfo()) {
+ AccessorInfo* info = AccessorInfo::cast(obj);
+ if (info->all_can_read()) {
+ return result->GetAttributes();
+ }
+ }
+ break;
+ }
+ case NORMAL:
+ case FIELD:
+ case CONSTANT_FUNCTION: {
Mads Ager (chromium) 2008/10/28 20:02:38 I think you might have to pass in a boolean indica
+ // Search ALL_CAN_READ accessors in prototype chain.
+ LookupResult r;
+ result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
+ if (r.IsValid()) {
+ return GetPropertyAttributeWithFailedAccessCheck(receiver, &r, name);
+ }
+ break;
+ }
+ case INTERCEPTOR: {
+ // If the object has an interceptor, try real named properties.
+ // No access check in GetPropertyAttributeWithInterceptor.
+ LookupResult r;
+ result->holder()->LookupRealNamedProperty(name, &r);
Mads Ager (chromium) 2008/10/28 20:02:38 Similarly here, we probably need the boolean indic
+ if (r.IsValid()) {
+ return GetPropertyAttributeWithFailedAccessCheck(receiver, &r, name);
+ }
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+
+ Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
+ return ABSENT;
+}
+
+
Object* JSObject::GetLazyProperty(Object* receiver,
LookupResult* result,
String* name,
@@ -1720,8 +1769,7 @@
// Check access rights if needed.
if (IsAccessCheckNeeded() &&
!Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
- return ABSENT;
+ return GetPropertyAttributeWithFailedAccessCheck(receiver, result, name);
Mads Ager (chromium) 2008/10/28 20:02:38 I think we need to propagate the continue_search a
}
if (result->IsValid()) {
switch (result->type()) {

Powered by Google App Engine
This is Rietveld 408576698