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

feat(core): use virtual file system for SRI #435

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Conversation

vejja
Copy link
Collaborator

@vejja vejja commented Apr 25, 2024

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR brings a technical rewrite of the way we save SRI hashes at build time.

Previously, the way we saved SRI hashes was hacky. We were writing the hashes on the drive under the .nuxt build-time directory, which was necessary for SSG rendering of integrity hashes. But because this directory is not available in the server context in SSR mode, we also copied them to the server assets output folder. Then we relied on useStorage to retrieve the hashes, and depending whether the context was SSR or SSG, we had to look either into the build folder or assets folder. Because the output was in JSON format, we encountered issues when Nitropack changed the format of raw assets in JSON format (most notably #395).

With this rewrite, we now use the native Nuxt Virtual File System to inject SRI hashes at build time. In practice, this means that the SRI hashes are now directly bundled into the Nitro server runtime. We do not need useStorage to read them from the disk anymore.

This closes #395 definitively as we remove the dependency from useStorage raw format.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

@vejja vejja self-assigned this Apr 25, 2024
Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-security ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 6:47am

@vejja vejja marked this pull request as ready for review April 25, 2024 13:56
Copy link
Owner

@Baroshem Baroshem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, thanks! Do you think we could release it as a patch version or should we wait until the next minor?

@vejja
Copy link
Collaborator Author

vejja commented Apr 26, 2024

It can be a patch, this is really small

@Baroshem Baroshem merged commit 57ea940 into main Apr 29, 2024
5 checks passed
@Baroshem
Copy link
Owner

Published as 1.4.3 :)

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

Successfully merging this pull request may close these issues.

Subresource Integrity error
2 participants