Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
Add multiple component definitons for DTR, Engine (#73)
Browse files Browse the repository at this point in the history
* Fix multiple entries for control config

* inital prototype for multiple component definitions

Signed-off-by: aitchkhan <aitchkhan@gmail.com>

* modify tests and fix issue with multiple comp definitions

* fix typo in component

Signed-off-by: aitchkhan <aitchkhan@gmail.com>
  • Loading branch information
aitchkhan authored and anweiss committed Jan 29, 2019
1 parent f0976b2 commit 9b2c365
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 106 deletions.
57 changes: 49 additions & 8 deletions impl/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,60 @@ const (
)

func TestGenerateImplementation(t *testing.T) {

ucpCompID := "(component ID: cpe:2.3:a:docker:ucp:3.2.0:*:*:*:*:*:*:*)"
dtrCompID := "(component ID: cpe:2.3:a:docker:dtr:2.7.0:*:*:*:*:*:*:*)"
engineCompID := "(component ID: cpe:2.3:a:docker:engine-enterprise:18.09:*:*:*:*:*:*:*)"
components := []string{"CompA", "CompB", "CompC"}
controls := []string{"ac-2", "ac-2.2", "ac-4"}
comps := []component{
{
id: getComponentID(ucpCompID),
name: "UCP",
compNameIndex: 17,
uuidIndex: 18,
narrativeIndex: 19,
definition: make(cdMap),
},
{
id: getComponentID(dtrCompID),
name: "DTR",
compNameIndex: 20,
uuidIndex: 21,
narrativeIndex: 22,
definition: make(cdMap),
},
{
id: getComponentID(engineCompID),
name: "Engine",
compNameIndex: 14,
uuidIndex: 15,
narrativeIndex: 16,
definition: make(cdMap),
},
}
controls := []string{"ac-2", "ac-2.2", "ac-4", "bc-1.1", "hk-1.2", "as-3.2", "af-1.23", "ar-5.2", "fp-8.5"}
ComponentDetails := [][]string{
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "2-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "2.2-Narrative", "456|654"},
[]string{controls[2], "CompC", "4-Narrative", "789|987"},
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "3-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "3.4-Narrative", "567|1231"},
[]string{controls[2], "CompC", "5-Narrative", "789|987"},
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "4-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "4.1-Narrative", "111|222"},
[]string{controls[2], "CompC", "6-Narrative", "789|987"},
}
csvs := make([][]string, totalControlsInExcel)
for i := range csvs {
csvs[i] = make([]string, 20)
csvs[i] = make([]string, 25)
}
for i, x := range ComponentDetails {
csvs[i+rowIndex][controlIndex] = x[0]
csvs[i+rowIndex][componentConfigIndex] = x[1]
csvs[i+rowIndex][narrativeIndex] = x[2]
csvs[i+rowIndex][uuidIndex] = x[3]

for _, comp := range comps {
for i, x := range ComponentDetails {
csvs[i+rowIndex][controlIndex] = x[0]
csvs[i+rowIndex][comp.compNameIndex] = x[1]
csvs[i+rowIndex][comp.narrativeIndex] = x[2]
csvs[i+rowIndex][comp.uuidIndex] = x[3]
}
}

p := profile.Profile{
Expand Down Expand Up @@ -81,6 +118,10 @@ func TestGenerateImplementation(t *testing.T) {
},
}
i := GenerateImplementation(csvs, &p, &NISTCatalog{"NISTSP80053"})

if len(i.ComponentDefinitions) != len(comps) {
t.Error("mismatch number of component definitions")
}
if len(i.ComponentDefinitions[0].ComponentConfigurations) != len(components) {
t.Error("mismatch number of components")
}
Expand Down
Loading

0 comments on commit 9b2c365

Please sign in to comment.