E07910: sanitized parameters must be String type
What went wrong
The 'sanitized' modifier can ONLY be applied to String type parameters. The receiving function or method cleans a 'sanitized' parameter on entry, checking the String for injection patterns. This only makes sense for String types - other types don't have injection vulnerability semantics.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 661 (Why can sanitized only be used on incoming String paramet...)
- ek9 -q 665 (How do sanitized parameters work with web service content...)
Rationale
Sanitization prevents injection attacks (SQL injection, XSS, command injection). These attacks exploit string interpolation into commands or markup. Non-string types like Integer, Boolean, or objects don't have this attack vector.
How to fix it
- Remove 'sanitized' modifier from non-String parameters
- Use sanitized only for String parameters that receive external input
- For non-String types, use normal type validation
Common causes
- Misunderstanding sanitized as general "validation" (it's specifically for injection)
- Copy-paste from String parameter to non-String parameter
- Trying to apply security modifier to all external inputs
See also
- E07910: sanitized on non-String type (this error)
- E07920: sanitized in wrong location (not on incoming parameter)
https://ek9.io/sanitized.html https://ek9.io/forAI.json#$.sanitizedTypes
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07910: sanitized parameters must be String type
#!ek9 defines module error.e07910.bad defines function //ERROR: Integer cannot be sanitized - only String processInteger() -> value as sanitized Integer <- result as Integer? result: value //ERROR: Float cannot be sanitized - only String processFloat() -> value as sanitized Float <- result as Float? result: value //ERROR: Date cannot be sanitized - only String processDate() -> value as sanitized Date <- result as Date? result: value //ERROR: Time cannot be sanitized - only String processTime() -> value as sanitized Time <- result as Time? result: value //ERROR: Duration cannot be sanitized - only String processDuration() -> value as sanitized Duration <- result as Duration? result: value //ERROR: Boolean cannot be sanitized - only String processBoolean() -> value as sanitized Boolean <- result as Boolean? result: value //VALID: String CAN be sanitized - this should NOT produce an error processString() -> value as sanitized String <- result as String? result: value
Fixed: Use 'sanitized' only on a String parameter
#!ek9 defines module error.e07910.good defines function //A String parameter can be sanitized executeQuery() -> sql as sanitized String <- rtn as String: sql //An Integer needs no sanitizing: text that is not a number never becomes one processCount() -> count as Integer <- rtn as Integer: count
Questions and answers
These Q&A entries show E07910 and its fix:
- Q661: Why can sanitized only be used on incoming String parameters?
- Q665: How do sanitized parameters work with web service content binding?
- Q1237: Write me a pure function that takes a sanitized String parameter and returns a different status string for safe input versus blocked malicious input.
- Q1246: Create me an AuditLogger class whose constructor takes a sanitized String log message, where construction with malicious input (file path traversal, terminal escape sequences) leaves the logger in a 'rejected' state.
- Q1247: Write me a QueryBuilder class with an addClause method that takes a sanitized String fragment, returning 'accepted' for clean fragments and 'rejected' for malicious ones (LDAP injection, NoSQL operator injection).