بنقرة واحدة
csp-debug
Debug Content Security Policy (CSP) and Subresource Integrity (SRI) issues in the jmrp.io project
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Debug Content Security Policy (CSP) and Subresource Integrity (SRI) issues in the jmrp.io project
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Build, preview, and verify the jmrp.io Astro 7 project. Use when asked to build, deploy, or run the QA pipeline.
Scaffold and write a new MDX blog post. Use when asked to create a blog post, write an article, or add content to the posts collection.
Create a new reusable Astro UI component in src/components/ui/. Use when asked to add a component, build a UI element, or extend the component library.
Run accessibility audits and fix WCAG 2.2 AA violations. Use when asked about accessibility, a11y, WCAG, or axe-core issues.
Add or update translations for the EN/ES bilingual system. Use when asked about translations, missing keys, locale routing, hardcoded strings, or adding a new language.
| name | csp-debug |
| description | Debug Content Security Policy (CSP) and Subresource Integrity (SRI) issues in the jmrp.io project |
| argument-hint | [issue: violation|nonce|sri|headers|all] |
Debug and fix Content Security Policy and SRI issues in the jmrp.io Astro 7 project.
This project uses a nonce-only CSP strategy:
NGINX_CSP_NONCE placeholder with $cspNonce per-requestsecurity_headers.conf — For HTML pages (nonce in script-src + style-src + strict-dynamic)security_headers_assets.conf — For static assets (default-src 'none', no nonces)| File | Purpose |
|---|---|
src/integrations/post-build/csp.ts | Generates security_headers.conf and security_headers_assets.conf |
src/integrations/post-build/html.ts | Adds SRI integrity hashes, nonce attributes, inline style → class |
src/integrations/vite-plugin-prefetch-nonce.ts | Patches Astro's appendSpeculationRules for CSP nonce compliance |
src/components/ui/SRIEventListener.astro | SRI integrity for inline event listeners |
scripts/csp-reporter.mjs | CSP violation receiver with Telegram notifications |
tests/security.spec.ts | E2E tests verifying CSP/SRI on all pages |
Problem: <script> without nonce attribute.
Fix: Use <script is:inline> in Astro components (post-build adds nonce automatically).
Check: Search for <script tags missing is:inline in .astro files.
Problem: style="..." inline attributes break CSP style-src.
Fix: Use UnoCSS utility classes or scoped <style> blocks.
Check:
grep -rn 'style="' src/components/ src/layouts/ src/pages/ --include="*.astro" | grep -v '<style'
Problem: External <script src> or <link rel="stylesheet"> without integrity attribute.
Fix: The post-build pipeline auto-generates SRI hashes. Rebuild with pnpm build.
Problem: data: URIs in CSS or HTML break strict CSP.
Fix: The post-build pipeline extracts data URIs to physical files (src/integrations/post-build/css.ts).
Problem: Astro's prefetch injects <script type="speculationrules"> without nonce.
Fix: The Vite plugin vite-plugin-prefetch-nonce.ts handles this automatically.
pnpm test:e2e --grep "security"
cat dist/security_headers.conf
grep -rn 'integrity=' dist/ --include="*.html" | head -20
grep -rn 'style="' src/ --include="*.astro" | grep -v '<style' | grep -v '<!--'
grep -rn 'NGINX_CSP_NONCE' dist/ --include="*.html" | head -10
TELEGRAM_BOT_TOKEN=xxx TELEGRAM_CHAT_ID=xxx node scripts/csp-reporter.mjs
<script> tags — they break CSP nonce-only policystyle="..." attributes — use UnoCSS utility classespnpm preview, not pnpm devrel="external noopener noreferrer" + target="_blank"safeJsonLd() from @utils/html to prevent XSSFor security issues beyond CSP/SRI (code smells, vulnerabilities, hotspots), use SonarCloud:
SONAR_PROJECT_KEY=jmrplens_jmrp.io node scripts/ci/get-sonar-issues.mjs
Requires SONAR_TOKEN env var. Reports open issues and TO_REVIEW security hotspots.
https://sonarcloud.io/dashboard?id=jmrplens_jmrp.io
SonarLint connected mode is configured in .vscode/settings.json — provides real-time security issue detection in the editor.
sonar-project.properties for CI scripts with validated inputs