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

Set specific version of Algolia docsearch, set SRI #974

Closed
wants to merge 1 commit into from

Conversation

colindean
Copy link
Member

I was about to drop the SRI attributes, but then noticed that jsdelivr had some warnings:

So, to heed these warnings, I decided it was best to pin to a particular version of docsearch and use the pre-minified index.js to avoid dynamic modification.

Work toward #973

I was about to drop the SRI attributes, but then noticed that jsdelivr had some warnings:

* Skipped minification because the original files appear to be already minified.
* Original file: /npm/@docsearch/[email protected]/dist/umd/index.js
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files

So, to heed these warnings, I decided it was best to pin to a particular version of docsearch and use the pre-minified index.js to avoid dynamic modification.

Work toward Homebrew#973
@colindean
Copy link
Member Author

The one downside to this is getting the security benefits but losing the automatic update of the docsearch library...

And docsearch/js is updated ~monthly: https://www.npmjs.com/package/@docsearch/js?activeTab=versions

@Bo98
Copy link
Member

Bo98 commented Aug 20, 2023

At the very least, the version should be linked to the stylesheet above.

We probably also want a workflow that auto-updates this, with perhaps notices pointing maintainers to test locally in the event of major version bumps.

@SMillerDev
Copy link
Member

We could add a package.json and fail the build if the versions don't match

@MikeMcQuaid
Copy link
Member

We probably also want a workflow that auto-updates this, with perhaps notices pointing maintainers to test locally in the event of major version bumps.

Agreed. It feels like we're going to have to lean into Dependabot if we do this.

Not convinced the lack of SRI is a bigger security problem than sitting on older versions indefinitely.

@colindean
Copy link
Member Author

Upstream docsearch project has an open request for an SRI strategy: algolia/docsearch#1561

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Sep 13, 2023
@colindean
Copy link
Member Author

I posted about a potential solution in algolia/docsearch#1561 (comment). It's extra but it'd solve the problem if falling behind docsearch versions is a bad thing.

@github-actions github-actions bot removed the stale label Sep 13, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 5, 2023
@colindean
Copy link
Member Author

If the build-time SRI generation is acceptable, I can move forward with that.

@github-actions github-actions bot removed the stale label Oct 6, 2023
@MikeMcQuaid
Copy link
Member

If the build-time SRI generation is acceptable, I can move forward with that.

@colindean Can you detail more what this looks like?

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 28, 2023
@colindean
Copy link
Member Author

See algolia/docsearch#1561 (comment), but briefly, it's this at jekyll build time:

  1. retrieve the latest version of the library from the NPM registry API
  2. retrieve the content of jsdelivr's cache at that version and get the SRI hash
  3. include the output of that in my generated script tag.

This would safen the resource, creating only a threat vector at site build time.

This also creates a build time dependency on the NPM API and jsdelivr.net, but if these are inaccessible, the build could fall back to using the latest version URL and not specifying an SRI.

@github-actions github-actions bot removed the stale label Oct 29, 2023
@MikeMcQuaid
Copy link
Member

Closing this out for now but happy to review a new PR when that approach is done.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants