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.
Jak naprawić tę podatność
Strategie zapobiegania dla Unchecked Error Condition oparte na 3 regułach detekcji Shoulder.
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
Znajdz podatnosci w swoim kodzie
Uzyj Shoulder do skanowania kodu w poszukiwaniu wzorcow Unchecked Error Condition. 3 reguly.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=391 # Or scan entire project npx @shoulderdev/cli trust .
Reguly Wykrywania (3)
Na co zwracac uwage podczas przegladu kodu
Te wzorce wskazuja na potencjalne podatnosci Unchecked Error Condition. Szukaj ich podczas przegladow kodu i audytow bezpieczenstwa.
Przeskanuj swój kod w poszukiwaniu Unchecked Error Condition
Shoulder CLI znajduje podatne wzorce w całym Twoim kodzie.