Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨[Please fix it]Use of eval in "node_modules/lottie-web/build/player/lottie.js" is strongly discouraged as it poses security risks and may cause issues with minification. #3122

Open
JakiChen opened this issue Oct 9, 2024 · 0 comments

Comments

@JakiChen
Copy link

JakiChen commented Oct 9, 2024

First of all, thank you Airbnb team for creating such a useful thing, but I currently encounter this warning when compiling the project~

building client (vite) 
node_modules/lottie-web/build/player/lottie.js (17010:32): Use of eval in "node_modules/lottie-web/build/player/lottie.js" is strongly discouraged as it poses security risks and may cause issues with minification.

It seems that almost all versions have this problem? Whether it is the latest version or the version within the past two years?

I also tried to ask chatgpt related questions. If you switch to the light version, all animations will be missing (I am at a loss)

Lottie-Web 使用 eval 是为了支持解析 After Effects 的表达式,这对于需要处理动态表达式的动画来说是必要的。然而,这会带来一些安全性问题,尤其是在项目中使用严格的内容安全策略(CSP)时,这种策略通常会默认阻止 eval 的使用。启用 eval 可能会带来 XSS 攻击的风险​(#217)​(#298
)。

一个常见的解决方案是使用 lottie_light 版本,这个版本去除了对表达式的支持,因此不使用 eval。它可以处理大部分不依赖表达式的基础动画。如果你的项目不需要 After Effects 的复杂表达式,lottie_light 版本可能是一个更合适的选择​(#298)。

另外,也可以考虑手动修改库代码,尝试用更安全的解析方法替换 eval,例如 Function(),但这可能会失去某些上下文,影响性能或动画效果。对于只需要基础动画功能的场景,使用 lottie_light 是一种更简便的方法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant