[PR #1833] [MERGED] fix(staffml): pin bootstrap-icons CSS with SRI + crossorigin #27303

Closed
opened 2026-06-18 16:53:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1833
Author: @farhan523
Created: 6/3/2026
Status: Merged
Merged: 6/10/2026
Merged by: @profvjreddi

Base: devHead: fix/ecosystembar-cdn-sri


📝 Commits (1)

  • 34d4a7f fix(staffml): pin bootstrap-icons CSS with SRI + crossorigin

📊 Changes

1 file changed (+18 additions, -1 deletions)

View changed files

📝 interviews/staffml/src/components/EcosystemBar.tsx (+18 -1)

📄 Description

Summary

EcosystemBar injected the bootstrap-icons stylesheet from jsDelivr with no integrity attribute. If jsDelivr was ever compromised or its CDN served modified bytes, the browser would apply the foreign CSS on every StaffML pageview.

Changes

  • Add integrity=\"sha384-…\" pinning the v1.11.3 bytes. Hash computed from the actual CDN file:
    curl -sL https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css \
      | openssl dgst -sha384 -binary | openssl base64 -A
    
  • Add crossOrigin=\"anonymous\" — required for SRI to be enforced on cross-origin resources.
  • Add an onerror handler that logs to console (with the recompute recipe) when the stylesheet is rejected. Without it the only symptom of a stale hash (e.g. after a version bump) would be silently missing icons across the bar.
  • Comment includes the recompute recipe so future version bumps update the hash deterministically.

Test plan

  • npx tsc --noEmit → unchanged (the 2 pre-existing errors on dev about katex / js-quantities are local-env-only; those packages are declared in package.json but missing from local node_modules until npm install runs)
  • All 57 individual vitest cases still pass. The 4 test files that fail to import on dev fail with the same stash-in / stash-out behavior — unrelated to this PR.
  • Manual: load the site, confirm icons (envelope, github, etc.) still render. If the hash is wrong they'd vanish.
  • Manual: temporarily corrupt the hash, reload, confirm the new console.error fires with the recompute recipe.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1833 **Author:** [@farhan523](https://github.com/farhan523) **Created:** 6/3/2026 **Status:** ✅ Merged **Merged:** 6/10/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/ecosystembar-cdn-sri` --- ### 📝 Commits (1) - [`34d4a7f`](https://github.com/harvard-edge/cs249r_book/commit/34d4a7fdb1123face2a20fbdd6595c63c6ac8eb7) fix(staffml): pin bootstrap-icons CSS with SRI + crossorigin ### 📊 Changes **1 file changed** (+18 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `interviews/staffml/src/components/EcosystemBar.tsx` (+18 -1) </details> ### 📄 Description ## Summary `EcosystemBar` injected the bootstrap-icons stylesheet from jsDelivr with no `integrity` attribute. If jsDelivr was ever compromised or its CDN served modified bytes, the browser would apply the foreign CSS on every StaffML pageview. ### Changes - Add `integrity=\"sha384-…\"` pinning the v1.11.3 bytes. Hash computed from the actual CDN file: ``` curl -sL https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css \ | openssl dgst -sha384 -binary | openssl base64 -A ``` - Add `crossOrigin=\"anonymous\"` — required for SRI to be enforced on cross-origin resources. - Add an `onerror` handler that logs to console (with the recompute recipe) when the stylesheet is rejected. Without it the only symptom of a stale hash (e.g. after a version bump) would be silently missing icons across the bar. - Comment includes the recompute recipe so future version bumps update the hash deterministically. ## Test plan - [x] `npx tsc --noEmit` → unchanged (the 2 pre-existing errors on `dev` about `katex` / `js-quantities` are local-env-only; those packages are declared in `package.json` but missing from local `node_modules` until `npm install` runs) - [x] All 57 individual vitest cases still pass. The 4 test files that fail to import on `dev` fail with the same stash-in / stash-out behavior — unrelated to this PR. - [ ] Manual: load the site, confirm icons (envelope, github, etc.) still render. If the hash is wrong they'd vanish. - [ ] Manual: temporarily corrupt the hash, reload, confirm the new `console.error` fires with the recompute recipe. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-18 16:53:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#27303