Conversation
This commit introduces a robust Content Security Policy (CSP) for the application, following modern security best practices and supporting both standalone and engine deployment models. Key changes: - Defined application-wide CSP in `config/initializers/content_security_policy.rb`. - Implemented a secure, per-request nonce generator (`SecureRandom.base64(16)`). - Configured allowlists for essential external resources: - `unpkg.com` for Leaflet assets. - `secure.gravatar.com` for user avatars. - `*.openstreetmap.org` for map tiles. - Enabled `report_only` mode for initial rollout to identify potential issues without breaking functionality. - Explicitly allowed `http` in the development environment to support non-SSL local setups. - Converted legacy HAML `:javascript` filters and `%style` tags to Rails `javascript_tag` and `tag.style` helpers with nonces. - Unified the nonce-based script handling across main and admin layouts, resolving issues with nested script tags and ensuring consistent execution. - Maintained support for `style` attributes by including `:unsafe_inline` in the `style-src` directive while still providing nonces for style blocks. - Refactored helper methods like `get_browser_timezone_offset` and `load_select_popups_for` to be CSP-compliant. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| end | ||
|
|
||
| # Generate session nonces for permitted importmap and inline scripts | ||
| config.content_security_policy_nonce_generator = ->(request) { SecureRandom.base64(16) } |
Check warning
Code scanning / Rubocop
Checks for unused block arguments. Warning
|
|
||
| # Generate session nonces for permitted importmap and inline scripts | ||
| config.content_security_policy_nonce_generator = ->(request) { SecureRandom.base64(16) } | ||
| config.content_security_policy_nonce_directives = %w(script-src style-src) |
Check notice
Code scanning / Rubocop
Use `%`-literal delimiters consistently. Note
Enabled Content Security Policy (CSP) in Fat Free CRM using nonces for inline scripts and styles. The policy is initially set to report-only mode and includes allowlists for Gravatar, Leaflet, and OpenStreetMap. It also handles environment-specific rules for local development.
PR created automatically by Jules for task 330213784843227832 started by @CloCkWeRX