Commit 68d7cd7
Reduce CSP inline style violations in drug stock webviews (#5786)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
**Story card:**
[SIMPLEBACK-95](https://rtsl.atlassian.net/browse/SIMPLEBACK-95)
## Because
`style-src-attr` and `style-src-elem` CSP
[violations](https://resolve-to-save-lives.sentry.io/organizations/resolve-to-save-lives/issues/3586002970/)
are among the highest-volume Sentry errors for Simple Server, with a
large concentration on the webview drug stock pages.
## This addresses
- Adds CSP nonce attributes to helper-generated inline assets:
- `inline_stylesheet`
- `inline_js`
- Removes inline `style="..."` attributes from the highest-traffic
webview templates:
- `app/views/webview/drug_stocks/new.html.erb`
- `app/views/webview/drug_stocks/index.html.erb`
- Adds a CSP nonce to the inline script in `webview/drug_stocks/new`.
- Removes inline `style` attributes from SVG assets used on that flow:
- `app/assets/images/chevron-left.svg`
- `app/assets/images/check-mark-small.svg`
## Test instructions
1. Open the drug stock webview pages:
- `/webview/drug_stocks/new`
- `/webview/drug_stocks`
2. Verify both pages render correctly (buttons, footer spacing, icons).
3. Inspect page source/DOM and confirm there are no inline `style="..."`
attributes on the modified elements.
4. Confirm helper-generated inline `<style>` / `<script>` tags include a
`nonce` attribute.
5. Monitor Sentry issues `SIMPLE-SERVER-1RQ` and `SIMPLE-SERVER-1RR`
after deploy for a drop in new events.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Igbanam <igbanam@users.noreply.github.com>1 parent 5637546 commit 68d7cd7
5 files changed
Lines changed: 16 additions & 11 deletions
File tree
- app
- assets/images
- helpers
- views/webview/drug_stocks
Loading
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
2 | 7 | | |
3 | 8 | | |
4 | 9 | | |
| |||
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
12 | | - | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | | - | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
| 121 | + | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
0 commit comments