---
name: fix-csp-compliance
description: |
Fix Content Security Policy (CSP) compliance issues that UI5 linter reports but cannot auto-fix. Use this skill when linter outputs:
- `csp-unsafe-inline-script` with message "Use of unsafe inline script"
Trigger on: inline JavaScript in HTML files, script tags without src attribute, onclick/onload handlers in HTML.
Also use when user mentions 'security headers', 'inline script warning', 'CSP policy', 'unsafe-inline', or 'Content-Security-Policy'.
Provides guidance on moving inline scripts to external files for CSP compliance.
---
# Fix CSP Compliance - Unsafe Inline Scripts
## Key Rules
1. **NEVER delete inline script content.** Always extract it to an external `.js` file and replace the inline `` with ``. Even trivial config objects, debug flags, or seemingly unused code must be externalized — removal is a functional regression.
2. File naming: use a descriptive name matching the content's purpose (e.g., `appConfig.js` for configuration, `init.js` for initialization).
This skill fixes Content Security Policy (CSP) compliance issues that the UI5 linter detects but cannot auto-fix because they require restructuring code into external files.
## Linter Rule Handled
| Rule ID | Message Pattern | Severity | This Skill's Action |
|---------|-----------------|----------|---------------------|
| `csp-unsafe-inline-script` | Use of unsafe inline script | Warning | Move to external JS file |
## When to Use
Apply this skill when you see linter output like:
```
index.html:15:5 warning Use of unsafe inline script csp-unsafe-inline-script
test.html:20:5 warning Use of unsafe inline script csp-unsafe-inline-script
```
## Background: Why CSP Matters
Content Security Policy (CSP) is a security feature that helps prevent:
- Cross-Site Scripting (XSS) attacks
- Data injection attacks
- Unauthorized script execution
Inline scripts are considered unsafe because an attacker who manages to inject HTML can also inject malicious JavaScript. CSP-compliant apps use `script-src 'self'` which blocks inline scripts.
Documentation: [Content Security Policy](https://ui5.sap.com/#/topic/fe1a6dba940e479fb7c3bc753f92b28c)
## Detection
The linter flags `
```
**Not flagged:**
```html
```
## Fix Strategy
The fix for every inline script is the same: **move it to an external file and add a `