Visitor implements visit_string without visit_str
ID |
rust.correctness.serde_visit_str_implemented |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Api Misuse |
Language |
Rust |
Description
This visitor implements visit_string but not visit_str. Deserializers that can borrow from the input call visit_str, so the default implementation runs instead and the borrowed case is handled differently from the owned one. Implement visit_str as well.
Rationale
This visitor implements visit_string but not visit_str. Deserializers that can borrow from the input call visit_str, so the default implementation runs instead and the borrowed case is handled differently from the owned one. Implement visit_str as well.
The following code illustrates the pattern detected by this rule:
struct BadVisitor;
// FLAGGED: Visitor implements visit_string without visit_str
impl BadVisitor {
fn visit_string(&self, value: String) -> String {
value
}
}
Remediation
Follow secure coding practices and review the references below for detailed remediation guidance.