2018-05-15 21:13:11 +00:00
|
|
|
package model
|
|
|
|
|
2020-09-15 21:21:16 +00:00
|
|
|
type Criterion struct {
|
2018-05-15 21:13:11 +00:00
|
|
|
Family string `yaml:"family"`
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
Description string `yaml:"description"`
|
|
|
|
}
|
|
|
|
|
2020-09-15 19:52:22 +00:00
|
|
|
type Framework struct {
|
2018-05-15 21:13:11 +00:00
|
|
|
Name string `yaml:"name"`
|
2020-09-15 21:21:16 +00:00
|
|
|
Criteria map[string]Criterion `yaml:",inline"`
|
2018-05-15 21:13:11 +00:00
|
|
|
}
|
|
|
|
|
2020-09-15 21:21:16 +00:00
|
|
|
// CriteriaSatisfied determines the unique criteria currently satisfied by all Narratives, Policies, and Procedures
|
|
|
|
func CriteriaSatisfied(data *Data) map[string][]string {
|
2018-05-15 21:13:11 +00:00
|
|
|
satisfied := make(map[string][]string)
|
|
|
|
|
|
|
|
appendSatisfaction := func(in map[string][]string, k string, v string) []string {
|
|
|
|
s, ok := in[k]
|
|
|
|
if !ok {
|
|
|
|
s = make([]string, 0)
|
|
|
|
}
|
|
|
|
s = append(s, v)
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, n := range data.Narratives {
|
2020-09-15 21:21:16 +00:00
|
|
|
for _, criteriaKeys := range n.Satisfies {
|
|
|
|
for _, key := range criteriaKeys {
|
2018-05-15 21:13:11 +00:00
|
|
|
satisfied[key] = appendSatisfaction(satisfied, key, n.OutputFilename)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, n := range data.Policies {
|
2020-09-15 21:21:16 +00:00
|
|
|
for _, criteriaKeys := range n.Satisfies {
|
|
|
|
for _, key := range criteriaKeys {
|
2018-05-15 21:13:11 +00:00
|
|
|
satisfied[key] = appendSatisfaction(satisfied, key, n.OutputFilename)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, n := range data.Procedures {
|
2020-09-15 21:21:16 +00:00
|
|
|
for _, criteriaKeys := range n.Satisfies {
|
|
|
|
for _, key := range criteriaKeys {
|
2018-05-15 21:13:11 +00:00
|
|
|
satisfied[key] = appendSatisfaction(satisfied, key, n.OutputFilename)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return satisfied
|
|
|
|
}
|