Skip to content

Enable Content Security Policy for AWBW#1491

Draft
lenikadali wants to merge 1 commit intomainfrom
enable-content-security-policy
Draft

Enable Content Security Policy for AWBW#1491
lenikadali wants to merge 1 commit intomainfrom
enable-content-security-policy

Conversation

@lenikadali
Copy link
Copy Markdown
Collaborator

@lenikadali lenikadali commented Apr 24, 2026

Closes #261

What is the goal of this PR and why is this important?

Enables Content Security Policy for AWBW based on what we're already using in the codebase.
The code is mostly vanilla Rails with minimal to no JavaScript so much of the Rails defaults have been removed.
We're adding this so that AWBW is not vulnerable to Cross-site scripting (XSS) attacks.

How did you approach the change?

I reviewed the issue, then read up on how Rails handles CSP configuration and compared the different options available to what the AWBW code is using. Important notes:

  • <%= csp_meta_tag %> is used when considering using 'unsafe-inline' as per Rails guide here. Since we are not considering using 'unsafe-inline' and it is not already used in the codebase, it has been omitted from the initial configuration.
  • As far as I can tell, we are not using Vite and JavaScript in a way that requires configurations related to them, so they have been removed.

Anything else to add?

I could have left in the Vite/JavaScript lines but removing them keeps the file cleaner and easy to read for someone looking at it. Happy to restore the lines if there's a preference for preserving them 😄

Enables Content Security Policy for AWBW based on
what we're already using in the codebase (the code
is mostly vanilla Rails with minimal to no JavaScript)
so much of the Rails defaults have removed.
@lenikadali
Copy link
Copy Markdown
Collaborator Author

Some tests are broken; going to look into them and fix. For now, switching to draft.

@lenikadali lenikadali marked this pull request as draft April 24, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update content security policy in layouts/application.html.erb

1 participant