angular - 如何解决 Checkmarx 漏洞 - Angular 代码中的“Client Insufficient ClickJacking Protection”,在某些组件 HTML 页面上报告?
问题描述
Checkmarx 扫描报告 Angular 组件 HTML 页面上的“Client Insufficient ClickJacking Protection”漏洞。
这是一页:
文件名 src/app/app.component.html
<div class="home-page-container">
这是另一个:
文件名 src/app/create.component.html
<div class="control-bar">
Checkmarx 建议:
该应用程序不会通过使用 framebusting 脚本来保护网页 src/app/app.component.html 免受旧版浏览器中的点击劫持攻击。
我已经在index.html页面中为旧版浏览器实现了 Frame busting 代码,因为 Angular 代码是一个单页应用程序。
并且X-Frame-Options响应标头在托管服务器上设置为SAMEORIGIN 。
但 Checkmarx 仍然在组件特定的 HTML 页面中报告此漏洞。
如何修复此漏洞?
这是添加到Angular 代码的index.html的 framebusting 代码 -
<style> html {display : none; } </style>
<script>
if ( self === top ) {
document.documentElement.style.display = 'block';
}
else {
top.location = encodeURI(self.location);
}
</script>
解决方案
推荐阅读
- r - 使用 R 从字符中删除停用词
- firebase - 谷歌云端硬盘手表变化的无服务器解决方案
- git - Git:如何从主分支中删除一个提交
- python - Pandas 将列变成 MultiIndex
- cmake - 如何在一台机器上使用 cpack 为 fedora/RH 和 debian/ubuntu 构建 RPM
- android - 不支持 Twilio 视频编解码器 H264
- datetime - 如何从给定的日期时间开始倒计时到 24 小时颤动?
- github - 为什么我会得到很多远程:当推送到 master 时
- javascript - 在c#中提交表单字符串输入为空
- python - 使用非 ascii 字符测试 python 代码