We're using puppeteer and sometimes playwright to run some integration tests. We mock some of the target page's script dependencies, which causes subresource integrity hash mismatches.
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."
Is there a way to disable integrity hash checking via a flag or configuration property?
No. I believe the only way is to fix or remove the
integrityattribute from the source that loads the script.Looking at the chromium (or blink) source, unless the
integrityattribute is empty, theFetchManager::Loaderwill instantiate theSRIVerifier, whose constructor calls itsOnStateChangemethod, where for response types ofbasic,cors,default(leaving outopaqueresponses and errors),SubresourceIntegrity::CheckSubresourceIntegrityis called. Unless the parsing of theintegrityattribute fails,SubresourceIntegrity::CheckSubresourceIntegrityImplwill either successfully verify one of the digests, or it will fail with the given error message. There is no configuration option checked along this path to override a failed check.