From 5761c7a627f43887d162e47e8ee2aa0699c4e47f Mon Sep 17 00:00:00 2001 From: "James C. Scott" Date: Wed, 15 Jun 2016 12:02:42 -0400 Subject: [PATCH 1/4] Add control_origin to v3 --- models/components/versions/2_0_0/component.go | 4 ++++ models/components/versions/2_0_0/component_test.go | 1 + models/components/versions/3_0_0/component.go | 5 +++++ models/components/versions/3_0_0/component_test.go | 3 ++- models/components/versions/base/component.go | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/models/components/versions/2_0_0/component.go b/models/components/versions/2_0_0/component.go index b44ea649..e308a6fe 100644 --- a/models/components/versions/2_0_0/component.go +++ b/models/components/versions/2_0_0/component.go @@ -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 { diff --git a/models/components/versions/2_0_0/component_test.go b/models/components/versions/2_0_0/component_test.go index 1a5ec7a9..48243ccc 100644 --- a/models/components/versions/2_0_0/component_test.go +++ b/models/components/versions/2_0_0/component_test.go @@ -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()) } } diff --git a/models/components/versions/3_0_0/component.go b/models/components/versions/3_0_0/component.go index 1b0c21d5..b01bc2e7 100644 --- a/models/components/versions/3_0_0/component.go +++ b/models/components/versions/3_0_0/component.go @@ -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 { @@ -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 { diff --git a/models/components/versions/3_0_0/component_test.go b/models/components/versions/3_0_0/component_test.go index f743b257..484ee7e3 100644 --- a/models/components/versions/3_0_0/component_test.go +++ b/models/components/versions/3_0_0/component_test.go @@ -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", @@ -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()) } } diff --git a/models/components/versions/base/component.go b/models/components/versions/base/component.go index fe3ca17b..a49228f0 100644 --- a/models/components/versions/base/component.go +++ b/models/components/versions/base/component.go @@ -25,6 +25,7 @@ type Satisfies interface { GetNarratives() []Section GetParameters() []Section GetCoveredBy() common.CoveredByList + GetControlOrigin() string } type Section interface { From ee8d5f2369c237db63b0795b48b8e22a2752903f Mon Sep 17 00:00:00 2001 From: "James C. Scott" Date: Wed, 15 Jun 2016 13:20:19 -0400 Subject: [PATCH 2/4] Change gitbook rendering for control_origin --- gitbook/gitbookCertification.go | 8 ++++++++ gitbook/gitbookCertification_test.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/gitbook/gitbookCertification.go b/gitbook/gitbookCertification.go index f2ab81d8..34f4bb41 100644 --- a/gitbook/gitbookCertification.go +++ b/gitbook/gitbookCertification.go @@ -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) { @@ -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) diff --git a/gitbook/gitbookCertification_test.go b/gitbook/gitbookCertification_test.go index cc9ae6d8..703358b8 100644 --- a/gitbook/gitbookCertification_test.go +++ b/gitbook/gitbookCertification_test.go @@ -36,6 +36,8 @@ var exportControlTests = []exportControlTest{ ##### Responsible Role: AWS Staff +##### Control Origin: shared + ##### a Justification in narrative form A for CM-2 From 8f357af0050b17a44726d407ab90bb22522880f6 Mon Sep 17 00:00:00 2001 From: "James C. Scott" Date: Wed, 15 Jun 2016 13:22:34 -0400 Subject: [PATCH 3/4] Add control_origin to 3.0.0 yaml fixtures --- fixtures/component_fixtures/v3_0_0/EC2/component.yaml | 4 ++++ fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml | 4 ++++ fixtures/opencontrol_fixtures/components/EC2/component.yaml | 3 +++ .../components/EC2/component.yaml | 3 +++ 4 files changed, 14 insertions(+) diff --git a/fixtures/component_fixtures/v3_0_0/EC2/component.yaml b/fixtures/component_fixtures/v3_0_0/EC2/component.yaml index 6fc895a1..e0527424 100644 --- a/fixtures/component_fixtures/v3_0_0/EC2/component.yaml +++ b/fixtures/component_fixtures/v3_0_0/EC2/component.yaml @@ -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" @@ -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" @@ -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" @@ -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 diff --git a/fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml b/fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml index 4e510b14..1feb3cfd 100644 --- a/fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml +++ b/fixtures/component_fixtures/v3_0_0/EC2WithKey/component.yaml @@ -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" @@ -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" @@ -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" @@ -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 diff --git a/fixtures/opencontrol_fixtures/components/EC2/component.yaml b/fixtures/opencontrol_fixtures/components/EC2/component.yaml index 5d255846..bba11fff 100644 --- a/fixtures/opencontrol_fixtures/components/EC2/component.yaml +++ b/fixtures/opencontrol_fixtures/components/EC2/component.yaml @@ -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" @@ -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" @@ -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 diff --git a/fixtures/opencontrol_fixtures_with_markdown/components/EC2/component.yaml b/fixtures/opencontrol_fixtures_with_markdown/components/EC2/component.yaml index 8a141fc0..44dfd94e 100644 --- a/fixtures/opencontrol_fixtures_with_markdown/components/EC2/component.yaml +++ b/fixtures/opencontrol_fixtures_with_markdown/components/EC2/component.yaml @@ -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" @@ -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" @@ -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 From dc3c810fe64fcacb7b3af38bcf62d544714846e3 Mon Sep 17 00:00:00 2001 From: "James C. Scott" Date: Wed, 15 Jun 2016 13:23:04 -0400 Subject: [PATCH 4/4] Adjust gitbook fixtures for control_origin output --- .../complete_export/standards/NIST-800-53-CM-2.md | 2 ++ .../complete_export/standards/PCI-DSS-MAY-2015-1.1.md | 2 ++ .../complete_export/standards/PCI-DSS-MAY-2015-2.1.md | 2 ++ .../complete_export_with_markdown/standards/NIST-800-53-CM-2.md | 2 ++ .../standards/PCI-DSS-MAY-2015-1.1.md | 2 ++ .../standards/PCI-DSS-MAY-2015-2.1.md | 2 ++ 6 files changed, 12 insertions(+) diff --git a/fixtures/exports_fixtures/complete_export/standards/NIST-800-53-CM-2.md b/fixtures/exports_fixtures/complete_export/standards/NIST-800-53-CM-2.md index 855b34ad..7436e8e1 100755 --- a/fixtures/exports_fixtures/complete_export/standards/NIST-800-53-CM-2.md +++ b/fixtures/exports_fixtures/complete_export/standards/NIST-800-53-CM-2.md @@ -5,6 +5,8 @@ ##### Responsible Role: AWS Staff +##### Control Origin: shared + ##### a Justification in narrative form A for CM-2 diff --git a/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-1.1.md b/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-1.1.md index 92f9c4c9..6af0c3c1 100755 --- a/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-1.1.md +++ b/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-1.1.md @@ -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) diff --git a/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-2.1.md b/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-2.1.md index 76b675fc..01414197 100755 --- a/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-2.1.md +++ b/fixtures/exports_fixtures/complete_export/standards/PCI-DSS-MAY-2015-2.1.md @@ -4,4 +4,6 @@ #### Amazon Elastic Compute Cloud ##### Responsible Role: AWS Staff + +##### Control Origin: inherited Justification in narrative form for 2.1 diff --git a/fixtures/exports_fixtures/complete_export_with_markdown/standards/NIST-800-53-CM-2.md b/fixtures/exports_fixtures/complete_export_with_markdown/standards/NIST-800-53-CM-2.md index 855b34ad..7436e8e1 100755 --- a/fixtures/exports_fixtures/complete_export_with_markdown/standards/NIST-800-53-CM-2.md +++ b/fixtures/exports_fixtures/complete_export_with_markdown/standards/NIST-800-53-CM-2.md @@ -5,6 +5,8 @@ ##### Responsible Role: AWS Staff +##### Control Origin: shared + ##### a Justification in narrative form A for CM-2 diff --git a/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-1.1.md b/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-1.1.md index 92f9c4c9..6af0c3c1 100755 --- a/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-1.1.md +++ b/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-1.1.md @@ -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) diff --git a/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-2.1.md b/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-2.1.md index 76b675fc..01414197 100755 --- a/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-2.1.md +++ b/fixtures/exports_fixtures/complete_export_with_markdown/standards/PCI-DSS-MAY-2015-2.1.md @@ -4,4 +4,6 @@ #### Amazon Elastic Compute Cloud ##### Responsible Role: AWS Staff + +##### Control Origin: inherited Justification in narrative form for 2.1