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.
So behebst du diese Schwachstelle
Präventionsstrategien für Unchecked Return Value basierend auf 2 Shoulder-Erkennungsregeln.
Replace blank identifier _ with err and check error return values
- data, _ := ioutil.ReadFile(path) + data, err := ioutil.ReadFile(path) + if err != nil { + return fmt.Errorf("failed to read %s: %w", path, err) + } process(data)
Always check return values from critical operations like password comparison and database writes
- 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);
Finden Sie Schwachstellen in Ihrem Code
Verwenden Sie Shoulder, um Ihren Code nach Unchecked Return Value-Mustern zu scannen. 2 Regeln.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=252 # Or scan entire project npx @shoulderdev/cli trust .
Erkennungsregeln (2)
Worauf bei Code-Reviews zu achten ist
Diese Muster weisen auf potenzielle Unchecked Return Value-Schwachstellen hin. Achten Sie bei Code-Reviews und Sicherheitsaudits darauf.
Scanne deine Codebasis nach Unchecked Return Value
Shoulder CLI findet anfällige Muster in deiner gesamten Codebasis.