T09 · Insecure Skill Coding Practices
- Location
references/ENTITY_EXAMPLE.md:138- Finding
Canonical update example bypasses mandatory state-transition validation
- Content
View full analysis
- Remediation
View remediation
{:?}", task.status, next_status ))); } let mut active: task::ActiveModel = task.into(); active.status = Set(next_status); active.updated_at = Set(chrono::Utc::now()); active.update(db).await?; ``` Additional hardening measures should include: 1. Place transition validation in a centralized entity or service method rather than relying on every caller to repeat it. 2. Add tests for every allowed and prohibited transition. 3. Ensure externally supplied states are authorized in addition to being valid transitions. 4. Update the example documentation to explicitly identify transition validation as mandatory. 5. Consider concurrency controls, such as optimistic locking or a conditional update, when simultaneous state changes are possible. ]]>
