diff --git a/types/oscal/catalog/catalog.go b/types/oscal/catalog/catalog.go new file mode 100644 index 0000000..39a0f82 --- /dev/null +++ b/types/oscal/catalog/catalog.go @@ -0,0 +1,16 @@ +package catalog + +func (c *Catalog) FindControlById(id string) *Control { + for i, ctrl := range c.Controls { + if ctrl.Id == id { + return &c.Controls[i] + } + } + for i, _ := range c.Groups { + ctrl := c.Groups[i].FindControlById(id) + if ctrl != nil { + return ctrl + } + } + return nil +} diff --git a/types/oscal/catalog/group.go b/types/oscal/catalog/group.go new file mode 100644 index 0000000..3f90903 --- /dev/null +++ b/types/oscal/catalog/group.go @@ -0,0 +1,16 @@ +package catalog + +func (g *Group) FindControlById(id string) *Control { + for i, ctrl := range g.Controls { + if ctrl.Id == id { + return &g.Controls[i] + } + } + for i, _ := range g.Groups { + ctrl := g.Groups[i].FindControlById(id) + if ctrl != nil { + return ctrl + } + } + return nil +}