Harden docs against supply-chain attacks: remove all third-party assets#56
Merged
Conversation
Pre-render the entropy page display equations to committed SVGs and write inline math as plain HTML, removing the cdnjs MathJax and require.js loads (same supply chain class as the polyfill.io incident). render_docs_math.py regenerates the SVGs from the markdown. Also ignore mkdocs (public/) and pytest-cov (htmlcov/) build output.
Make the docs site fully self-contained so no remote code or assets load in visitors' browsers: - System font stack (theme.font: false) instead of Google Fonts - Video tutorials as a title + link list, dropping YouTube thumbnails - Shortcode emoji replaced with inline Material icons - Remove the gitmind.com mind-map iframes (navigation page) - Add a Content-Security-Policy meta tag (overrides/main.html) that blocks external scripts/styles/fonts/frames, preventing a polyfill.io style CDN injection at the browser level
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.
What is this PR for?
Following the recent polyfill.io incident (a CDN extension injected malware into the docs), this removes every remote asset the docs load in visitors' browsers and adds a CSP so it can't recur.
Changes
pymdownx.arithmatex.render_docs_math.pyregenerates the SVGs from the markdown (dev-only matplotlib, no JS).theme.font: false) instead of Google Fonts.Content-Security-Policymeta tag (overrides/main.html) locking scripts/styles/fonts/frames to'self', blocking any external<script>at the browser level.privacyplugin; gitignorepublic/andhtmlcov/build output.Result
Verified across the full 38-page build: zero external
<script>/<link>/<img>/<iframe>/font loads, CSP present on every page.mkdocs buildis clean.Changes made to:
Did you build the code and tested on device?
What is the purpose of this pull request?