当从用户那里获取代码输入并像Codepen一样运行它时,我应该采取什么安全措施?

问题描述

我正在用React创建类似于Codpen的东西,用户可以在其中输入HTML和JS代码, 然后在iframe内运行它,并为其提供srcDoc用户输入。像这样:

const render = () => {
  const htmlCode = // the data from the user's input
  const jsCode = // the data from the user's input
  const input = `<html><body>${htmlCode}</body><script type="text/javascript">${jsCode}. </script></html>`;
  return <iframe srcDoc={input}/>
}

我现在对暴露的漏洞一无所知。 您能指导我采取一些步骤吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...