Baroshem / nuxt-security

šŸ›” Automatically configure your app to follow OWASP security patterns and principles by using HTTP Headers and Middleware
https://nuxt-security.vercel.app/
MIT License
737 stars 56 forks source link

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

Closed vejja closed 1 month ago

vejja commented 2 months ago

Types of changes

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:

vercel[bot] commented 2 months ago

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 commented 2 months ago

It can be a patch, this is really small

Baroshem commented 1 month ago

Published as 1.4.3 :)