OTWO-7715 CSP misconfigured — unsafe-inline, unsafe-eval, overly broa… - #1945
Open
Niharika1117 wants to merge 2 commits into
Open
OTWO-7715 CSP misconfigured — unsafe-inline, unsafe-eval, overly broa…#1945Niharika1117 wants to merge 2 commits into
Niharika1117 wants to merge 2 commits into
Conversation
…d :https source, missing base-uri and form-action directives
There was a problem hiding this comment.
Pull request overview
This PR tightens the application’s Content Security Policy (CSP) to remove unsafe script allowances and migrate inline scripts to nonce-based execution, while also adding missing CSP hardening directives.
Changes:
- Removes
unsafe-inline/unsafe-evalfromscript-src, adds nonce generation/config, and addsbase-uri+form-actiondirectives. - Updates multiple HAML templates to attach CSP nonces to inline scripts (and converts some
:javascriptfilters to explicit nonce-bearing<script>blocks). - Replaces
setTimeout("...")string-eval patterns with function callbacks in several JS assets and forces Google Maps script loading over HTTPS.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| config/initializers/content_security_policy.rb | Updates CSP directives, script allowlist, and enables nonce-based inline scripts. |
| app/views/projects/estimated_cost.html.haml | Adds CSP nonce to an inline script block. |
| app/views/project_widgets/_users_logo_js.html.haml | Replaces :javascript with a nonce-bearing <script> block. |
| app/views/project_widgets/_project_users_js.html.haml | Emits inline JS via javascript_tag(..., nonce: true) with a heredoc. |
| app/views/project_widgets/_ohloh_code_header.html.haml | Replaces :javascript with a nonce-bearing <script> block. |
| app/views/project_widgets/_cocomo_js.html.haml | Replaces :javascript with a nonce-bearing <script> block. |
| app/views/project_licenses/new.html.haml | Adds nonce: true to a javascript_tag emitted via content_for :javascript. |
| app/views/oh_admin/license_permissions/new.html.haml | Converts inline JS to a nonce-bearing <script> block. |
| app/views/layouts/tracking_scripts/_google_analytics.html.haml | Adds CSP nonce to the inline Google Analytics configuration script. |
| app/views/factoids/index.html.haml | Adds nonce: true to an inline javascript_tag. |
| app/helpers/map_helper.rb | Forces HTTPS for Google Maps loader and adds nonce to inline initialization JS. |
| app/assets/javascripts/project.js | Replaces string-based setTimeout with a function callback. |
| app/assets/javascripts/ohloh_suggests.js | Replaces string-based setTimeout with function callbacks. |
| app/assets/javascripts/admin.js | Replaces string-based setTimeout with a function callback. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…d :https source, missing base-uri and form-action directives