Skip to content

Commit

Permalink
Merge pull request #174 from opencontrol/add_control_origin
Browse files Browse the repository at this point in the history
Add control_origin to v3 and gitbook rendering of control_origin
  • Loading branch information
mzia authored Jun 15, 2016
2 parents eef12ab + dc3c810 commit bb3f189
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fixtures/component_fixtures/v3_0_0/EC2/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: shared
narrative:
- key: "a"
text: "Justification in narrative form A for CM-2"
Expand All @@ -25,6 +26,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: inherited
parameters:
- key: "a"
text: "Parameter A for 1.1"
Expand All @@ -39,6 +41,7 @@ satisfies:
- control_key: 1.1.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- key: "a"
text: "Justification in narrative form A for 1.1.1"
Expand All @@ -53,6 +56,7 @@ satisfies:
- control_key: 2.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- text: "Justification in narrative form for 2.1"
standard_key: PCI-DSS-MAY-2015
Expand Down
4 changes: 4 additions & 0 deletions fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: shared
narrative:
- key: "a"
text: "Justification in narrative form A for CM-2"
Expand All @@ -26,6 +27,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: inherited
parameters:
- key: "a"
text: "Parameter A for 1.1"
Expand All @@ -40,6 +42,7 @@ satisfies:
- control_key: 1.1.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- key: "a"
text: "Justification in narrative form A for 1.1.1"
Expand All @@ -54,6 +57,7 @@ satisfies:
- control_key: 2.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- text: "Justification in narrative form for 2.1"
standard_key: PCI-DSS-MAY-2015
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

##### Responsible Role: AWS Staff

##### Control Origin: shared

##### a
Justification in narrative form A for CM-2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Parameter A for 1.1
###### b
Parameter B for 1.1

##### Control Origin: inherited

No narrative found for the combination of standard PCI-DSS-MAY-2015 and control 1.1
Covered By:
* [Amazon Elastic Compute Cloud - EC2 Verification 1](../components/EC2.md)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#### Amazon Elastic Compute Cloud

##### Responsible Role: AWS Staff

##### Control Origin: inherited
Justification in narrative form for 2.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

##### Responsible Role: AWS Staff

##### Control Origin: shared

##### a
Justification in narrative form A for CM-2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Parameter A for 1.1
###### b
Parameter B for 1.1

##### Control Origin: inherited

No narrative found for the combination of standard PCI-DSS-MAY-2015 and control 1.1
Covered By:
* [Amazon Elastic Compute Cloud - EC2 Verification 1](../components/EC2.md)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#### Amazon Elastic Compute Cloud

##### Responsible Role: AWS Staff

##### Control Origin: inherited
Justification in narrative form for 2.1
3 changes: 3 additions & 0 deletions fixtures/opencontrol_fixtures/components/EC2/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: shared
narrative:
- key: "a"
text: "Justification in narrative form A for CM-2"
Expand All @@ -25,6 +26,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: inherited
parameters:
- key: "a"
text: "Parameter A for 1.1"
Expand All @@ -34,6 +36,7 @@ satisfies:
- control_key: 2.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- text: "Justification in narrative form for 2.1"
standard_key: PCI-DSS-MAY-2015
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: shared
narrative:
- key: "a"
text: "Justification in narrative form A for CM-2"
Expand All @@ -26,6 +27,7 @@ satisfies:
system_key: CloudFoundry
verification_key: UAA_Verification_1
implementation_status: partial
control_origin: inherited
parameters:
- key: "a"
text: "Parameter A for 1.1"
Expand All @@ -35,6 +37,7 @@ satisfies:
- control_key: 2.1
covered_by: []
implementation_status: partial
control_origin: inherited
narrative:
- text: "Justification in narrative form for 2.1"
standard_key: PCI-DSS-MAY-2015
Expand Down
8 changes: 8 additions & 0 deletions gitbook/gitbookCertification.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func (openControl *OpenControlGitBook) getCoveredByVerification(text string, com
return text
}

func (openControl *OpenControlGitBook) getControlOrigin(text string, controlOrigin string) string {
if controlOrigin != "" {
text = fmt.Sprintf("%s\n##### Control Origin: %s\n", text, controlOrigin)
}
return text
}


func (openControl *OpenControlGitBook) exportControl(control *ControlGitbook) (string, string) {
Expand All @@ -100,6 +106,8 @@ func (openControl *OpenControlGitBook) exportControl(control *ControlGitbook) (s

text = openControl.getParameters(text, justification.SatisfiesData.GetParameters())

text = openControl.getControlOrigin(text, justification.SatisfiesData.GetControlOrigin())

text = openControl.getNarratives(justification.SatisfiesData.GetNarratives(), text, control)
})
text = openControl.getCoveredBy(text, justification)
Expand Down
2 changes: 2 additions & 0 deletions gitbook/gitbookCertification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var exportControlTests = []exportControlTest{
##### Responsible Role: AWS Staff
##### Control Origin: shared
##### a
Justification in narrative form A for CM-2
Expand Down
4 changes: 4 additions & 0 deletions models/components/versions/2_0_0/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (s Satisfies) GetCoveredBy() common.CoveredByList {
return s.CoveredBy
}

func (s Satisfies) GetControlOrigin() string {
return ""
}

type Narrative string

func (n Narrative) GetKey() string {
Expand Down
1 change: 1 addition & 0 deletions models/components/versions/2_0_0/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestComponentGetters(t *testing.T) {
}
assert.Equal(t, satisfies.GetParameters(), testSatisfies[idx].GetParameters())
assert.Equal(t, satisfies.GetCoveredBy(), testSatisfies[idx].GetCoveredBy())
assert.Equal(t, "", satisfies.GetControlOrigin())
}
}

Expand Down
5 changes: 5 additions & 0 deletions models/components/versions/3_0_0/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Satisfies struct {
Narrative []NarrativeSection `yaml:"narrative" json:"narrative"`
CoveredBy common.CoveredByList `yaml:"covered_by" json:"covered_by"`
Parameters []Section `yaml:"parameters" json:"parameters"`
ControlOrigin string `yaml:"control_origin" json:"control_origin"`
}

func (s Satisfies) GetControlKey() string {
Expand Down Expand Up @@ -101,6 +102,10 @@ func (s Satisfies) GetCoveredBy() common.CoveredByList {
return s.CoveredBy
}

func (s Satisfies) GetControlOrigin() string {
return s.ControlOrigin
}

// NarrativeSection contains the key and text for a particular section.
// NarrativeSection can omit the key.
type NarrativeSection struct {
Expand Down
3 changes: 2 additions & 1 deletion models/components/versions/3_0_0/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestComponentGetters(t *testing.T) {
testSatisfies := []Satisfies{{Parameters: []Section{Section{Key:"key", Text: "text"}}, Narrative: []NarrativeSection{NarrativeSection{Key: "key", Text: "text"}, NarrativeSection{Text: "text"}}}, {}, {}, {}}
testSatisfies := []Satisfies{{ControlOrigin: "control_origin", Parameters: []Section{Section{Key:"key", Text: "text"}}, Narrative: []NarrativeSection{NarrativeSection{Key: "key", Text: "text"}, NarrativeSection{Text: "text"}}}, {}, {}, {}}
component := Component{
Name: "Amazon Elastic Compute Cloud",
Key: "EC2",
Expand Down Expand Up @@ -40,6 +40,7 @@ func TestComponentGetters(t *testing.T) {
assert.Equal(t, satisfies.GetParameters()[i].GetText(), parameter.GetText())
}
assert.Equal(t, satisfies.GetCoveredBy(), testSatisfies[idx].GetCoveredBy())
assert.Equal(t, satisfies.GetControlOrigin(), testSatisfies[idx].GetControlOrigin())
}
}

Expand Down
1 change: 1 addition & 0 deletions models/components/versions/base/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Satisfies interface {
GetNarratives() []Section
GetParameters() []Section
GetCoveredBy() common.CoveredByList
GetControlOrigin() string
}

type Section interface {
Expand Down

0 comments on commit bb3f189

Please sign in to comment.