मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी75k · #2753

avoid-eval

यह क्या करती है

यह स्किल कोड में eval और टेक्स्ट को कोड की तरह चलाने के दूसरे तरीकों का उपयोग जाँचती है। यह उन डेवलपर के लिए है जो वेबसाइट पर होने वाले एक आम और गंभीर हमले को रोकना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आपके कोड में eval या new Function मिले।
  • ✓जब किसी टाइमर को चलाने के लिए टेक्स्ट स्ट्रिंग दी जाती है।
  • ✓जब आप ऐसे कोड की समीक्षा कर रहे हों जो उपयोगकर्ताओं का डेटा संभालता है।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/avoid-eval/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे प्रोजेक्ट में eval कॉल खोजें और उन्हें सुरक्षित कोड से बदलें।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट कोड में eval, new Function और टेक्स्ट स्ट्रिंग वाले टाइमर खोजता है, फिर उन्हें JSON पार्सिंग, ऑब्जेक्ट लुकअप या फ़ंक्शन रेफ़रेंस से बदलता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Never use eval() or unsafe dynamic code execution

eval() and its equivalents are the root cause of some of the most severe XSS vulnerabilities. If any user-controlled string reaches eval(), an attacker can execute arbitrary JavaScript in your users' browsers — stealing sessions, making requests as the user, or redirecting to malicious sites. Content Security Policy (CSP) blocks eval() but not new Function(), and there is never a legitimate use case that can't be solved without it.

Quick Reference

  • eval() executes arbitrary strings as code — any user input passed to it is a critical security hole
  • new Function() is equally dangerous and not caught by CSP eval restrictions
  • setTimeout('code', delay) and setInterval('code', delay) also evaluate strings — use function references instead
  • Use JSON.parse() instead of eval() for parsing JSON

Check

Search this codebase for any use of eval(), new Function(), or setTimeout/setInterval with string arguments.

Fix

Replace eval() calls with safe alternatives: JSON.parse for data, object lookups for dynamic dispatch, and Function references for timers.

Explain

Explain why eval() is dangerous, how it enables XSS attacks, and what safe alternatives exist for each use case.

Code Review

Review scripts, client components, and browser execution paths related to Never use eval() or unsafe dynamic code execution. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


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

Rule page: https://frontendchecklist.io/rules/javascript/avoid-eval

अक्सर पूछे जाने वाले सवाल

eval खतरनाक क्यों है?

स्किल कहती है कि अगर उपयोगकर्ता का इनपुट eval तक पहुँचे, तो हमलावर दूसरे विज़िटर के ब्राउज़र में JavaScript चला सकता है।

क्या content security policy इसे रोकती है?

स्किल कहती है कि CSP eval को रोकती है, लेकिन new Function को नहीं, इसलिए दोनों को कोड से हटाना होगा।

JSON को पार्स करने के लिए क्या इस्तेमाल करें?

JSON.parse, जिसकी स्किल eval के बजाय सिफ़ारिश करती है।

जानकारी

लेखक का मूल विवरण

Use when reviewing scripts, client components, bundles, or runtime behavior related to Never use eval() or unsafe dynamic code execution. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

लोकप्रियता

GitHub स्टार
75k
रैंकिंग में स्थान
#2753
लाइसेंस
MIT
अपडेट की गई
31/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills