gpt4 book ai didi

sonarqube - SonarJs 仍然显示有关 postMessage 跨域问题的警告

转载 作者:行者123 更新时间:2023-12-02 17:01:08 27 4
gpt4 key购买 nike

错误消息是“确保这个跨域消息被发送到预期的域”

此检查规则来自RSPEC-2819

Authors should not use the wildcard keyword ( *) in the targetOrigin argument in messages that contain any confidential information, as otherwise there is no way to guarantee that the message is only delivered to the recipient to which it was intended.

我假设它要求 * 不能用作 targetOrigin,但是当我使用预期域作为 targetOrigin 时它仍然显示警告,如下所示:

enter image description here

请有人告诉我如何通过此检查,

任何帮助将不胜感激

最佳答案

此规则仅检测是否在名称中包含 window 的对象上调用方法 postMessage。源代码:PostMessageCheck.java .要绕过它,只需将您的 contentWindow 对象分配给不同的对象,如下所示:

var content = this.elem.contentWindow;

content.postMessage('your message', window.location.origin);

关于sonarqube - SonarJs 仍然显示有关 postMessage 跨域问题的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54139298/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com