Unchecked Error Condition
The product does not properly check when a function or operation returns a value that is associated with an error condition.
When error conditions are not checked, the application may continue with invalid or unexpected state, potentially leading to crashes, data corruption, or security vulnerabilities.
इस भेद्यता को कैसे ठीक करें
3 Shoulder डिटेक्शन नियमों पर आधारित Unchecked Error Condition के लिए रोकथाम रणनीतियाँ।
Log or return errors instead of silently swallowing them
_, err := db.Exec("DELETE FROM sessions WHERE expired = true") if err != nil { + log.Printf("session cleanup failed: %v", err) + return err }
Always handle promise rejections with .catch() or try/catch in async functions
app.post('/create', async (req, res) => { - const user = await User.create(req.body); - res.json(user); + try { + const user = await User.create(req.body); + res.json(user); + } catch (error) { + logger.error('User creation failed:', error); + res.status(500).json({ error: 'Could not create user' }); + } });
Log exceptions or handle them explicitly instead of silently swallowing with pass
- def get_data(): - try: - data = fetch_sensitive_data() - return {'data': data} - except: - pass + import logging + + logger = logging.getLogger(__name__) + + def get_data(): + try: + data = fetch_sensitive_data() + return {'data': data} + except Exception as e: + logger.error(f"Failed to fetch data: {e}", exc_info=True) + return {'error': 'Data unavailable'}, 500
अपने कोड में भेद्यताएँ खोजें
Unchecked Error Condition पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 3 नियम.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=391 # Or scan entire project npx @shoulderdev/cli trust .
पहचान नियम (3)
कोड समीक्षा में किन बातों पर ध्यान दें
ये पैटर्न संभावित Unchecked Error Condition भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।
अपने कोडबेस को इसके लिए स्कैन करें: Unchecked Error Condition
Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।