BETA Shoulder está en beta — Los hallazgos a veces pueden ser incorrectos. Tu feedback da forma a lo que arreglamos a continuación. Compartir comentarios

Unchecked Error Condition

🛡️ 3 reglas detectan esto

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.

Prevalencia
Media
3 lenguajes cubiertos
Impacto
Alto
1 reglas de severidad alta
Prevención
Documentada
3 ejemplos de corrección
2 Prevención
2 Prevención

Cómo corregir esta vulnerabilidad

Estrategias de prevención para Unchecked Error Condition basadas en 3 reglas de detección de Shoulder.

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
  
4 Señales de Alerta
4 Señales de Alerta

Qué buscar en las revisiones de código

Estos patrones indican vulnerabilidades potenciales de Unchecked Error Condition. Búscalos durante las revisiones de código y auditorías de seguridad.

🟠
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
🔍

Escanea tu base de código para Unchecked Error Condition

Shoulder CLI encuentra patrones vulnerables en toda tu base de código.