fix: vendor glightbox#165
Closed
ParidelPooya wants to merge 1 commit into
Closed
Conversation
Zensical's theme bundle fetches the GLightbox image-lightbox library and its stylesheet from unpkg.com at runtime, which the site's Content Security Policy on docs.aws.amazon.com forbids. AppSec flagged both the direct CSS load (ExternalCDNForbiddenCheck) and the indirect JS load (ExternalCDNDynamicLoadForbiddenCheck). Zensical guards the unpkg fetch with typeof GLightbox === "undefined" || GLightbox instanceof Element so self-hosting the UMD build — which assigns window.GLightbox on load — short-circuits the check and prevents any network request to unpkg.com. This is the same mechanism already in use for Mermaid. - Add scripts/vendor_glightbox.py, which reads version and expected sha256 values from scripts/vendor_glightbox.toml, downloads the pinned glightbox build from cdn.jsdelivr.net, and verifies the sha256. The script supports --check (CI-safe) and --latest modes. - Vendor glightbox@3.3.1 into docs/assets/javascripts/glightbox.min.js and docs/assets/stylesheets/glightbox.min.css. - Register both files under extra_javascript and extra_css in zensical.toml so the browser loads them same-origin. - Extend .gitattributes so docs/assets/stylesheets/** is also treated as binary, keeping PR diffs readable for vendored CSS alongside the existing rule for vendored JavaScript. - Add a "Verify vendored GLightbox" step to the docs workflow so drift between the committed files and the pinned sha256 values fails CI. - Document the new vendored dependency and its upgrade procedure in CONTRIBUTING.md, next to the existing Mermaid entry. Refs V2204778244, V2204779958
Contributor
|
superseded by #166 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zensical's theme bundle fetches the GLightbox image-lightbox library and its stylesheet from unpkg.com at runtime, which the site's Content Security Policy on docs.aws.amazon.com forbids. AppSec flagged both the direct CSS load (ExternalCDNForbiddenCheck) and the indirect JS load (ExternalCDNDynamicLoadForbiddenCheck).
Zensical guards the unpkg fetch with
typeof GLightbox === "undefined" || GLightbox instanceof Element
so self-hosting the UMD build — which assigns window.GLightbox on load — short-circuits the check and prevents any network request to unpkg.com. This is the same mechanism already in use for Mermaid.