MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / LoadEngine

Function LoadEngine

internal/security/policy.go:283–300  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

281}
282
283func 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
302func (e Engine) Evaluate(event Event) Decision {
303 if len(e.Rules) > 0 {

Callers 2

complianceMappingOptionsFunction · 0.92
policyCmdFunction · 0.92

Calls 2

DefaultEngineFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected