(path string)
| 281 | } |
| 282 | |
| 283 | func LoadEngine(path string) (Engine, error) { |
| 284 | if path == "" { |
| 285 | return DefaultEngine(), nil |
| 286 | } |
| 287 | raw, err := os.ReadFile(path) |
| 288 | if err != nil { |
| 289 | return Engine{}, err |
| 290 | } |
| 291 | var file RuleFile |
| 292 | if err := yaml.Unmarshal(raw, &file); err != nil { |
| 293 | return Engine{}, err |
| 294 | } |
| 295 | engine := Engine{Rules: file.Rules} |
| 296 | if len(engine.Rules) == 0 { |
| 297 | return Engine{}, fmt.Errorf("policy rule file has no rules") |
| 298 | } |
| 299 | return engine, nil |
| 300 | } |
| 301 | |
| 302 | func (e Engine) Evaluate(event Event) Decision { |
| 303 | if len(e.Rules) > 0 { |
no test coverage detected