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

Support <script integrity= crossorigin=> tags #12279

Open
4 tasks
westurner opened this issue Apr 14, 2024 · 8 comments
Open
4 tasks

Support <script integrity= crossorigin=> tags #12279

westurner opened this issue Apr 14, 2024 · 8 comments
Labels
type:proposal a feature suggestion

Comments

@westurner
Copy link
Contributor

Is your feature request related to a problem? Please describe.

  • Use Case:
    • conf.py: Add a jquery static js asset with app.app_javascript()
      • https://releases.jquery.com/ suggests this <script> tag with extra attributes that aren't yet supported by app.add_javascript(pathurl) is now app.add_js_file(pathurl):
        <script
          src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
          integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
          crossorigin="anonymous"></script>

Describe the solution you'd like

Describe alternatives you've considered

  • Rewrite all <link> and <script> tags with SRI hashes

Additional context

@westurner westurner added the type:proposal a feature suggestion label Apr 14, 2024
@jayaddison
Copy link
Contributor

Hi @westurner - does the keyword-argument support in the add_js_file method provide the functionality that you're looking for here?

@westurner
Copy link
Contributor Author

Almost, I think. Remaining:

  • When or how should sphinx's own add_js_files() SRI hash integrity= kwargs be updated?
  • Update sphinx dev process to update integrity= kwargs at {dev, build, release}-time
  • Possibly add DeprecationWarning or similar if there are no integrity= hashes specifed and idk ignore_missing_sri_hashes = true isn't set in conf.py?

@jayaddison
Copy link
Contributor

Update sphinx dev process to update integrity= kwargs at {dev, build, release}-time

I don't think that sphinx should modify those itself if they're provided as arguments; that would conflict the reason for providing them - to ensure that the correct content is delivered to users. It would be OK for a project to provide either -- or both -- minified and non-minified variants, though, for example. The integrity HTML attribute can contain multiple same-algorithm-digests for the same resource, meaning that a choice of valid contents are considered valid at a point-in-time, and that would support the 'both' provision there.

When or how should sphinx's own add_js_files() SRI hash integrity= kwargs be updated?

I'm not completely certain what you mean by this; do you mean how would integrity values for the built-in theme CSS/JS files from Sphinx itself be generated?

@westurner
Copy link
Contributor Author

westurner commented Apr 15, 2024 via email

@jayaddison
Copy link
Contributor

  • support min.js variants - auto-hash the built in theme resources yeah - flag to build without any integrity= values for debugging

Could you describe some use-case(s) for disabling the integrity attribute? Even in development mode, it's valuable to know that code/scripts/stylesheets haven't been unexpectedly modified.

@westurner
Copy link
Contributor Author

westurner commented Apr 15, 2024 via email

@jayaddison
Copy link
Contributor

  • live on-disk modification of theme stylesheets (which DevTools works around just fine)

Given that the developer has local write access to the resources in that scenario, would it be acceptable to temporarily remove the HTML integrity attribute(s) for those resources until editing is completed?

@westurner
Copy link
Contributor Author

westurner commented Apr 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

2 participants