Unmarshal Tag Omitempty
Description
The `omitempty` key is used in a struct field, which can lead to encoding errors. The developer likely intended to use ",omitempty" instead.
Examples
Insecure Code
go
type T struct { X string `json:"omitempty"` }Secure Code
go
type T struct { X string `json:"omitempty,"` }Remediation
Add a comma before 'omitempty' in the struct field tag.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0508 |
| Category | InsecureConfig |
| Severity | MEDIUM |
| CWE | CWE-172 |
| Confidence | HIGH |
| Impact | LOW |
| Likelihood | MEDIUM |
| Exploitability | MODERATE |
| Tags | encoding-error, struct-field |
| OWASP | N/A |