Skillpedia
الأمان75k · #3041

subresource-integrity

ما الذي تفعله

تفحص هذه المهارة السكربتات والأنماط الخارجية في صفحة الويب وتضيف لها هاشات integrity. وهي موجهة إلى المطورين الذين يحمّلون كودًا من خارج خوادمهم.

متى تستخدمها

  • ✓عندما تحمّل الصفحة ملفات JavaScript أو CSS من CDN دون سمة integrity.
  • ✓عندما تراجع قوالب HTML تتضمن وسوم سكربت أو رابط خارجية.
  • ✓عندما يسأل أحدهم كيف يحمي الزوار إذا تعرضت CDN للاختراق.

رابط المهارة

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/subresource-integrity/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/subresource-integrity/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“موقعي يحمّل سكربتات من CDN. كيف أتأكد من أن أحدًا لا يستطيع استبدالها بكود ضار؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يجد الوكيل الملفات الخارجية التي لا تحمل بصمة ويضيف لها بصمة. ثم يقارن المتصفح كل ملف محمّل ببصمته، ويمنع أي ملف لا يطابقها.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Add Subresource Integrity to external scripts

When you load JavaScript from a CDN, you're trusting that CDN completely — if it's compromised, attackers can serve malicious JavaScript to all your users. SRI adds a cryptographic hash to the tag; the browser refuses to execute the script if the hash doesn't match the downloaded content, protecting users even if the CDN is compromised or the URL is hijacked.

Quick Reference

  • Add integrity="sha384-..." to <script> and <link> tags loading from CDNs
  • Always pair integrity with crossorigin="anonymous"
  • Generate hashes with openssl or online tools — CDN providers usually supply them
  • SRI blocks execution if the file hash doesn't match, preventing CDN compromise attacks

Check

Find all external <script> and <link rel=stylesheet> tags in this HTML that load from CDNs and don't have integrity attributes. List each one.

Fix

Add appropriate integrity and crossorigin attributes to external CDN resources. Generate the SHA-384 hashes for each resource.

Explain

Explain Subresource Integrity, how it protects against CDN compromise, how to generate SRI hashes, and its limitations.

Code Review

Review templates, server-rendered HTML, and shared components that output markup related to Add Subresource Integrity to external scripts. Flag exact elements, attributes, and routes where the rendered HTML violates the rule.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/html/subresource-integrity

الأسئلة الشائعة

ما هو هاش Subresource Integrity؟

هو رمز قصير يصف المحتوى الدقيق للملف. يقارنه المتصفح بالملف المحمّل قبل تشغيله.

هل أحتاج إلى هذا للملفات التي يستضيفها خادمي؟

تركز المهارة على ملفات CDN الخارجية. أما الملفات التي يستضيفها موقعك بنفسه فليست الهدف الأساسي هنا.

هل تذكر المهارة حدود هذه الطريقة؟

نعم. تشرح أيضًا قيودها، حتى تعرف ما يفعله الفحص وما لا يحميك منه.

التفاصيل

الوصف الأصلي من المؤلف

Use when reviewing templates, rendered HTML, or shared components related to Add Subresource Integrity to external scripts. Validate the final browser-facing markup, not just the source framework abstraction.

repo: thedaviddias/Front-End-Checklist

الشعبية

نجوم GitHub
75k
الترتيب
#3041
الترخيص
MIT
آخر تحديث
31‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة