javascript - iframe 内的资源 URL 上下文中使用的不安全值
问题描述
我正在尝试在 Angular 应用程序中嵌入 iframe。
嵌入页面来自外部 URL,因此我必须使用 DomSanitizer 才能绕过安全信任资源 url:
this.route.paramMap.pipe(
map(params => params.get('projectName')),
switchMap(projectName => retreiveUrlFunction()),
map(url => this.sanitizer.bypassSecurityTrustResourceUrl(url) as string)
).subscribe(url => this.embedUrl = url)
<iframe [src]="embedUrl" width=770 height=500 style="border: 0; box-shadow: 5px 5px 56px 0px rgba(0,0,0,0.25);"></iframe>
这样做会加载 Iframe,但 Iframe 本身包含需要绕过安全信任的资源 URL。
我犯了同样的错误 :
Error: unsafe value used in a resource URL context (see https://g.co/ng/security#xss)
一个相对于 Iframe 中加载的所有脚本:
Refused to load the script 'https://a.bigbrain.me/bigbrain-1.0.min.js?v=1' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' http://localhost:8080 *.lvh.me:* https://realize.io https://dapulse.com https://mondaystaging.com https://itsmonday.com https://monday.com https://assets.zendesk.com https://cdn.actionbar.io....
我怎样才能完全绕过安全性?
解决方案
推荐阅读
- flutter - Flutter Parallax Scroll 中的按钮不可点击
- php - session_status() 重新加载时不返回
- javascript - React-Redux 用户界面错误。图像更新滞后
- vagrant - 使用虚拟环境在 vagrant 的共享文件夹中安装 python 模块时出现 [Errno 39] 目录不是空问题
- python-3.x - 从 Python 命名空间向后工作到包
- javascript - react-router-dom 参数不包含 URL 中存在的问号
- integer - 为什么在对 3 个实变量求和时会得到一个奇怪的结果?
- .net - 用于集成测试的 Spring Boot @LocalServerPort 的 DotNet 替代品
- react-native - React-native createRef 无法正常工作
- django - 错误当前路径,与其中任何一个都不匹配