Skip to content

sec(frontend/docs): SRI + version pin on Go-served swagger-ui (closes #541, #543) - #573

Merged
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
sec/frontend-docs-sri-handler
May 22, 2026
Merged

sec(frontend/docs): SRI + version pin on Go-served swagger-ui (closes #541, #543)#573
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
sec/frontend-docs-sri-handler

Conversation

@cristim

@cristim cristim commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

Brings the Go-served swagger-ui docs page to parity with the docs.html hardening from PR #521, closing the remaining half of #447 plus its regression test.

Fixes

Version + SRI hashes are kept consistent with PR #521's docs.html values.

Test plan

  • internal/api/handler_docs_test.go asserts the served HTML contains the pinned version + integrity + crossorigin
  • frontend/src/__tests__/docs.test.ts guards the docs.html tags
  • CSP no longer permits unhashed unpkg.com script-src

Closes #541, #543. Refs #447.

cristim added 2 commits May 20, 2026 18:33
The Go /docs handler still loaded swagger-ui-dist@5.32.5 from unpkg with no
integrity/crossorigin, leaving the public docs page open to CDN poisoning
(issue #447). PR #521 only fixed the static frontend/src/docs.html, not the
Go handler (issue #541).

Bring handler_docs.go to parity with docs.html: pin @5.32.6, add the same
sha384 SRI hashes + crossorigin="anonymous" to the css/bundle/standalone-
preset tags, and load the standalone-preset script the bootstrap references
(previously missing). The unpkg host stays in script-src because element-level
SRI does not grant CSP load permission; the godoc explains why. Add a Go
regression test asserting the served HTML keeps the version pin and SRI attrs
and uses the shared hash constants.

Closes #447, #541
Refs #521
PR #521 pinned the swagger-ui-dist version and added SRI integrity/crossorigin
to docs.html but added no test, so a future edit could silently drop the
integrity attribute or revert the @5.32.6 pin to a floating @5 tag (issue #543).

Add a regression test that, for each unpkg/swagger-ui-dist link/script tag in
docs.html, asserts an exact x.y.z version (never a floating major tag), an
integrity="sha384-..." attribute, and crossorigin="anonymous".

Closes #543
Refs #447, #521
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-quarter Within the quarter impact/all-users Affects every user effort/s Hours type/security Security finding labels May 20, 2026
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@cristim has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 59 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08600db6-b224-4e74-a4b3-7053c6382dc5

📥 Commits

Reviewing files that changed from the base of the PR and between bc7bf0f and a6d9f00.

📒 Files selected for processing (3)
  • frontend/src/__tests__/docs.test.ts
  • internal/api/handler_docs.go
  • internal/api/handler_docs_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sec/frontend-docs-sri-handler

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/all-users Affects every user priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/security Security finding urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant