validateColumn ensures the JSON column is a bare SQL identifier before it is emitted into the query by the ent sqljson helpers. Callers are expected to set it to a known column constant, but validating here keeps safety from depending on every caller remembering to do so.
(column string)
| 127 | // it to a known column constant, but validating here keeps safety from depending |
| 128 | // on every caller remembering to do so. |
| 129 | func validateColumn(column string) error { |
| 130 | if !columnRegexp.MatchString(column) { |
| 131 | return fmt.Errorf("invalid column %q: must be a valid identifier", column) |
| 132 | } |
| 133 | |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // validateFieldPath ensures the JSON field path only contains safe characters |
| 138 | // before it is concatenated into the SQL query by the ent sqljson helpers. |
no outgoing calls
no test coverage detected