content-security-policy
यह क्या करती है
यह स्किल Content Security Policy जाँचती और बनाती है, यानी ब्राउज़र नियमों का सेट जो अनुमति न प्राप्त कोड और संसाधन रोकते हैं। यह cross-site scripting के खिलाफ़ अतिरिक्त सुरक्षा चाहने वाले डेवलपर के लिए है।
कब इस्तेमाल करें
- ✓जब आपकी साइट में content security policy हेडर नहीं है।
- ✓जब इनलाइन स्क्रिप्ट या असुरक्षित सेटिंग्स इस्तेमाल हो रही हों।
- ✓जब आपका ऐप उपयोगकर्ता के दिए HTML को पेज में डालता है।
Skill का लिंक
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/content-security-policy/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी साइट के लिए content security policy सेट करें, जो अज्ञात स्क्रिप्ट रोके, और उसे लागू करने से पहले परखें।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट एक ऐसी policy सुझाता है जो पहले सिर्फ़ रिपोर्ट मोड में शुरू होती है, इनलाइन स्क्रिप्ट के लिए nonce या hash इस्तेमाल करती है, असुरक्षित सेटिंग्स से बचती है, और अविश्वसनीय HTML के लिए sanitizing जोड़ती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Implement a content security policy
Content Security Policy prevents cross-site scripting (XSS), clickjacking, and data injection attacks by controlling which resources can be loaded and executed on your pages. It reduces blast radius, but it does not replace output encoding and sanitization.
Quick Reference
- Start with Content-Security-Policy-Report-Only to test without breaking your site
- Use nonces or hashes for inline scripts instead of unsafe-inline
- Avoid unsafe-eval unless absolutely necessary
- Set strict default-src then allow specific sources
- Monitor CSP reports to catch violations
- Sanitize untrusted HTML before rendering it into the DOM
- Use Trusted Types in larger apps as defense in depth for DOM XSS sinks
Check
Check if this website implements a Content Security Policy header and analyze its directives. Also review any use of innerHTML, dangerouslySetInnerHTML, HTML template injection, and Trusted Types enforcement for large applications.
Fix
Implement a strict Content Security Policy to prevent XSS attacks and control resource loading. Sanitize untrusted HTML before rendering and add Trusted Types enforcement where the application has enough DOM injection surface to benefit from it.
Explain
Explain how CSP provides a security layer that helps detect and mitigate XSS and data injection attacks, and why sanitization is still required before rendering untrusted HTML.
Code Review
Review server config, headers, forms, and integration points related to Implement a content security policy. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response. Inspect HTML injection sinks and note whether Trusted Types or sanitization protects them.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/security/content-security-policy
अक्सर पूछे जाने वाले सवाल
क्या मुझे policy तुरंत लागू करनी चाहिए?
नहीं। स्किल साइट तोड़े बिना परखने के लिए पहले सिर्फ़ रिपोर्ट मोड में शुरू करने की सिफ़ारिश करती है।
क्या content security policy sanitizing की जगह लेती है?
नहीं। स्किल कहती है कि यह हमलों का असर घटाती है, लेकिन output encoding और sanitization की जगह नहीं लेती।
Trusted Types क्या है?
स्किल इसे बड़े ऐप के लिए एक अतिरिक्त बचाव बताती है, जो पेज में HTML डालते हैं।
जानकारी
लेखक का मूल विवरण
Use when reviewing headers, forms, cookies, or third-party integrations related to Implement a content security policy. Validate the effective browser and HTTP behavior in a production-like environment.
लोकप्रियता
- GitHub स्टार
- 75k
- रैंकिंग में स्थान
- #2785
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
frontendchecklist
75kकमांड-लाइन टूल से फ़्रंटएंड कोड और लाइव पेजों को एक्सेसिबिलिटी, स्पीड, SEO और सिक्योरिटी के 380 से ज़्यादा नियमों से जाँचती है।
frontend-checklist-global
75kफ़्रंटएंड प्रोजेक्ट को Front-End Checklist के सभी 386 नियमों से ऑडिट करती है, और हर मिली समस्या का ठोस समाधान देती है।
404-page
75kजाँचती है कि आपका गुम पेज उपयोगी लिंक देता है और सही 404 स्टेटस लौटाता है, ताकि भटके हुए विज़िटर रास्ता ढूँढ सकें।
about-page
75kजाँचती है कि आपकी साइट पर एक साफ़ About पेज है जो बताता है कि उसे कौन चलाता है, ताकि विज़िटर और सर्च इंजन का भरोसा बढ़े।
मिलती-जुलती skills
reverse-engineer-anything
422kयह आपके एजेंट को REA टूल से शिप हुई ऐप्स और पैकेज को अंदर से समझने, वर्ज़न की तुलना करने या दोबारा बनाने में मदद करती है।
1password
394kयह आपके एजेंट को 1Password CLI सेट करने, साइन इन करने और सीक्रेट्स की वैल्यू चैट में छापे बिना उन्हें पढ़ने या इस्तेमाल करने में मदद करती है।
healthcheck
394kयह आपके एजेंट को उस कंप्यूटर या सर्वर का सुरक्षा ऑडिट करने देती है जिस पर OpenClaw चलता है, जिसमें SSH, firewall, अपडेट और बैकअप शामिल हैं, और फिर सुरक्षित सुधार सुझाती है।