File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,3 +43,13 @@ func (c *Control) UnmarshalYAML(data []byte) error {
4343
4444 return nil
4545}
46+
47+ func (c * Control ) GetMappingReferences () (refs []string ) {
48+ for _ , ref := range c .Guidelines {
49+ refs = append (refs , ref .ReferenceId )
50+ }
51+ for _ , ref := range c .Threats {
52+ refs = append (refs , ref .ReferenceId )
53+ }
54+ return refs
55+ }
Original file line number Diff line number Diff line change 11package gemara
22
3- import "github.com/goccy/go-yaml"
3+ import (
4+ "slices"
5+
6+ "github.com/goccy/go-yaml"
7+ )
48
59// UnmarshalYAML allows decoding control catalogs from older/alternate YAML schemas.
610// It supports mapping `families` -> `groups`.
@@ -38,3 +42,30 @@ func (c *ControlCatalog) UnmarshalYAML(data []byte) error {
3842
3943 return nil
4044}
45+
46+ func (c * ControlCatalog ) GetGroupNames () (groups []string ) {
47+ for _ , group := range c .Groups {
48+ groups = append (groups , group .Title )
49+ }
50+ return groups
51+ }
52+
53+ func (c * ControlCatalog ) GetControlsForGroup (group string ) (controls []Control ) {
54+ for _ , control := range c .Controls {
55+ if control .Group == group {
56+ controls = append (controls , control )
57+ }
58+ }
59+ return controls
60+ }
61+
62+ func (c * ControlCatalog ) GetRequirementForApplicability (applicability string ) (reqs []AssessmentRequirement ) {
63+ for _ , control := range c .Controls {
64+ for _ , assessment := range control .AssessmentRequirements {
65+ if slices .Contains (assessment .Applicability , applicability ) {
66+ reqs = append (reqs , assessment )
67+ }
68+ }
69+ }
70+ return reqs
71+ }
You can’t perform that action at this time.
0 commit comments