Changeset 104412 in webkit


Ignore:
Timestamp:
Jan 8, 2012 3:15:42 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 Sam Weinig.

This patch contains only renames and FIXME comments. No behavior change.

  • bindings/js/JSDOMBinding.cpp:

(WebCore::allowAccessToNode):
(WebCore::allowAccessToFrame):

  • bindings/js/JSDOMBinding.h:
  • 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):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104411 r104412  
     12012-01-08  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 Sam Weinig.
     7
     8        This patch contains only renames and FIXME comments.  No behavior change.
     9
     10        * bindings/js/JSDOMBinding.cpp:
     11        (WebCore::allowAccessToNode):
     12        (WebCore::allowAccessToFrame):
     13        * bindings/js/JSDOMBinding.h:
     14        * bindings/js/JSHTMLFrameElementCustom.cpp:
     15        (WebCore::allowSettingJavascriptURL):
     16        * bindings/js/JSHistoryCustom.cpp:
     17        (WebCore::JSHistory::getOwnPropertySlotDelegate):
     18        (WebCore::JSHistory::getOwnPropertyDescriptorDelegate):
     19        (WebCore::JSHistory::putDelegate):
     20        (WebCore::JSHistory::deleteProperty):
     21        (WebCore::JSHistory::getOwnPropertyNames):
     22        * bindings/js/JSLocationCustom.cpp:
     23        (WebCore::JSLocation::getOwnPropertySlotDelegate):
     24        (WebCore::JSLocation::getOwnPropertyDescriptorDelegate):
     25        (WebCore::JSLocation::putDelegate):
     26        (WebCore::JSLocation::deleteProperty):
     27        (WebCore::JSLocation::getOwnPropertyNames):
     28        (WebCore::JSLocation::toStringFunction):
     29        * bindings/js/ScriptController.cpp:
     30        (WebCore::ScriptController::canAccessFromCurrentOrigin):
     31        * bindings/scripts/CodeGeneratorJS.pm:
     32        (GenerateGetOwnPropertyDescriptorBody):
     33        (GenerateImplementation):
     34        * bindings/scripts/CodeGeneratorV8.pm:
     35        (GenerateNormalAttrGetter):
     36        (GenerateFunctionCallback):
     37
    1382012-01-08  Adam Barth  <abarth@webkit.org>
    239
  • trunk/Source/WebCore/bindings/generic/BindingSecurity.h

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

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

    r104411 r104412  
    281281    JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned&);
    282282
    283     bool checkNodeSecurity(JSC::ExecState*, Node*);
    284 
    285     // Helpers for Window, History, and Location classes to implement cross-domain policy.
    286     // Besides the cross-domain check, they need non-caching versions of staticFunctionGetter for
    287     // because we do not want current property values involved at all.
    288     // FIXME: These functions should be named frameAllowsAccessFrom, because the access is *to* the frame.
    289     bool allowsAccessFromFrame(JSC::ExecState*, Frame*);
    290     bool allowsAccessFromFrame(JSC::ExecState*, Frame*, String& message);
     283    // 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);
     287    // FIXME: Implement allowAccessToDOMWindow(JSC::ExecState*, DOMWindow*);
     288
     289    // FIXME: Remove these functions in favor of activeContext and
     290    // firstContext, which return ScriptExecutionContext*. We prefer to use
     291    // ScriptExecutionContext* as the context object in the bindings.
    291292    DOMWindow* activeDOMWindow(JSC::ExecState*);
    292293    DOMWindow* firstDOMWindow(JSC::ExecState*);
  • trunk/Source/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp

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

    r102797 r104412  
    6262    // allowed, return false so the normal lookup will take place.
    6363    String message;
    64     if (allowsAccessFromFrame(exec, impl()->frame(), message))
     64    if (allowAccessToFrame(exec, impl()->frame(), message))
    6565        return false;
    6666
     
    102102
    103103    // Throw out all cross domain access
    104     if (!allowsAccessFromFrame(exec, impl()->frame()))
     104    if (!allowAccessToFrame(exec, impl()->frame()))
    105105        return true;
    106106
     
    142142{
    143143    // Only allow putting by frames in the same origin.
    144     if (!allowsAccessFromFrame(exec, impl()->frame()))
     144    if (!allowAccessToFrame(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 (!allowsAccessFromFrame(exec, thisObject->impl()->frame()))
     153    if (!allowAccessToFrame(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 (!allowsAccessFromFrame(exec, thisObject->impl()->frame()))
     162    if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
    163163        return;
    164164    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r102797 r104412  
    6060    // allowed, return false so the normal lookup will take place.
    6161    String message;
    62     if (allowsAccessFromFrame(exec, frame, message))
     62    if (allowAccessToFrame(exec, frame, message))
    6363        return false;
    6464
     
    9696   
    9797    // throw out all cross domain access
    98     if (!allowsAccessFromFrame(exec, frame))
     98    if (!allowAccessToFrame(exec, frame))
    9999        return true;
    100100   
     
    135135        return true;
    136136
    137     bool sameDomainAccess = allowsAccessFromFrame(exec, frame);
     137    bool sameDomainAccess = allowAccessToFrame(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 (!allowsAccessFromFrame(exec, thisObject->impl()->frame()))
     159    if (!allowAccessToFrame(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 (!allowsAccessFromFrame(exec, thisObject->impl()->frame()))
     168    if (!allowAccessToFrame(exec, thisObject->impl()->frame()))
    169169        return;
    170170    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
     
    271271{
    272272    Frame* frame = impl()->frame();
    273     if (!frame || !allowsAccessFromFrame(exec, frame))
     273    if (!frame || !allowAccessToFrame(exec, frame))
    274274        return jsUndefined();
    275275
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

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

    r104411 r104412  
    523523            push(@implContent, "    if (!thisObject->allowsAccessFrom(exec))\n");
    524524        } else {
    525             push(@implContent, "    if (!allowsAccessFromFrame(exec, thisObject->impl()->frame()))\n");
     525            push(@implContent, "    if (!allowAccessToFrame(exec, thisObject->impl()->frame()))\n");
    526526        }
    527527        push(@implContent, "        return false;\n");
     
    17531753                        push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
    17541754                    }
    1755                 } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) {
     1755                } elsif ($attribute->signature->extendedAttributes->{"allowAccessToNode"}) {
    17561756                    $implIncludes{"JSDOMBinding.h"} = 1;
    17571757                    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1758                     push(@implContent, "    return checkNodeSecurity(exec, impl->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
     1758                    push(@implContent, "    return allowAccessToNode(exec, impl->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
    17591759                } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) {
    17601760                    $implIncludes{"Document.h"} = 1;
    17611761                    $implIncludes{"JSDOMBinding.h"} = 1;
    17621762                    push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1763                     push(@implContent, "    return checkNodeSecurity(exec, impl->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
     1763                    push(@implContent, "    return allowAccessToNode(exec, impl->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n");
    17641764                } elsif ($type eq "EventListener") {
    17651765                    $implIncludes{"EventListener.h"} = 1;
     
    19291929                                push(@implContent, "    if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
    19301930                            } else {
    1931                                 push(@implContent, "    if (!allowsAccessFromFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
     1931                                push(@implContent, "    if (!allowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
    19321932                            }
    19331933                            push(@implContent, "        return;\n");
     
    20572057                        push(@implContent, "    if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
    20582058                    } else {
    2059                         push(@implContent, "    if (!allowsAccessFromFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
     2059                        push(@implContent, "    if (!allowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n");
    20602060                    }
    20612061                    push(@implContent, "        return;\n");
     
    21712171
    21722172                if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"} and !$function->isStatic) {
    2173                     push(@implContent, "    if (!checkNodeSecurity(exec, impl->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
     2173                    push(@implContent, "    if (!allowAccessToNode(exec, impl->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
    21742174                    push(@implContent, "        return JSValue::encode(jsUndefined());\n");
    21752175                    $implIncludes{"JSDOMBinding.h"} = 1;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r104411 r104412  
    884884
    885885    # Generate security checks if necessary
    886     if ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) {
    887         push(@implContentDecls, "    if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->$attrName()))\n    return v8::Handle<v8::Value>();\n\n");
     886    if ($attribute->signature->extendedAttributes->{"allowAccessToNode"}) {
     887        push(@implContentDecls, "    if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->$attrName()))\n    return v8::Handle<v8::Value>();\n\n");
    888888    } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) {
    889         push(@implContentDecls, "    if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->contentDocument()))\n    return v8::Handle<v8::Value>();\n\n");
     889        push(@implContentDecls, "    if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->contentDocument()))\n    return v8::Handle<v8::Value>();\n\n");
    890890    }
    891891
     
    14351435    if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
    14361436        push(@implContentDecls, <<END);
    1437     if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->getSVGDocument(ec)))
     1437    if (!V8BindingSecurity::allowAccessToNode(V8BindingState::Only(), imp->getSVGDocument(ec)))
    14381438        return v8::Handle<v8::Value>();
    14391439END
Note: See TracChangeset for help on using the changeset viewer.