我们正在使用 puppeteer有时 playwright运行一些集成测试。我们模拟了一些目标页面的脚本依赖项,这会导致 subresource integrity哈希不匹配。
Failed to find a valid digest in the 'integrity' attribute for resource 'http://localhost:3000/static/third-party/adobe-target/at-js/2.4.0-cname/at.js' with computed SHA-256 integrity '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='. The resource has been blocked."
有没有办法通过标志或配置属性禁用完整性哈希检查?
最佳答案
没有。我认为唯一的方法是从加载脚本的源中修复或删除 integrity
属性。
查看 chromium(或闪烁)源,unless the integrity
attribute is empty , FetchManager::Loader
将实例化 SRIVerifier
,其构造函数调用其 OnStateChange
方法,其中对于 basic
、cors
、default
的响应类型(省略 opaque
响应和错误),SubresourceIntegrity::CheckSubresourceIntegrity
叫做。 Unless the parsing of the integrity
attribute fails , SubresourceIntegrity::CheckSubresourceIntegrityImpl
将成功验证其中一个摘要,否则将失败并显示给定的错误消息。没有沿此路径检查配置选项来覆盖失败的检查。
关于puppeteer - 是否有一个标志可以禁用 chromium 中的子资源完整性检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69470528/