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

Customize CSP for HTML preview #1510

Closed
rocec opened this issue Jan 10, 2024 · 7 comments
Closed

Customize CSP for HTML preview #1510

rocec opened this issue Jan 10, 2024 · 7 comments

Comments

@rocec
Copy link

rocec commented Jan 10, 2024

Why the new feature should be added

As a user, I would like to add additional trusted sources to the CSP (Consent Security Policy). This would allow previewing pages with embedded content, e.g. from intranet sites in a corporate environment.

How the new feature should work

Add an option "Additional CSP frame sources" to the plugin settings. Its value shall be added to the CSP used by the HTML preview.

@ahus1
Copy link
Contributor

ahus1 commented Jan 10, 2024

Thank you for suggesting this. This might pose a security or privacy risk, and might trick users into doing things with unintended consequences. Therefore I'm sceptical.

Please provide a more detailed example (possibly with code) showing which content can't be included.

@ahus1
Copy link
Contributor

ahus1 commented Jan 10, 2024

Might be related: #1508

@rocec
Copy link
Author

rocec commented Jan 11, 2024

My use case is embedding Structurizr diagrams to provide a live view with interactive exploration. This is done using iframes; see Embedding diagrams in the Structurizr docs.

An example in AsciiDoc:

= Embed Structurizr

++++
<iframe id="myEmbeddedDiagram" src="https://structurizr.com/embed/36141?diagram=SystemContext&amp;diagramSelector=false&amp;iframe=myEmbeddedDiagram" width="602px" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" allowfullscreen="true" height="424px"></iframe>
<script type="text/javascript" src="https://static.structurizr.com/js/structurizr-embed.js"></script>
++++

In the IntelliJ JCEF preview, I see the following error in the dev console:

Refused to frame 'https://structurizr.com/' because it violates the following Content Security Policy directive: "frame-src 'self' https://player.vimeo.com/ https://www.youtube.com/".

As a workaround, instead of viewing it directly in the IntelliJ preview, I can convert my file to HTML and open it in a browser.

@ahus1
Copy link
Contributor

ahus1 commented Mar 24, 2024

Thank you for this example. The next version of the plugin adds https://structurizr.com/ to the list of allowed domains to show content in an iframe. I'll update this issue once a pre-release is available.

@ahus1 ahus1 closed this as completed Mar 24, 2024
ahus1 added a commit that referenced this issue Mar 24, 2024
@ahus1
Copy link
Contributor

ahus1 commented Mar 24, 2024

The release 0.41.11 which includes this change will be available in the JetBrains marketplace later today.

@rocec
Copy link
Author

rocec commented Apr 2, 2024

Allowing https://structurizr.com/ does not help if you have a custom on-prem installation of Structurizr, e.g. in a corporate network.

I think a configurable allow list is desirable.

Of course, as you said, this may pose a security or privacy risk if used incorrectly. Plus, this feature suggestion issue is just a nice-to-have from my point of view, as it is presumably seldom needed, and there is a workaround (open HTML in external browser).

@rocec
Copy link
Author

rocec commented Apr 2, 2024

In any case, thank you very much, not only in this context, but in general for the great work and the continuous support of the entire plugin!

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

No branches or pull requests

2 participants