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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 break; 259 break;
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264 Top::ReportFailedAccessCheck(this, v8::ACCESS_GET); 264 Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
265 return Heap::undefined_value(); 265 return Heap::undefined_value();
266 } 266 }
267 267
268 268
269 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
270 Object* receiver,
Mads Ager (chromium) 2008/10/28 20:02:38 Parameters should be indented by four spaces inste
271 LookupResult* result,
272 String* name) {
273 if (result->IsValid()) {
274 switch (result->type()) {
275 case CALLBACKS: {
276 // Only allow API accessors.
277 Object* obj = result->GetCallbackObject();
278 if (obj->IsAccessorInfo()) {
279 AccessorInfo* info = AccessorInfo::cast(obj);
280 if (info->all_can_read()) {
281 return result->GetAttributes();
282 }
283 }
284 break;
285 }
286 case NORMAL:
287 case FIELD:
288 case CONSTANT_FUNCTION: {
Mads Ager (chromium) 2008/10/28 20:02:38 I think you might have to pass in a boolean indica
289 // Search ALL_CAN_READ accessors in prototype chain.
290 LookupResult r;
291 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r);
292 if (r.IsValid()) {
293 return GetPropertyAttributeWithFailedAccessCheck(receiver, &r, name);
294 }
295 break;
296 }
297 case INTERCEPTOR: {
298 // If the object has an interceptor, try real named properties.
299 // No access check in GetPropertyAttributeWithInterceptor.
300 LookupResult r;
301 result->holder()->LookupRealNamedProperty(name, &r);
Mads Ager (chromium) 2008/10/28 20:02:38 Similarly here, we probably need the boolean indic
302 if (r.IsValid()) {
303 return GetPropertyAttributeWithFailedAccessCheck(receiver, &r, name);
304 }
305 break;
306 }
307 default: {
308 break;
309 }
310 }
311 }
312
313 Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
314 return ABSENT;
315 }
316
317
269 Object* JSObject::GetLazyProperty(Object* receiver, 318 Object* JSObject::GetLazyProperty(Object* receiver,
270 LookupResult* result, 319 LookupResult* result,
271 String* name, 320 String* name,
272 PropertyAttributes* attributes) { 321 PropertyAttributes* attributes) {
273 HandleScope scope; 322 HandleScope scope;
274 Handle<Object> this_handle(this); 323 Handle<Object> this_handle(this);
275 Handle<Object> receiver_handle(receiver); 324 Handle<Object> receiver_handle(receiver);
276 Handle<String> name_handle(name); 325 Handle<String> name_handle(name);
277 bool pending_exception; 326 bool pending_exception;
278 LoadLazy(Handle<JSFunction>(JSFunction::cast(result->GetValue())), 327 LoadLazy(Handle<JSFunction>(JSFunction::cast(result->GetValue())),
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 } 1762 }
1714 1763
1715 1764
1716 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver, 1765 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver,
1717 LookupResult* result, 1766 LookupResult* result,
1718 String* name, 1767 String* name,
1719 bool continue_search) { 1768 bool continue_search) {
1720 // Check access rights if needed. 1769 // Check access rights if needed.
1721 if (IsAccessCheckNeeded() && 1770 if (IsAccessCheckNeeded() &&
1722 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) { 1771 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
1723 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 1772 return GetPropertyAttributeWithFailedAccessCheck(receiver, result, name);
Mads Ager (chromium) 2008/10/28 20:02:38 I think we need to propagate the continue_search a
1724 return ABSENT;
1725 } 1773 }
1726 if (result->IsValid()) { 1774 if (result->IsValid()) {
1727 switch (result->type()) { 1775 switch (result->type()) {
1728 case NORMAL: // fall through 1776 case NORMAL: // fall through
1729 case FIELD: 1777 case FIELD:
1730 case CONSTANT_FUNCTION: 1778 case CONSTANT_FUNCTION:
1731 case CALLBACKS: 1779 case CALLBACKS:
1732 return result->GetAttributes(); 1780 return result->GetAttributes();
1733 case INTERCEPTOR: 1781 case INTERCEPTOR:
1734 return result->holder()-> 1782 return result->holder()->
(...skipping 4989 matching lines...) Expand 10 before | Expand all | Expand 10 after
6724 // No break point. 6772 // No break point.
6725 if (break_point_objects()->IsUndefined()) return 0; 6773 if (break_point_objects()->IsUndefined()) return 0;
6726 // Single beak point. 6774 // Single beak point.
6727 if (!break_point_objects()->IsFixedArray()) return 1; 6775 if (!break_point_objects()->IsFixedArray()) return 1;
6728 // Multiple break points. 6776 // Multiple break points.
6729 return FixedArray::cast(break_point_objects())->length(); 6777 return FixedArray::cast(break_point_objects())->length();
6730 } 6778 }
6731 6779
6732 6780
6733 } } // namespace v8::internal 6781 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698