MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetQueryExportFactors

Function GetQueryExportFactors

backend/common/cel.go:217–239  ·  view source on GitHub ↗

GetQueryExportFactors is used to get risk factors from query and export expressions.

(expression string)

Source from the content-addressed store, hash-verified

215
216// GetQueryExportFactors is used to get risk factors from query and export expressions.
217func GetQueryExportFactors(expression string) (*QueryExportFactors, error) {
218 // If the expression is empty, return an empty struct.
219 if expression == "" {
220 return &QueryExportFactors{}, nil
221 }
222
223 factors := &QueryExportFactors{}
224 e, err := cel.NewEnv(IAMPolicyConditionCELAttributes...)
225 if err != nil {
226 return nil, err
227 }
228 ast, issues := e.Compile(expression)
229 if issues != nil {
230 return nil, errors.Errorf("found issue %v", issues)
231 }
232 parsedExpr, err := cel.AstToParsedExpr(ast)
233 if err != nil {
234 return nil, err
235 }
236 callExpr := parsedExpr.Expr.GetCallExpr()
237 findField(callExpr, factors)
238 return factors, nil
239}
240
241func findField(callExpr *exprproto.Expr_Call, factors *QueryExportFactors) {
242 if callExpr == nil {

Callers 2

Calls 2

findFieldFunction · 0.85
ErrorfMethod · 0.80

Tested by 1