mirror of
https://github.com/strongdm/comply
synced 2024-11-16 21:04:54 +00:00
Update renderer to simplify framework criteria satisfaction based on controls in place, in addition to existing policy and narrative
This commit is contained in:
parent
8f5a63db53
commit
351c47e381
@ -8,6 +8,7 @@ type Document struct {
|
|||||||
|
|
||||||
Revisions []Revision `yaml:"majorRevisions"`
|
Revisions []Revision `yaml:"majorRevisions"`
|
||||||
Satisfies Satisfaction `yaml:"satisfies"`
|
Satisfies Satisfaction `yaml:"satisfies"`
|
||||||
|
Targets Target `yaml:"targets"`
|
||||||
FullPath string
|
FullPath string
|
||||||
OutputFilename string
|
OutputFilename string
|
||||||
ModifiedAt time.Time
|
ModifiedAt time.Time
|
||||||
|
@ -4,6 +4,9 @@ type Criterion struct {
|
|||||||
Family string `yaml:"family"`
|
Family string `yaml:"family"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
|
|
||||||
|
Satisfied bool
|
||||||
|
SatisfiedBy []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Framework struct {
|
type Framework struct {
|
||||||
|
@ -9,6 +9,7 @@ type Procedure struct {
|
|||||||
|
|
||||||
Revisions []Revision `yaml:"majorRevisions"`
|
Revisions []Revision `yaml:"majorRevisions"`
|
||||||
Satisfies Satisfaction `yaml:"satisfies"`
|
Satisfies Satisfaction `yaml:"satisfies"`
|
||||||
|
Targets Target `yaml:"targets"`
|
||||||
FullPath string
|
FullPath string
|
||||||
OutputFilename string
|
OutputFilename string
|
||||||
ModifiedAt time.Time
|
ModifiedAt time.Time
|
||||||
|
@ -2,7 +2,6 @@ package render
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
"time"
|
"time"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
|
||||||
@ -19,6 +18,8 @@ type project struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type stats struct {
|
type stats struct {
|
||||||
|
ControlsTotal int
|
||||||
|
|
||||||
CriteriaTotal int
|
CriteriaTotal int
|
||||||
CriteriaSatisfied int
|
CriteriaSatisfied int
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ type renderData struct {
|
|||||||
Procedures []*model.Procedure
|
Procedures []*model.Procedure
|
||||||
Frameworks []*model.Framework
|
Frameworks []*model.Framework
|
||||||
Tickets []*model.Ticket
|
Tickets []*model.Ticket
|
||||||
Criteria []*criterion
|
|
||||||
Links *model.TicketLinks
|
Links *model.TicketLinks
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,24 +68,15 @@ func load() (*model.Data, *renderData, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
satisfied := model.CriteriaSatisfied(modelData)
|
satisfied := model.CriteriaSatisfied(modelData)
|
||||||
criteria := make([]*criterion, 0)
|
|
||||||
for _, framework := range modelData.Frameworks {
|
for _, framework := range modelData.Frameworks {
|
||||||
for key, c := range framework.Criteria{
|
for key, c := range framework.Criteria{
|
||||||
satisfactions, ok := satisfied[key]
|
satisfactions, ok := satisfied[key]
|
||||||
satisfied := ok && len(satisfactions) > 0
|
satisfied := ok && len(satisfactions) > 0
|
||||||
criteria = append(criteria, &criterion{
|
c.Satisfied = satisfied
|
||||||
Framework: framework.Name,
|
c.SatisfiedBy = satisfactions
|
||||||
CriteriaKey: key,
|
framework.Criteria[key] = c
|
||||||
Name: c.Name,
|
|
||||||
Description: c.Description,
|
|
||||||
Satisfied: satisfied,
|
|
||||||
SatisfiedBy: satisfactions,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Slice(criteria, func(i, j int) bool {
|
|
||||||
return criteria[i].CriteriaKey < criteria[j].CriteriaKey
|
|
||||||
})
|
|
||||||
|
|
||||||
rd := &renderData{}
|
rd := &renderData{}
|
||||||
rd.Narratives = modelData.Narratives
|
rd.Narratives = modelData.Narratives
|
||||||
@ -97,7 +88,6 @@ func load() (*model.Data, *renderData, error) {
|
|||||||
rd.Links = &model.TicketLinks{}
|
rd.Links = &model.TicketLinks{}
|
||||||
rd.Project = project
|
rd.Project = project
|
||||||
rd.Name = project.OrganizationName
|
rd.Name = project.OrganizationName
|
||||||
rd.Criteria= criteria
|
|
||||||
|
|
||||||
ts, err := config.Config().TicketSystem()
|
ts, err := config.Config().TicketSystem()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -133,6 +123,7 @@ func addStats(modelData *model.Data, renderData *renderData) {
|
|||||||
stats := &stats{}
|
stats := &stats{}
|
||||||
|
|
||||||
satisfied := model.CriteriaSatisfied(modelData)
|
satisfied := model.CriteriaSatisfied(modelData)
|
||||||
|
stats.ControlsTotal += len(renderData.Controls)
|
||||||
|
|
||||||
for _, std := range renderData.Frameworks {
|
for _, std := range renderData.Frameworks {
|
||||||
stats.CriteriaTotal += len(std.Criteria)
|
stats.CriteriaTotal += len(std.Criteria)
|
||||||
|
Loading…
Reference in New Issue
Block a user