-
Notifications
You must be signed in to change notification settings - Fork 29
Add SRI integrity hashes to CDN resources in docs HTML files (2.x) #593
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
Open
Copilot
wants to merge
4
commits into
2.x
Choose a base branch
from
copilot/add-checksum-to-html-tags-2-x
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
73e0b94
Add SRI integrity hashes to CDN resources in docs HTML files
Copilot aa2d87c
Add custom MkDocs theme template with SRI hashes to prevent rebuild loss
Copilot 7547a5d
Fix typos in custom theme base.html inherited from MkDocs 1.0.4 template
Copilot 2937955
Fix CodeQL: guard hljs language scripts with SRI hash lookup (fail-se…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| <!DOCTYPE html> | ||
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> | ||
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> | ||
| <head> | ||
| {%- block site_meta %} | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| {% if page and page.is_homepage %}<meta name="description" content="{{ config.site_description }}">{% endif %} | ||
| {% if config.site_author %}<meta name="author" content="{{ config.site_author }}">{% endif %} | ||
| {% if config.site_favicon %}<link rel="shortcut icon" href="{{ config.site_favicon|url }}"> | ||
| {% else %}<link rel="shortcut icon" href="{{ 'img/favicon.ico'|url }}">{% endif %} | ||
| {%- endblock %} | ||
|
|
||
| {%- block htmltitle %} | ||
| <title>{% if page and page.title and not page.is_homepage %}{{ page.title }} - {% endif %}{{ config.site_name }}</title> | ||
| {%- endblock %} | ||
|
|
||
| {%- block styles %} | ||
| <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> | ||
|
|
||
| <link rel="stylesheet" href="{{ 'css/theme.css'|url }}" type="text/css" /> | ||
| <link rel="stylesheet" href="{{ 'css/theme_extra.css'|url }}" type="text/css" /> | ||
| {%- if config.theme.highlightjs %} | ||
| <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" integrity="sha384-WtUWHyk39lfUpZQVgokNfSKCJaKAeD6adgLduBLrKTMUuPzFhLtL23y1guFy6lZn" crossorigin="anonymous"> | ||
| {%- endif %} | ||
| {%- for path in config['extra_css'] %} | ||
| <link href="{{ path|url }}" rel="stylesheet"> | ||
| {%- endfor %} | ||
| {%- endblock %} | ||
|
|
||
| {%- block libs %} | ||
| {% if page %} | ||
| <script> | ||
| // Current page data | ||
| var mkdocs_page_name = {{ page.title|tojson|safe }}; | ||
| var mkdocs_page_input_path = {{ page.file.src_path|string|tojson|safe }}; | ||
| var mkdocs_page_url = {{ page.abs_url|tojson|safe }}; | ||
| </script> | ||
| {% endif %} | ||
| <script src="{{ 'js/jquery-2.1.1.min.js'|url }}" defer></script> | ||
| <script src="{{ 'js/modernizr-2.8.3.min.js'|url }}" defer></script> | ||
| {%- if config.theme.highlightjs %} | ||
| <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" integrity="sha384-ZeLYJ2PNSQjvogWP559CDAf02Qb8FE5OyQicqtz/+UhZutbrwyr87Be7NPH/RgyC" crossorigin="anonymous"></script> | ||
| {#- SRI hashes for highlight.js 9.12.0 language files. Add an entry here for each | ||
| language listed under theme.hljs_languages in mkdocs.yml before enabling it. #} | ||
| {%- set hljs_lang_sri = {} %} | ||
| {%- for lang in config.theme.hljs_languages %} | ||
| {%- if lang in hljs_lang_sri %} | ||
| <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/{{lang}}.min.js" integrity="{{ hljs_lang_sri[lang] }}" crossorigin="anonymous"></script> | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| <script>hljs.initHighlightingOnLoad();</script> | ||
| {%- endif %} | ||
| {%- endblock %} | ||
|
|
||
| {%- block extrahead %} {% endblock %} | ||
|
|
||
| {%- block analytics %} | ||
| {% if config.google_analytics %} | ||
| <script> | ||
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
| })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
|
|
||
| ga('create', '{{ config.google_analytics[0] }}', '{{ config.google_analytics[1] }}'); | ||
| ga('send', 'pageview'); | ||
| </script> | ||
| {% endif %} | ||
| {%- endblock %} | ||
| </head> | ||
|
|
||
| <body class="wy-body-for-nav" role="document"> | ||
|
|
||
| <div class="wy-grid-for-nav"> | ||
|
|
||
| {# SIDE NAV, TOGGLES ON MOBILE #} | ||
| <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav"> | ||
| <div class="wy-side-nav-search"> | ||
| {%- block site_name %} | ||
| <a href="{{ nav.homepage.url|url }}" class="icon icon-home"> {{ config.site_name }}</a> | ||
| {%- endblock %} | ||
| {%- block search_button %} | ||
| {% if 'search' in config['plugins'] %}{% include "searchbox.html" %}{% endif %} | ||
| {%- endblock %} | ||
| </div> | ||
|
|
||
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> | ||
| {%- block site_nav %} | ||
| <ul class="current"> | ||
| {% set navlevel = 1 %} | ||
| {% for nav_item in nav %} | ||
| <li class="toctree-l{{ navlevel }}{% if nav_item.active and not nav_item.children %} current{%endif%}"> | ||
| {% include 'nav.html' %} | ||
| </li> | ||
| {% endfor %} | ||
| </ul> | ||
| {%- endblock %} | ||
| </div> | ||
| | ||
| </nav> | ||
|
|
||
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> | ||
|
|
||
| {# MOBILE NAV, TRIGGERS SIDE NAV ON TOGGLE #} | ||
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> | ||
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
| <a href="{{ nav.homepage.url|url }}">{{ config.site_name }}</a> | ||
| </nav> | ||
|
|
||
| {# PAGE CONTENT #} | ||
| <div class="wy-nav-content"> | ||
| <div class="rst-content"> | ||
| {% include "breadcrumbs.html" %} | ||
| <div role="main"> | ||
| <div class="section"> | ||
| {% block content %} | ||
| {{ page.content }} | ||
| {% endblock %} | ||
| </div> | ||
| </div> | ||
| {%- block footer %} | ||
| {% include "footer.html" %} | ||
| {% endblock %} | ||
| </div> | ||
| </div> | ||
|
|
||
| </section> | ||
|
|
||
| </div> | ||
|
|
||
| {% include "versions.html" %} | ||
|
|
||
| {%- block scripts %} | ||
| <script>var base_url = '{{ base_url }}';</script> | ||
| <script src="{{ 'js/theme.js'|url }}" defer></script> | ||
| {%- for path in config['extra_javascript'] %} | ||
| <script src="{{ path|url }}" defer></script> | ||
| {%- endfor %} | ||
| {%- endblock %} | ||
|
|
||
| </body> | ||
| </html> | ||
| {% if page and page.is_homepage %} | ||
| <!-- | ||
| MkDocs version : {{ mkdocs_version }} | ||
| Build Date UTC : {{ build_date_utc }} | ||
| --> | ||
| {% endif %} | ||
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hljs.initHighlightingOnLoad()is called unconditionally right after loading highlight.js. If the CDN script fails to load (e.g., SRI mismatch, network block), this will throw a ReferenceError (hljsis undefined) and clutter the console. Consider guarding the call (e.g., checkwindow.hljsbefore invoking) so the page degrades cleanly when highlighting is unavailable.