-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cypress cannot test sites that implement SRI #2393
Comments
Confirmed, we have the same problem. |
Is there any word on how this may be addressed or if there is any simple workaround for this? This prevents us from running any test automation outside our own local machines and prevents us from using Cypress as part of our continuous delivery pipeline. I'm happy to contribute a solution if a maintainer might point me in the right direction. |
Bug DescriptionTest code to reproduce issue it('fails to pass SRI', function () {
cy.visit('https://github.com')
}) Console error on test above: Implementation Details for Cypress to InvestigateSpecification for SRI: https://w3c.github.io/webappsec-subresource-integrity/
Workaround TodayFrom w3c Spec
Today you will want to implement an SRI fallback within the application under test. You can turn this on at all times or only when running in Cypress by detecting your application is running within Cypress - this is up to you. |
Still happening for me. Cypress package version: 3.1.5 |
I ran into this issue, seemingly out of the blue. I added the following to a script a the top of the document, and it seems to work: if (window.Cypress) {
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
if (MutationObserver) {
new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(processNode);
});
}).observe(document, { childList: true, subtree: true });
}
const processNode = function(node) {
const tagName = (node.tagName || '').toLowerCase();
if (
tagName === 'script'
&& node.integrity
) {
node.onerror = function(e) {
const fb = document.createElement(tagName);
const parent = node.parentNode;
if (node.src) fb.setAttribute('src', node.getAttribute('src'));
parent.appendChild(fb);
node.remove();
};
}
};
} |
Hi there! We are experiencing the same issue as above while testing our website. Are there plans to fix this issue ? I noticed this was slated for sprint 15 but didn't get finished as part of it. |
Hi, We have the same issue. Is there a plan for when this bug will be fixed in Cypress? |
Same issue here too! |
Hi, we have the same issue. |
Hello, Thanks for your attention, |
Just added this in #5273. Once released, SRI <script type="text/javascript" integrity="foo"> becomes the below which will cause integrity checking to be skipped. <script type="text/javascript" cypress:stripped-integrity="foo"> |
The code for this is done in cypress-io/cypress#5273, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
This fix is available starting in {
"experimentalSourceRewriting": true
} The fix is experimental, so there may be some situations where the this is not fixed. If you're still this issue while setting the |
Workaround for: cypress-io/cypress#2393 Ignores "Failed to find a valid digest in the 'integrity' attribute for resource" error when testing user login with Cypress
Current behavior:
When running Cypress against a site that implements SRI hashes, resources on the page are immediately blocked by Chrome and the page will not load due to invalid hashes. Disabling
chromeWebSecurity
does nothing. The following error appears in the Chrome DevTools console.Desired behavior:
The page of an SRI enabled site can load and not be blocked by Chrome. Either Cypress dynamically corrects the hash when it tampers with the file, or the
chromeWebSecurity
option actually disables SRI checks in Chrome.Steps to reproduce:
Versions
Cypress 3.1.0
Fedora 28
Chrome 68.0.3440.106
The text was updated successfully, but these errors were encountered: