1
0
mirror of https://github.com/strongdm/comply synced 2025-12-06 06:14:09 +00:00

Refactor "Standards" to "Frameworks"

This commit is contained in:
Craine Runton
2020-09-15 14:52:22 -05:00
parent dbe49a09b3
commit 84e439e7cc
17 changed files with 180 additions and 106 deletions

View File

@@ -24,7 +24,7 @@ func todoAction(c *cli.Context) error {
}
w := tablewriter.NewWriter(os.Stdout)
w.SetHeader([]string{"Standard", "Control", "Satisfied?", "Name"})
w.SetHeader([]string{"Framework", "Control", "Satisfied?", "Name"})
type row struct {
standard string
@@ -36,7 +36,7 @@ func todoAction(c *cli.Context) error {
satisfied := model.ControlsSatisfied(d)
var rows []row
for _, std := range d.Standards {
for _, std := range d.Frameworks {
for id, c := range std.Controls {
sat := "NO"
if _, ok := satisfied[id]; ok {

View File

@@ -6,7 +6,7 @@ type Control struct {
Description string `yaml:"description"`
}
type Standard struct {
type Framework struct {
Name string `yaml:"name"`
Controls map[string]Control `yaml:",inline"`
}

View File

@@ -30,7 +30,7 @@ func ReadData() (*Data, error) {
if err != nil {
return nil, err
}
standards, err := ReadStandards()
frameworks, err := ReadFrameworks()
if err != nil {
return nil, err
}
@@ -40,7 +40,7 @@ func ReadData() (*Data, error) {
Narratives: narratives,
Policies: policies,
Procedures: procedures,
Standards: standards,
Frameworks: frameworks,
}, nil
}
@@ -67,27 +67,27 @@ func tickets(rawTickets []string) ([]*Ticket, error) {
return tickets, nil
}
// ReadStandards loads standard definitions from the filesystem.
func ReadStandards() ([]*Standard, error) {
var standards []*Standard
// ReadFrameworks loads standard definitions from the filesystem.
func ReadFrameworks() ([]*Framework, error) {
var frameworks []*Framework
files, err := path.Standards()
files, err := path.Frameworks()
if err != nil {
return nil, errors.Wrap(err, "unable to enumerate paths")
}
for _, f := range files {
s := &Standard{}
s := &Framework{}
sBytes, err := ioutil.ReadFile(f.FullPath)
if err != nil {
return nil, errors.Wrap(err, "unable to read "+f.FullPath)
}
yaml.Unmarshal(sBytes, &s)
standards = append(standards, s)
frameworks = append(frameworks, s)
}
return standards, nil
return frameworks, nil
}
// ReadNarratives loads narrative descriptions from the filesystem.

View File

@@ -1,12 +1,12 @@
package model
type Data struct {
Standards []*Standard
Narratives []*Document
Policies []*Document
Procedures []*Procedure
Tickets []*Ticket
Audits []*Audit
Frameworks []*Framework
Narratives []*Document
Policies []*Document
Procedures []*Procedure
Tickets []*Ticket
Audits []*Audit
}
type Revision struct {

View File

@@ -15,9 +15,9 @@ type File struct {
Info os.FileInfo
}
// Standards lists all standard files.
func Standards() ([]File, error) {
return filesFor("standards", "yml")
// Frameworks lists all standard files.
func Frameworks() ([]File, error) {
return filesFor("frameworks", "yml")
}
// Narratives lists all narrative files.

View File

@@ -36,14 +36,14 @@ type renderData struct {
Narratives []*model.Document
Policies []*model.Document
Procedures []*model.Procedure
Standards []*model.Standard
Frameworks []*model.Framework
Tickets []*model.Ticket
Controls []*control
Links *model.TicketLinks
}
type control struct {
Standard string
Framework string
ControlKey string
Name string
Description string
@@ -65,12 +65,12 @@ func load() (*model.Data, *renderData, error) {
satisfied := model.ControlsSatisfied(modelData)
controls := make([]*control, 0)
for _, standard := range modelData.Standards {
for key, c := range standard.Controls {
for _, framework := range modelData.Frameworks {
for key, c := range framework.Controls {
satisfactions, ok := satisfied[key]
satisfied := ok && len(satisfactions) > 0
controls = append(controls, &control{
Standard: standard.Name,
Framework: framework.Name,
ControlKey: key,
Name: c.Name,
Description: c.Description,
@@ -87,7 +87,7 @@ func load() (*model.Data, *renderData, error) {
rd.Narratives = modelData.Narratives
rd.Policies = modelData.Policies
rd.Procedures = modelData.Procedures
rd.Standards = modelData.Standards
rd.Frameworks = modelData.Frameworks
rd.Tickets = modelData.Tickets
rd.Links = &model.TicketLinks{}
rd.Project = project
@@ -123,7 +123,7 @@ func addStats(modelData *model.Data, renderData *renderData) {
satisfied := model.ControlsSatisfied(modelData)
for _, std := range renderData.Standards {
for _, std := range renderData.Frameworks {
stats.ControlsTotal += len(std.Controls)
for controlKey := range std.Controls {
if _, ok := satisfied[controlKey]; ok {

View File

@@ -114,7 +114,7 @@ func preprocessDoc(data *renderData, pol *model.Document, fullPath string) error
for standard, keys := range pol.Satisfies {
rows += fmt.Sprintf("| %s | %s |\n", standard, strings.Join(keys, ", "))
}
satisfiesTable = fmt.Sprintf("|Standard|Controls Satisfied|\n|-------+--------------------------------------------|\n%s\nTable: Control satisfaction\n", rows)
satisfiesTable = fmt.Sprintf("|Framework|Controls Satisfied|\n|-------+--------------------------------------------|\n%s\nTable: Control satisfaction\n", rows)
}
if len(pol.Revisions) > 0 {

File diff suppressed because it is too large Load Diff