Skip to content

feat(daemon): csp nonce handling#6587

Merged
bgajjala8 merged 5 commits intomainfrom
bgajjala-nonce-csp-encoding
Apr 27, 2026
Merged

feat(daemon): csp nonce handling#6587
bgajjala8 merged 5 commits intomainfrom
bgajjala-nonce-csp-encoding

Conversation

@bgajjala8
Copy link
Copy Markdown
Contributor

Description

This PR adds nonce handling to support UI features. The changes include a new wrapper to apply CSP with a crypto nonce value and adjust injection of the nonce into returned HTML. This change will take place in tandem with a UI PR

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've documented the impact of any changes to security controls.
    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@bgajjala8 bgajjala8 changed the title Nonce handling feat(ui): csp nonce handling Apr 13, 2026
@bgajjala8 bgajjala8 requested review from ZedLi and irenarindos April 13, 2026 17:07
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from 12200fa to 590ff8e Compare April 13, 2026 17:12
@bgajjala8 bgajjala8 self-assigned this Apr 13, 2026
@bgajjala8 bgajjala8 added this to the 0.21.x milestone Apr 13, 2026
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from 590ff8e to 04be86c Compare April 13, 2026 17:24
@bgajjala8 bgajjala8 marked this pull request as ready for review April 13, 2026 17:25
@bgajjala8 bgajjala8 requested a review from a team as a code owner April 13, 2026 17:25
@bgajjala8 bgajjala8 requested a review from Copilot April 13, 2026 17:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CSP nonce handling for controller-served UI responses by generating a per-document nonce, injecting it into the CSP header, and rewriting the served index.html to replace a placeholder value.

Changes:

  • Add wrapHandlerWithCsp middleware to generate/inject a CSP nonce for UI “document” requests and preserve default CSP for static assets.
  • Add a ResponseWriter wrapper to replace a CSP placeholder in index.html with a runtime value.
  • Add unit tests covering CSP header nonce injection behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
internal/daemon/controller/handler_ui.go Wraps UI document responses to replace a CSP placeholder in returned HTML.
internal/daemon/controller/handler_test.go Adds tests for the new CSP wrapping middleware behavior.
internal/daemon/controller/handler.go Introduces and wires a CSP middleware that injects a nonce for UI document requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/daemon/controller/handler_ui.go Outdated
Comment thread internal/daemon/controller/handler_ui.go Outdated
Comment thread internal/daemon/controller/handler_ui.go Outdated
Comment thread internal/daemon/controller/handler.go
Comment thread internal/daemon/controller/handler.go Outdated
@bgajjala8 bgajjala8 changed the title feat(ui): csp nonce handling feat(daemon): csp nonce handling Apr 13, 2026
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from 04be86c to 7166768 Compare April 13, 2026 19:38
irenarindos
irenarindos previously approved these changes Apr 14, 2026
Comment thread internal/daemon/controller/handler_ui.go Outdated
Comment thread internal/daemon/controller/handler.go Outdated
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from b59ff1c to 5631beb Compare April 20, 2026 19:42
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from 5631beb to a675c92 Compare April 20, 2026 19:44
@bgajjala8 bgajjala8 requested a review from irenarindos April 21, 2026 20:59
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch 2 times, most recently from 16a839d to e69f87b Compare April 22, 2026 01:05
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from e69f87b to a269242 Compare April 22, 2026 01:07
@bgajjala8 bgajjala8 force-pushed the bgajjala-nonce-csp-encoding branch from a269242 to 897bbe1 Compare April 22, 2026 01:13
Copy link
Copy Markdown
Collaborator

@ZedLi ZedLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works as expected for me!

@bgajjala8 bgajjala8 merged commit bf24d66 into main Apr 27, 2026
63 of 64 checks passed
@bgajjala8 bgajjala8 deleted the bgajjala-nonce-csp-encoding branch April 27, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants