JS_GetSecurityCallbacks 编辑

This article covers features introduced in SpiderMonkey 1.8.1

Configure SpiderMonkey security hooks.

Syntax

/* Added in SpiderMonkey 17 */

void
JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks);

const JSSecurityCallbacks *
JS_GetSecurityCallbacks(JSRuntime *rt);

/* Obsolete since JSAPI 13 */

JSSecurityCallbacks *
JS_SetContextSecurityCallbacks(JSContext *cx, JSSecurityCallbacks *callbacks);

JSSecurityCallbacks *
JS_GetRuntimeSecurityCallbacks(JSRuntime *rt);

JSSecurityCallbacks *
JS_SetRuntimeSecurityCallbacks(JSRuntime *rt, JSSecurityCallbacks *callbacks);
NameTypeDescription
rtJSRuntime *A runtime to get/set the security callbacks.
callbacksconst JSSecurityCallbacks *A pointer to the new callbacks for the runtime.

Callback Structure

struct JSSecurityCallbacks {
    JSCSPEvalChecker           contentSecurityPolicyAllows; // Added in SpiderMonkey 1.8.5
    JSSubsumesOp               subsumes; // Added in SpiderMonkey 31

    JSCheckAccessOp            checkObjectAccess;    // Obsolete since JSAPI 29

    JSPrincipalsTranscoder     principalsTranscoder; // Obsolete since JSAPI 13
    JSObjectPrincipalsFinder   findObjectPrincipals; // Obsolete since JSAPI 13
};
NameTypeDescription
contentSecurityPolicyAllowsJSCSPEvalCheckerA pointer to the function which checks if a CSP instance wants to disable eval() and friends. Use NULL is not needed.
subsumesJSSubsumesOpA pointe to the function which returns whether the first principal subsumes the second. Use NULL is not needed.

Description

JS_SetSecurityCallbacks sets the runtime's security callbacks to callbacks. It allows the embedding to control certain aspects of JS code execution based on security settings of the global object the code is executed in. If callbacks is NULL, it sets callbacks to default value.

JS_GetSecurityCallbacks returns the runtime's current security callbacks. If the callbacks are default value, it returns NULL

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:61 次

字数:4699

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文