You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "pkliczewski (via GitHub)" <gi...@apache.org> on 2025/07/03 16:17:20 UTC

[I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

pkliczewski opened a new issue, #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197

   The workflow editor sources served statically by the orchestrator backend can only run by configuring the following csp for backstage backend:
   
   ```
    script-src: ["'self'", "'unsafe-inline'", "'unsafe-eval'"] 
    script-src-elem: ["'self'", "'unsafe-inline'", "'unsafe-eval'"] 
    connect-src: ["'self'", 'http:', 'https:', 'data:']
   ```
   
   See:
   https://github.com/parodos-dev/orchestrator-helm-chart/blob/main/charts/orchestrator/templates/rhdh-operator.yaml#L86


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "batzionb (via GitHub)" <gi...@apache.org>.
batzionb commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3112679176

   @handreyrc that sounds good. Let's focus on getting the React component ASAP.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento closed issue #3197: enable workflow viewer without requiring unsafe csp policies
URL: https://github.com/apache/incubator-kie-tools/issues/3197


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "pkliczewski (via GitHub)" <gi...@apache.org>.
pkliczewski commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3187295539

   @handreyrc @treblereel this is blocking issue for us. when we can have it fixed?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "treblereel (via GitHub)" <gi...@apache.org>.
treblereel commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3105816985

   Technically speaking, the Closure Compiler can include any provided JavaScript directly into the final build, so it's possible to avoid using ScriptInjector altogether


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "batzionb (via GitHub)" <gi...@apache.org>.
batzionb commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3044576449

   Adding some more details:
   
   The csp exceptions that need to be added to enable the editor are:
   
   script-src:' 'unsafe-inline'
   connect-src:  'data:'
   
   These are not enabled by default in a standard csp header.
   
   To reproduce, you need to serve the files from a webserver which contains a starndard secure csp for example:
   
   Content-Security-Policy: 
     default-src 'self';
     script-src 'self';
     style-src 'self';
     img-src 'self' data:;
     font-src 'self';
     object-src 'none';
     frame-ancestors 'none';
     base-uri 'self';
     connect-src 'self';
     form-action 'self';
     frame-src 'none';
     media-src 'self';
     manifest-src 'self';
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "handreyrc (via GitHub)" <gi...@apache.org>.
handreyrc commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3104976643

   @batzionb I investigated the issue and the root cause is how resources such as css and scripts are being added to the DOM in runtime by the diagram editor's core. 
   
   GWT uses script / style injector that fetches the \<HEAD\> from the DOM and literally injects text / content into it at runtime. The catch is that same approach was ported to our current  J2CL implementation of the editor.  The issue is not only a matter of including those resources in the DOM,  we also need to make them available to java code otherwise we cannot consume jquery, booststrap, patternfly... 
   Take a look how it works : [StunnerLienzoCore.java](https://github.com/apache/incubator-kie-tools/blob/main/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/StunnerLienzoCore.java#L51)
   
   The CSP error message implies that to make those resources safe we need to add a hash / nonce to them so they would be allowed to run. Following that approach I added a webpack plugin "CspHtmlWebpackPlugin" that in compiling time would scan from scripts and styles included and then add a nonce to all of them. It works fine, however, the scripts being blocked are being added at runtime and would still be blocked by rhdh CSP polices. 
   Aiming to solve this issue, there is a way to extend permissions from a parent script to its child scripts by adding "strict-dynamic" to CSP header. The interesting part in this approach is that we have the rhdh CSP coming from the http header and the CSP \<META\> tag added to the resulting html by the  "CspHtmlWebpackPlugin". Despite of the browser combining both CSPs sources there are rules to be observed. The more strict police always wins. It means that we can tighten up rules via  \<META\> tag but we cannot relax them. In this case "strict-dynamic" loses to rhdh CSP rules and has no effect.
   
   That being said I don't see any fixes by tunning CSP parameters on the editor side.
   
   The remaing solution is to remove the script injector usages and then reengineer the way scrips are included and made available to java code in the diagram editor.  For example, somehow find a way to include those scripts statically and then build elemental interfaces to bridge the access to js native resources from java code. 
   The CSP did not complain about the styles and fonts also being included, however, they can be and issue as well once the script issue is fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "batzionb (via GitHub)" <gi...@apache.org>.
batzionb commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3106154918

   @handreyrc thanks for all the details. 
   How will it work after the rewrite to react?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-4920026398

   Closing due to https://github.com/apache/incubator-kie-tools/pull/3540


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "treblereel (via GitHub)" <gi...@apache.org>.
treblereel commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3184555018

   > [@batzionb](https://github.com/batzionb) With the ts / react inplementation of the editor it is very unlikely to be an issue. This kind of approach that caused the issue is sort of a GWT thing. By that time they did it that way to make it easier to include resources and reuse them on java side of the code. Anyway, it is something I can test just in case.
   
   This statement is at the very least debatable. The idea of inserting tags (in this case, <script>) into the DOM from code appeared as soon as such a capability became available.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "pkliczewski (via GitHub)" <gi...@apache.org>.
pkliczewski commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3195758996

   @handreyrc I asked the team to verify


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "handreyrc (via GitHub)" <gi...@apache.org>.
handreyrc commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3108758108

   @batzionb With the ts / react inplementation of the editor it is very unlikely to be an issue. 
   This kind of approach that caused the issue is sort of a GWT thing. By that time they did it that way to make it easier to include resources and reuse them on java side of the code. 
   Anyway, it is something I can test just in case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] enable workflow viewer without requiring unsafe csp policies [incubator-kie-tools]

Posted by "handreyrc (via GitHub)" <gi...@apache.org>.
handreyrc commented on issue #3197:
URL: https://github.com/apache/incubator-kie-tools/issues/3197#issuecomment-3194841284

   @pkliczewski We got a possible fix for the issue. 
   
   Instead of injecting the scrips at runtime causing issues with rhdh CSP,  we are now merging those scripts with the editor's built js.  We have a sort of a js bundle.
   
   It works fine with rhdh CSP polices enabled locally.
   
   Could you help us validating this solution with the actual rhdh?
   
   [PR-3226](https://github.com/apache/incubator-kie-tools/pull/3226)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org