Repository navigation
OCPBUGS-45525: Expand CSP dev-mode documentation for plugin authors #17430
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
Open
redhat-chai-bot
wants to merge
1
commit into
openshift:main
Choose a base branch
from
redhat-chai-bot:OCPBUGS-45525-csp-dev-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -456,7 +456,9 @@ To launch the server using the built image, you can run: | |
| docker run -p 8081:8081 downloadsserver:latest | ||
| ``` | ||
|
|
||
| ## ContentSecurityViolation Detection | ||
| ## Content Security Policy | ||
|
|
||
| ### Violation Detection | ||
|
|
||
| The console application automatically reports CSP violations to telemetry. This detection and | ||
| reporting logic attempts to parse a dynamic plugin name from the securitypolicyviolation event to | ||
|
|
@@ -468,28 +470,33 @@ violation. If a plugin name is not determined in this way, an empty plugin name | |
| Additionally, violation reporting is throttled to prevent spamming the telemetry service with | ||
| repetitive data. Identical violations will not be reported more than once a day. | ||
|
|
||
| ### Configuring For Development | ||
|
|
||
| Bridge defaults to `--csp-mode=report-only`, which emits the | ||
| `Content-Security-Policy-Report-Only` HTTP header. Use `--csp-mode=enforce` to emit | ||
| `Content-Security-Policy` HTTP header and block resources that violate the policy. Both modes | ||
| use the same CSP directives. Restart Bridge with `--csp-mode=report-only` to roll back | ||
| enforcement. Invalid mode values prevent startup. | ||
|
|
||
| In case of local developement of the dynamic plugin, just pass needed CSP directives address to the console server, using the `--content-security-policy` flag. | ||
| #### Supported directives | ||
|
|
||
| Example: | ||
| The accepted CSP directive types mirror those defined in the | ||
| [openshift/api repository](https://github.com/openshift/api/blob/master/console/v1/types_console_plugin.go#L101-L132). | ||
| Using a directive not in that list causes the server to exit with a fatal error. | ||
|
|
||
| ``` | ||
| ./bin/bridge --content-security-policy script-src='localhost:1234',font-src='localhost:2345 localhost:3456' | ||
| ``` | ||
| The following directives are always appended by the console server and cannot be | ||
| overridden: | ||
| - `object-src 'none'` | ||
| - `frame-src 'none'` | ||
| - `frame-ancestors 'none'` | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. openshift/api#3128 adds additional directives that should be documented here |
||
|
|
||
| List of configurable CSP directives is available in the [openshift/api repository](https://github.com/openshift/api/blob/master/console/v1/types_console_plugin.go#L102-L137). | ||
| #### Practical example | ||
|
|
||
| The list is extended automatically by the console server with following CSP directives: | ||
| - `"frame-src 'none'"` | ||
| - `"frame-ancestors 'none'"` | ||
| - `"object-src 'none'"` | ||
| **Plugin loading scripts and enabling hot-reload from its dev server** (e.g., `http://localhost:9001`): | ||
|
|
||
| Currently this feature is behind feature gate. | ||
| ``` | ||
| ./bin/bridge --content-security-policy script-src='localhost:9001',connect-src='ws://localhost:9001' | ||
| ``` | ||
|
|
||
| ## Frontend Packages | ||
| - [console-dynamic-plugin-sdk](./frontend/packages/console-dynamic-plugin-sdk/README.md) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context: the original implementation used
object-src 'none'. @jhadvig changed it to'self'in commit43c9c36f009c(April 2025) as part of OCPBUGS-49291, which restructured how CSP directives are built. This doc update aligns with that code change.AI-generated. Review for accuracy.