Skip to content

Missing Error Message in Assert Statement

Description

The assert statement is missing an error message, which can make it difficult to diagnose issues when the assertion fails.

Examples

Insecure Code

cairo
assert(x > 0)

Secure Code

cairo
assert(x > 0, 'x must be greater than 0')

Remediation

Add a descriptive error message to the assert statement, e.g., assert condition, 'Error message'

Rule Details

FieldValue
IDCODE-0670
CategoryErrorHandling
SeverityLOW
CWE
ConfidenceHIGH
ImpactLOW
LikelihoodLOW
ExploitabilityCOMPLEX
Tagsbest-practice
OWASPN/A

References