Changeset 106618 in webkit


Ignore:
Timestamp:
Feb 2, 2012 7:23:45 PM (12 years ago)
Author:
abarth@webkit.org
Message:

Rename checkNodeSecurity and allowsAccessFromFrame to have sensible names
https://bugs.webkit.org/show_bug.cgi?id=75796

Reviewed by Eric Seidel.

As requested by Darin Adler, this patch renames these functions be
clear that we're asking whether the access should be allowed rather
than explicitly allowing the access.

  • bindings/generic/BindingSecurity.h:

(BindingSecurity):
(WebCore::::shouldAllowAccessToNode):
(WebCore::::allowSettingFrameSrcToJavascriptUrl):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::shouldAllowAccessToNode):
(WebCore::shouldAllowAccessToFrame):

  • bindings/js/JSDOMBinding.h:

(WebCore):

  • bindings/js/JSHTMLFrameElementCustom.cpp:

(WebCore::allowSettingJavascriptURL):

  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::getOwnPropertySlotDelegate):
(WebCore::JSHistory::getOwnPropertyDescriptorDelegate):
(WebCore::JSHistory::putDelegate):
(WebCore::JSHistory::deleteProperty):
(WebCore::JSHistory::getOwnPropertyNames):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::getOwnPropertySlotDelegate):
(WebCore::JSLocation::getOwnPropertyDescriptorDelegate):
(WebCore::JSLocation::putDelegate):
(WebCore::JSLocation::deleteProperty):
(WebCore::JSLocation::getOwnPropertyNames):
(WebCore::JSLocation::toStringFunction):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::canAccessFromCurrentOrigin):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateGetOwnPropertyDescriptorBody):
(GenerateImplementation):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateNormalAttrGetter):
(GenerateFunctionCallback):

  • bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:

(WebCore::JSTestActiveDOMObject::getOwnPropertyDescriptor):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjContentDocument):
(WebCore::jsTestObjPrototypeFunctionGetSVGDocument):

  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::TestObjInternal::contentDocumentAttrGetter):
(WebCore::TestObjInternal::getSVGDocumentCallback):

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106615 r106618  
     12012-02-02  Adam Barth  <abarth@webkit.org>
     2
     3        Rename checkNodeSecurity and allowsAccessFromFrame to have sensible names
     4        https://bugs.webkit.org/show_bug.cgi?id=75796
     5
     6        Reviewed by Eric Seidel.
     7
     8        As requested by Darin Adler, this patch renames these functions be
     9        clear that we're asking whether the access should be allowed rather
     10        than explicitly allowing the access.
     11
     12        * bindings/generic/BindingSecurity.h:
     13        (BindingSecurity):
     14        (WebCore::::shouldAllowAccessToNode):
     15        (WebCore::::allowSettingFrameSrcToJavascriptUrl):
     16        * bindings/js/JSDOMBinding.cpp:
     17        (WebCore::shouldAllowAccessToNode):
     18        (WebCore::shouldAllowAccessToFrame):
     19        * bindings/js/JSDOMBinding.h:
     20        (WebCore):
     21        * bindings/js/JSHTMLFrameElementCustom.cpp:
     22        (WebCore::allowSettingJavascriptURL):
     23        * bindings/js/JSHistoryCustom.cpp:
     24        (WebCore::JSHistory::getOwnPropertySlotDelegate):
     25        (WebCore::JSHistory::getOwnPropertyDescriptorDelegate):
     26        (WebCore::JSHistory::putDelegate):
     27        (WebCore::JSHistory::deleteProperty):
     28        (WebCore::JSHistory::getOwnPropertyNames):
     29        * bindings/js/JSLocationCustom.cpp:
     30        (WebCore::JSLocation::getOwnPropertySlotDelegate):
     31        (WebCore::JSLocation::getOwnPropertyDescriptorDelegate):
     32        (WebCore::JSLocation::putDelegate):
     33        (WebCore::JSLocation::deleteProperty):
     34        (WebCore::JSLocation::getOwnPropertyNames):
     35        (WebCore::JSLocation::toStringFunction):
     36        * bindings/js/ScriptController.cpp:
     37        (WebCore::ScriptController::canAccessFromCurrentOrigin):
     38        * bindings/scripts/CodeGeneratorJS.pm:
     39        (GenerateGetOwnPropertyDescriptorBody):
     40        (GenerateImplementation):
     41        * bindings/scripts/CodeGeneratorV8.pm:
     42        (GenerateNormalAttrGetter):
     43        (GenerateFunctionCallback):
     44        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
     45        (WebCore::JSTestActiveDOMObject::getOwnPropertyDescriptor):
     46        * bindings/scripts/test/JS/JSTestObj.cpp:
     47        (WebCore::jsTestObjContentDocument):
     48        (WebCore::jsTestObjPrototypeFunctionGetSVGDocument):
     49        * bindings/scripts/test/V8/V8TestObj.cpp:
     50        (WebCore::TestObjInternal::contentDocumentAttrGetter):
     51        (WebCore::TestObjInternal::getSVGDocumentCallback):
     52
    1532012-02-02  Kalev Lember  <kalevlember@gmail.com>
    254
  • trunk/Source/WebCore/bindings/generic/BindingSecurity.h

    r104412 r106618  
    5656    // Check if it is safe to access the given node from the
    5757    // current security context.
    58     static bool allowAccessToNode(State<Binding>*, Node* target);
     58    static bool shouldAllowAccessToNode(State<Binding>*, Node* target);
    5959
    6060    static bool allowPopUp(State<Binding>*);
     
    102102
    103103template <class Binding>
    104 bool BindingSecurity<Binding>::allowAccessToNode(State<Binding>* state, Node* node)
     104bool BindingSecurity<Binding>::shouldAllowAccessToNode(State<Binding>* state, Node* node)
    105105{
    106106    if (!node)
     
    132132    if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value))) {
    133133        Node* contentDoc = frame->contentDocument();
    134         if (contentDoc && !allowAccessToNode(state, contentDoc))
     134        if (contentDoc && !shouldAllowAccessToNode(state, contentDoc))
    135135            return false;
    136136    }
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r105698 r106618  
    217217}
    218218
    219 bool allowAccessToNode(ExecState* exec, Node* node)
    220 {
    221     return node && allowAccessToFrame(exec, node->document()->frame());
    222 }
    223 
    224 bool allowAccessToFrame(ExecState* exec, Frame* frame)
     219bool shouldAllowAccessToNode(ExecState* exec, Node* node)
     220{
     221    return node && shouldAllowAccessToFrame(exec, node->document()->frame());
     222}
     223
     224bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame)
    225225{
    226226    if (!frame)
     
    230230}
    231231
    232 bool allowAccessToFrame(ExecState* exec, Frame* frame, String& message)
     232bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame, String& message)
    233233{
    234234    if (!frame)
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r106384 r106618  
    282282
    283283    // FIXME: Implement allowAccessToContext(JSC::ExecState*, ScriptExecutionContext*);
    284     bool allowAccessToNode(JSC::ExecState*, Node*);
    285     bool allowAccessToFrame(JSC::ExecState*, Frame*);
    286     bool allowAccessToFrame(JSC::ExecState*, Frame*, String& message);
     284    bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
     285    bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*);
     286    bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, String& message);
    287287    // FIXME: Implement allowAccessToDOMWindow(JSC::ExecState*, DOMWindow*);
    288288
  • trunk/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp

    r104412 r106618  
    4646    if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value))) {
    4747        Document* contentDocument = imp->contentDocument();
    48         if (contentDocument && !allowAccessToNode(exec, contentDocument))
     48        if (contentDocument && !shouldAllowAccessToNode(exec, contentDocument))
    4949            return false;
    5050    }
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r104412 r106618  
    6262    // allowed, return false so the normal lookup will take place.
    6363    String message;
    64     if (allowAccessToFrame(exec, impl()->frame(), message))
     64    if (shouldAllowAccessToFrame(exec, impl()->frame(), message))
    6565        return false;
    6666
     
    102102
    103103    // Throw out all cross domain access
    104     if (!allowAccessToFrame(exec, impl()->frame()))
     104    if (!shouldAllowAccessToFrame(exec, impl()->frame()))
    105105        return true;
    106106
     
    142142{
    143143    // Only allow putting by frames in the same origin.
    144     if (!allowAccessToFrame(exec, impl()->frame()))
     144    if (!shouldAllowAccessToFrame(exec, impl()->frame()))
    145145        return true;
    146146    return false;
     
    151151    JSHistory* thisObject = jsCast<JSHistory*>(cell);
    152152    // Only allow deleting by frames in the same origin.
    153     if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
     153    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
    154154        return false;
    155155    return Base::deleteProperty(thisObject, exec, propertyName);
     
    160160    JSHistory* thisObject = jsCast<JSHistory*>(object);
    161161    // Only allow the history object to enumerated by frames in the same origin.
    162     if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
     162    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
    163163        return;
    164164    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r105698 r106618  
    6060    // allowed, return false so the normal lookup will take place.
    6161    String message;
    62     if (allowAccessToFrame(exec, frame, message))
     62    if (shouldAllowAccessToFrame(exec, frame, message))
    6363        return false;
    6464
     
    9696   
    9797    // throw out all cross domain access
    98     if (!allowAccessToFrame(exec, frame))
     98    if (!shouldAllowAccessToFrame(exec, frame))
    9999        return true;
    100100   
     
    135135        return true;
    136136
    137     bool sameDomainAccess = allowAccessToFrame(exec, frame);
     137    bool sameDomainAccess = shouldAllowAccessToFrame(exec, frame);
    138138
    139139    const HashEntry* entry = JSLocation::s_info.propHashTable(exec)->entry(exec, propertyName);
     
    157157    JSLocation* thisObject = jsCast<JSLocation*>(cell);
    158158    // Only allow deleting by frames in the same origin.
    159     if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
     159    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
    160160        return false;
    161161    return Base::deleteProperty(thisObject, exec, propertyName);
     
    166166    JSLocation* thisObject = jsCast<JSLocation*>(object);
    167167    // Only allow the location object to enumerated by frames in the same origin.
    168     if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
     168    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
    169169        return;
    170170    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
     
    271271{
    272272    Frame* frame = impl()->frame();
    273     if (!frame || !allowAccessToFrame(exec, frame))
     273    if (!frame || !shouldAllowAccessToFrame(exec, frame))
    274274        return jsUndefined();
    275275
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r106043 r106618  
    248248    ExecState* exec = JSMainThreadExecState::currentState();
    249249    if (exec)
    250         return allowAccessToFrame(exec, frame);
     250        return shouldAllowAccessToFrame(exec, frame);
    251251    // If the current state is 0 we're in a call path where the DOM security
    252252    // check doesn't apply (eg. parser).
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r106575 r106618  
    500500            push(@implContent, "    if (!thisObject->allowsAccessFrom(exec))\n");
    501501        } else {
    502             push(@implContent, "    if (!allowAccessToFrame(exec, thisObject->impl()->frame()))\n");
     502            push(@implContent, "    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))\n");
    503503        }
    504504        push(@implContent, "        return false;\n");
     
    17011701                    $implIncludes{"JSDOMBinding.h"} = 1;
    17021702                    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1703                     push(@implContent, "    return allowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
     1703                    push(@implContent, "    return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
    17041704                } elsif ($type eq "EventListener") {
    17051705                    $implIncludes{"EventListener.h"} = 1;
     
    18901890                                push(@implContent, "    if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
    18911891                            } else {
    1892                                 push(@implContent, "    if (!allowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
     1892                                push(@implContent, "    if (!shouldAllowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
    18931893                            }
    18941894                            push(@implContent, "        return;\n");
     
    20182018                        push(@implContent, "    if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
    20192019                    } else {
    2020                         push(@implContent, "    if (!allowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
     2020                        push(@implContent, "    if (!shouldAllowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
    20212021                    }
    20222022                    push(@implContent, "        return;\n");
     
    21322132
    21332133                if ($function->signature->extendedAttributes->{"CheckAccessToNode"} and !$function->isStatic) {
    2134                     push(@implContent, "    if (!allowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
     2134                    push(@implContent, "    if (!shouldAllowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
    21352135                    push(@implContent, "        return JSValue::encode(jsUndefined());\n");
    21362136                    $implIncludes{"JSDOMBinding.h"} = 1;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r106605 r106618  
    855855    # Generate security checks if necessary
    856856    if ($attribute->signature->extendedAttributes->{"CheckAccessToNode"}) {
    857         push(@implContentDecls, "    if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->" . $attribute->signature->name . "()))\n    return v8::Handle<v8::Value>();\n\n");
     857        push(@implContentDecls, "    if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->" . $attribute->signature->name . "()))\n    return v8::Handle<v8::Value>();\n\n");
    858858    }
    859859
     
    14391439    }
    14401440    if ($function->signature->extendedAttributes->{"CheckAccessToNode"}) {
    1441         push(@implContentDecls, "    if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->" . $function->signature->name . "(ec)))\n");
     1441        push(@implContentDecls, "    if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->" . $function->signature->name . "(ec)))\n");
    14421442        push(@implContentDecls, "        return v8::Handle<v8::Value>();\n");
    14431443END
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp

    r105813 r106618  
    145145    JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(object);
    146146    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
    147     if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
     147    if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
    148148        return false;
    149149    return getStaticValueDescriptor<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, descriptor);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r106528 r106618  
    763763    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
    764764    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
    765     return allowAccessToNode(exec, impl->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->contentDocument())) : jsUndefined();
     765    return shouldAllowAccessToNode(exec, impl->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->contentDocument())) : jsUndefined();
    766766}
    767767
     
    19401940    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
    19411941    ExceptionCode ec = 0;
    1942     if (!allowAccessToNode(exec, impl->getSVGDocument(ec)))
     1942    if (!shouldAllowAccessToNode(exec, impl->getSVGDocument(ec)))
    19431943        return JSValue::encode(jsUndefined());
    19441944
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r106536 r106618  
    770770    INC_STATS("DOM.TestObj.contentDocument._get");
    771771    TestObj* imp = V8TestObj::toNative(info.Holder());
    772     if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->contentDocument()))
     772    if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->contentDocument()))
    773773    return v8::Handle<v8::Value>();
    774774
     
    14341434    ExceptionCode ec = 0;
    14351435    {
    1436     if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->getSVGDocument(ec)))
     1436    if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->getSVGDocument(ec)))
    14371437        return v8::Handle<v8::Value>();
    14381438    RefPtr<SVGDocument> result = imp->getSVGDocument(ec);
Note: See TracChangeset for help on using the changeset viewer.