MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / validateFieldPath

Function validateFieldPath

pkg/jsonfilter/jsonfilter.go:140–150  ·  view source on GitHub ↗

validateFieldPath ensures the JSON field path only contains safe characters before it is concatenated into the SQL query by the ent sqljson helpers. An empty path is allowed: it targets the column itself and is not injectable.

(fieldPath string)

Source from the content-addressed store, hash-verified

138// before it is concatenated into the SQL query by the ent sqljson helpers.
139// An empty path is allowed: it targets the column itself and is not injectable.
140func validateFieldPath(fieldPath string) error {
141 if fieldPath == "" {
142 return nil
143 }
144
145 if !fieldPathRegexp.MatchString(fieldPath) {
146 return fmt.Errorf("invalid field path %q: must be dot-separated identifiers with optional numeric array indices", fieldPath)
147 }
148
149 return nil
150}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected