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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_attributes.py

Issue 2439013002: Implement cross-origin attributes using access check interceptors. (Closed)
Patch Set: . Created 4 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
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 idl_type = attribute.idl_type 62 idl_type = attribute.idl_type
63 base_idl_type = idl_type.base_type 63 base_idl_type = idl_type.base_type
64 extended_attributes = attribute.extended_attributes 64 extended_attributes = attribute.extended_attributes
65 65
66 idl_type.add_includes_for_type(extended_attributes) 66 idl_type.add_includes_for_type(extended_attributes)
67 if idl_type.enum_values: 67 if idl_type.enum_values:
68 includes.add('core/inspector/ConsoleMessage.h') 68 includes.add('core/inspector/ConsoleMessage.h')
69 69
70 # [CheckSecurity] 70 # [CheckSecurity]
71 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes 71 is_cross_origin = 'CrossOrigin' in extended_attributes
72 is_check_security_for_receiver = ( 72 is_check_security_for_receiver = (
73 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and 73 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and
74 not is_do_not_check_security) 74 not is_cross_origin)
dcheng 2016/11/02 01:46:42 I'm not sure this is actually necessary: it seems
haraken 2016/11/02 04:30:32 Yeah, agreed. Let's make the change in a separate
dcheng 2016/11/02 07:45:32 Added a TODO back.
75 is_check_security_for_return_value = ( 75 is_check_security_for_return_value = (
76 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue')) 76 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue'))
77 if is_check_security_for_receiver or is_check_security_for_return_value: 77 if is_check_security_for_receiver or is_check_security_for_return_value:
78 includes.add('bindings/core/v8/BindingSecurity.h') 78 includes.add('bindings/core/v8/BindingSecurity.h')
79 # [CrossOrigin]
80 if has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'):
81 includes.add('bindings/core/v8/V8CrossOriginSetterInfo.h')
79 # [Constructor] 82 # [Constructor]
80 # TODO(yukishiino): Constructors are much like methods although constructors 83 # TODO(yukishiino): Constructors are much like methods although constructors
81 # are not methods. Constructors must be data-type properties, and we can 84 # are not methods. Constructors must be data-type properties, and we can
82 # support them as a kind of methods. 85 # support them as a kind of methods.
83 constructor_type = idl_type.constructor_type_name if is_constructor_attribut e(attribute) else None 86 constructor_type = idl_type.constructor_type_name if is_constructor_attribut e(attribute) else None
84 # [CEReactions] 87 # [CEReactions]
85 is_ce_reactions = 'CEReactions' in extended_attributes 88 is_ce_reactions = 'CEReactions' in extended_attributes
86 if is_ce_reactions: 89 if is_ce_reactions:
87 includes.add('core/dom/custom/CEReactionsScope.h') 90 includes.add('core/dom/custom/CEReactionsScope.h')
88 # [CustomElementCallbacks], [Reflect] 91 # [CustomElementCallbacks], [Reflect]
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 129 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
127 'cached_attribute_validation_method': cached_attribute_validation_method , 130 'cached_attribute_validation_method': cached_attribute_validation_method ,
128 'constructor_type': constructor_type, 131 'constructor_type': constructor_type,
129 'cpp_name': cpp_name(attribute), 132 'cpp_name': cpp_name(attribute),
130 'cpp_type': idl_type.cpp_type, 133 'cpp_type': idl_type.cpp_type,
131 'cpp_type_initializer': idl_type.cpp_type_initializer, 134 'cpp_type_initializer': idl_type.cpp_type_initializer,
132 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 135 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
133 'enum_type': idl_type.enum_type, 136 'enum_type': idl_type.enum_type,
134 'enum_values': idl_type.enum_values, 137 'enum_values': idl_type.enum_values,
135 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 138 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
139 'has_cross_origin_getter': has_extended_attribute_value(attribute, 'Cros sOrigin', None),
dcheng 2016/11/02 01:46:42 I'm not actually sure if it's OK to make this mutu
140 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'Cros sOrigin', 'Setter'),
136 'has_custom_getter': has_custom_getter(attribute), 141 'has_custom_getter': has_custom_getter(attribute),
137 'has_custom_setter': has_custom_setter(attribute), 142 'has_custom_setter': has_custom_setter(attribute),
138 'has_setter': has_setter(interface, attribute), 143 'has_setter': has_setter(interface, attribute),
139 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 144 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
140 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 145 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'),
141 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'), 146 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
142 'is_ce_reactions': is_ce_reactions, 147 'is_ce_reactions': is_ce_reactions,
143 'is_check_security_for_receiver': is_check_security_for_receiver, 148 'is_check_security_for_receiver': is_check_security_for_receiver,
144 'is_check_security_for_return_value': is_check_security_for_return_value , 149 'is_check_security_for_return_value': is_check_security_for_return_value ,
145 'is_custom_element_callbacks': is_custom_element_callbacks, 150 'is_custom_element_callbacks': is_custom_element_callbacks,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 # [PutForwards], [Replaceable] 530 # [PutForwards], [Replaceable]
526 def has_setter(interface, attribute): 531 def has_setter(interface, attribute):
527 if (is_data_type_property(interface, attribute) and 532 if (is_data_type_property(interface, attribute) and
528 (is_constructor_attribute(attribute) or 533 (is_constructor_attribute(attribute) or
529 'Replaceable' in attribute.extended_attributes)): 534 'Replaceable' in attribute.extended_attributes)):
530 return False 535 return False
531 536
532 return is_writable(attribute) 537 return is_writable(attribute)
533 538
534 539
535 # [DoNotCheckSecurity], [Unforgeable] 540 # [Unforgeable]
536 def access_control_list(interface, attribute): 541 def access_control_list(interface, attribute):
537 extended_attributes = attribute.extended_attributes 542 extended_attributes = attribute.extended_attributes
538 access_control = [] 543 access_control = []
539 if 'DoNotCheckSecurity' in extended_attributes:
540 do_not_check_security = extended_attributes['DoNotCheckSecurity']
541 if do_not_check_security == 'Setter':
542 access_control.append('v8::ALL_CAN_WRITE')
543 else:
544 access_control.append('v8::ALL_CAN_READ')
545 if has_setter(interface, attribute):
546 access_control.append('v8::ALL_CAN_WRITE')
547 if is_unforgeable(interface, attribute): 544 if is_unforgeable(interface, attribute):
548 access_control.append('v8::PROHIBITS_OVERWRITING') 545 access_control.append('v8::PROHIBITS_OVERWRITING')
549 return access_control or ['v8::DEFAULT'] 546 return access_control or ['v8::DEFAULT']
550 547
551 548
552 # [NotEnumerable], [Unforgeable] 549 # [NotEnumerable], [Unforgeable]
553 def property_attributes(interface, attribute): 550 def property_attributes(interface, attribute):
554 extended_attributes = attribute.extended_attributes 551 extended_attributes = attribute.extended_attributes
555 property_attributes_list = [] 552 property_attributes_list = []
556 if ('NotEnumerable' in extended_attributes or 553 if ('NotEnumerable' in extended_attributes or
(...skipping 30 matching lines...) Expand all
587 lambda self: strip_suffix(self.base_type, 'Constructor')) 584 lambda self: strip_suffix(self.base_type, 'Constructor'))
588 585
589 586
590 def is_constructor_attribute(attribute): 587 def is_constructor_attribute(attribute):
591 # FIXME: replace this with [ConstructorAttribute] extended attribute 588 # FIXME: replace this with [ConstructorAttribute] extended attribute
592 return attribute.idl_type.name.endswith('Constructor') 589 return attribute.idl_type.name.endswith('Constructor')
593 590
594 591
595 def update_constructor_attribute_context(interface, attribute, context): 592 def update_constructor_attribute_context(interface, attribute, context):
596 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 593 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698