Skip to content

Commit

Permalink
Convert child controls to the form we are used to see in opencontrols
Browse files Browse the repository at this point in the history
    ac-2.1 --> AC-2 (1)
  • Loading branch information
isimluk committed Oct 5, 2020
1 parent c1a8079 commit ad46e48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/opencontrol/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
yaml "gopkg.in/yaml.v2"
"io/ioutil"
"regexp"
"strings"

"github.com/gocomply/oscalkit/types/oscal/catalog"
Expand Down Expand Up @@ -64,5 +65,10 @@ func (controls Controls) Add(ctrl *catalog.Control, family string) {
}

func oscalIdToOpencontrol(id string) string {
return strings.ToUpper(id)
re := regexp.MustCompile(`^([a-z][a-z])-([0-9]+).([0-9]+)$`)
match := re.FindStringSubmatch(id)
if len(match) == 0 {
return strings.ToUpper(id)
}
return strings.ToUpper(match[1]) + "-" + match[2] + " (" + match[3] + ")"
}

0 comments on commit ad46e48

Please sign in to comment.