BETA Shoulder jest w wersji beta — Wyniki mogą czasami być błędne. Twoja opinia kształtuje to, co naprawimy w następnej kolejności. Podziel się opinią
↩️

Unchecked Return Value

🛡️ 2 reguł wykrywa to

Unchecked Return Value

The product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions.

When return values are not checked, the program may continue execution in an error state or with incorrect data, potentially leading to security vulnerabilities.

Rozpowszechnienie
Średnia
Pokryto 2 języków
Wplyw
Wysoki
1 reguł o wysokim poziomie
Zapobieganie
Udokumentowane
2 przykładów poprawek
2 Zapobieganie
2 Zapobieganie

Jak naprawić tę podatność

Strategie zapobiegania dla Unchecked Return Value oparte na 2 regułach detekcji Shoulder.

Unchecked Error Return Values MEDIUM

Replace blank identifier _ with err and check error return values

+4 -1 go
- data, _ := ioutil.ReadFile(path)
+ data, err := ioutil.ReadFile(path)
+ if err != nil {
+     return fmt.Errorf("failed to read %s: %w", path, err)
+ }
  process(data)
  
Unchecked Return Value from Critical Operations HIGH

Always check return values from critical operations like password comparison and database writes

+4 -2 javascript
- bcrypt.compare(req.body.password, user.passwordHash);
- // Proceeds without checking the result
+ const isValid = await bcrypt.compare(req.body.password, user.passwordHash);
+ if (!isValid) {
+   return res.status(401).json({ error: 'Invalid credentials' });
+ }
  const token = generateToken(user);
  
4 Sygnaly Ostrzegawcze
4 Sygnaly Ostrzegawcze

Na co zwracac uwage podczas przegladu kodu

Te wzorce wskazuja na potencjalne podatnosci Unchecked Return Value. Szukaj ich podczas przegladow kodu i audytow bezpieczenstwa.

🟠
Return value from ... at ... is not checked javascript-unchecked-return-value
🟠
critical operations (file system, database, authentication) whose return values are not checked javascript-unchecked-return-value
🔍

Przeskanuj swój kod w poszukiwaniu Unchecked Return Value

Shoulder CLI znajduje podatne wzorce w całym Twoim kodzie.