बीटा Shoulder बीटा में है — परिणाम कभी-कभी गलत हो सकते हैं। आपकी प्रतिक्रिया तय करती है कि हम आगे क्या ठीक करें। प्रतिक्रिया साझा करें

Unchecked Error Condition

🛡️ 3 नियम इसे पहचानते हैं

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 भाषाएँ कवर की गईं
प्रभाव
उच्च
1 उच्च गंभीरता वाले नियम
रोकथाम
प्रलेखित
3 फिक्स उदाहरण
2 रोकथाम
2 रोकथाम

इस भेद्यता को कैसे ठीक करें

3 Shoulder डिटेक्शन नियमों पर आधारित Unchecked Error Condition के लिए रोकथाम रणनीतियाँ।

Empty Error Handling LOW

Log or return errors instead of silently swallowing them

+2 -0 go
  _, err := db.Exec("DELETE FROM sessions WHERE expired = true")
  if err != nil {
+     log.Printf("session cleanup failed: %v", err)
+     return err
  }
  
Unhandled Promise Rejection HIGH

Always handle promise rejections with .catch() or try/catch in async functions

+7 -2 javascript
  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' });
+   }
  });
  
Empty Exception Handler MEDIUM

Log exceptions or handle them explicitly instead of silently swallowing with pass

+11 -6 python
- 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
  
3 पहचान
3 पहचान

अपने कोड में भेद्यताएँ खोजें

Unchecked Error Condition पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 3 नियम.

टर्मिनल
# Scan with Shoulder CLI
npx @shoulderdev/cli trust --cwe=391

# Or scan entire project
npx @shoulderdev/cli trust .
4 चेतावनी संकेत
4 चेतावनी संकेत

कोड समीक्षा में किन बातों पर ध्यान दें

ये पैटर्न संभावित Unchecked Error Condition भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।

🟠
Promise at ... lacks rejection handler (.catch or try-catch) javascript-unhandled-promise-rejection
🟠
promises that are created or called without proper rejection handlers javascript-unhandled-promise-rejection
🟡
empty except blocks that silently swallow exceptions python-empty-except-block
🔍

अपने कोडबेस को इसके लिए स्कैन करें: Unchecked Error Condition

Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।