opencontrol-linter 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +94 -0
  4. data/exe/opencontrol-linter +8 -0
  5. data/lib/opencontrol.rb +3 -0
  6. data/lib/opencontrol/cli.rb +231 -0
  7. data/lib/opencontrol/messages.rb +45 -0
  8. data/lib/opencontrol/version.rb +22 -0
  9. data/vendor/README.md +9 -0
  10. data/vendor/schemas/CONTRIBUTING.md +37 -0
  11. data/vendor/schemas/README.md +175 -0
  12. data/vendor/schemas/examples/component_v3.0.0.yaml +70 -0
  13. data/vendor/schemas/examples/component_v3.1.0.yaml +81 -0
  14. data/vendor/schemas/examples/opencontrol_v1.0.0.yaml +22 -0
  15. data/vendor/schemas/kwalify/README.md +31 -0
  16. data/vendor/schemas/kwalify/certification/v1.0.0.yaml +12 -0
  17. data/vendor/schemas/kwalify/component/test_data_validity.py +25 -0
  18. data/vendor/schemas/kwalify/component/v1.0.0.yaml +100 -0
  19. data/vendor/schemas/kwalify/component/v2.0.0.yaml +100 -0
  20. data/vendor/schemas/kwalify/component/v3.0.0.yaml +112 -0
  21. data/vendor/schemas/kwalify/component/v3.1.0.yaml +138 -0
  22. data/vendor/schemas/kwalify/opencontrol/v1.0.0.yaml +67 -0
  23. data/vendor/schemas/kwalify/requirements.txt +3 -0
  24. data/vendor/schemas/kwalify/standard/v1.0.0.yaml +14 -0
  25. data/vendor/schemas/transformation-scripts/utils.py +12 -0
  26. data/vendor/schemas/transformation-scripts/v1_example.yaml +40 -0
  27. data/vendor/schemas/transformation-scripts/v1_from_v2_example.yaml +41 -0
  28. data/vendor/schemas/transformation-scripts/v1_to_v2.py +75 -0
  29. data/vendor/schemas/transformation-scripts/v2_example.yaml +45 -0
  30. data/vendor/schemas/transformation-scripts/v2_from_v1_example.yaml +45 -0
  31. data/vendor/schemas/transformation-scripts/v2_to_v1.py +74 -0
  32. metadata +320 -0
@@ -0,0 +1,37 @@
1
+ ## Welcome!
2
+
3
+ We're so glad you're thinking about contributing to an 18F open source project! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. We love all friendly contributions.
4
+
5
+ We want to ensure a welcoming environment for all of our projects. Our staff follow the [18F Code of Conduct](https://github.com/18F/code-of-conduct/blob/master/code-of-conduct.md) and all contributors should do the same.
6
+
7
+ We encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md).
8
+
9
+ If you have any questions or want to read more, check out the [18F Open Source Policy GitHub repository](https://github.com/18f/open-source-policy), or just [shoot us an email](mailto:18f@gsa.gov).
10
+
11
+ ## Public domain
12
+
13
+ This project is in the public domain within the United States, and
14
+ copyright and related rights in the work worldwide are waived through
15
+ the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
16
+
17
+ All contributions to this project will be released under the CC0
18
+ dedication. By submitting a pull request, you are agreeing to comply
19
+ with this waiver of copyright interest.
20
+
21
+ ## Versioning
22
+
23
+ This project abides by [Semantic Versioning](http://semver.org/). [The Kwalify file](opencontrol-component-kwalify-schema.yaml) will be the source of truth for any given version. Examples of what would constitute each type of version bump are below.
24
+
25
+ ### Major
26
+
27
+ * New required field/attribute added
28
+ * Structure of a field/attribute changes
29
+
30
+ ### Minor
31
+
32
+ * Non-required attribute/field added
33
+ * Attribute/field deprecated
34
+
35
+ ### Patch
36
+
37
+ (We don't anticipate bumping the patch version.)
@@ -0,0 +1,175 @@
1
+ # Schemas
2
+
3
+ YAML schema, examples, and validators for OpenControl format. You can find the formal definitions and learn about how to do validation in the [`kwalify/`](kwalify/) folder. The examples from the Glorious (Fake) Nation of Freedonia are the complete standalone example targeted at OpenControl beginners, so we recommend looking at those first.
4
+
5
+ ## Full project examples
6
+
7
+ * [Freedonia](https://github.com/opencontrol/freedonia-compliance#readme)
8
+ * [cloud.gov](https://github.com/18F/cg-compliance) ([GitBook](https://compliance.cloud.gov/) [rendered with Compliance Masonry](https://github.com/opencontrol/compliance-masonry#creating-gitbook-documentation))
9
+ * [Environmental Protection Agency (EPA) eManifest/eRegs Notice and Comment](https://github.com/18F/epa-notice)
10
+ * [CALC](https://github.com/18F/calc)
11
+ * [Docker Datacenter example](https://github.com/docker/compliance/tree/master/examples/opencontrol/DockerEE-Moderate-ATO)
12
+
13
+ ## Components
14
+
15
+ Components represent individual parts of an application or organizational policy that deal with specific security requirements. For example, in the [AWS compliance documentation](https://github.com/opencontrol/aws-compliance) the [EC2](https://github.com/opencontrol/aws-compliance/blob/master/IAM/component.yaml) component deals with access control and identity management security requirements. In the [Cloud Foundry compliance documentation](https://github.com/opencontrol/cf-compliance), the [UAA](https://github.com/opencontrol/cf-compliance/blob/master/UAA/component.yaml) the [Cloud Controller](https://github.com/opencontrol/cf-compliance/tree/master/CloudController) components deal with those requirements. In a straightforward Django-based application, for example, Django would be the component that deals with access control and identity management. As a developer building an SSP you most likely only deal with the component documentation.
16
+
17
+ ### Examples
18
+
19
+ * [Amazon Web Services (AWS)](https://github.com/opencontrol/aws-compliance)
20
+ * [The (simplified) Freedonia version](https://github.com/opencontrol/freedonia-aws-compliance)
21
+ * [Cloud Foundry](https://github.com/opencontrol/cf-compliance)
22
+ * [Docker Datacenter](https://github.com/docker/ddc-opencontrol)
23
+
24
+ ### Structure
25
+
26
+ ```yaml
27
+ name: Name of the component
28
+ key: Key of the component (defaults to the filename if not present)
29
+ documentation_complete: Manual check if the documentation is complete (for gap analysis)
30
+ schema_version: 3.0.0
31
+ references:
32
+ - name: Name of the reference ie. EC2 website
33
+ path: Relative path of local file or URL ie. diagrams/diagram-1.png
34
+ type: Type of reference ie. Image, URL
35
+ - name: Name of the reference ie. EC2 website
36
+ path: Relative path of local file or URL ie. diagrams/diagram-1.png
37
+ type: Type of reference ie. Image, URL
38
+ verifications:
39
+ - key: Key of verification
40
+ name: Name of verification
41
+ path: Relative path of local file or URL ie. diagrams/diagram-1.png
42
+ type: Type of reference ie. Image, URL
43
+ - key: Key of verification
44
+ name: Name of verification
45
+ path: Relative path of local file or URL ie. diagrams/diagram-1.png
46
+ type: Type of reference ie. Image, URL
47
+ satisfies:
48
+ - standard_key: Standard Key (NIST-800-53)
49
+ control_key: Control Key (CM-2)
50
+ narrative:
51
+ - key: The optional key that represents a particular section of the control. If the key is not specified, assume the string in the following text represents the entire control
52
+ text: The narrative text for the particular section / entire control if there is no key specified
53
+ implementation_statuses:
54
+ - Used for gap analysis, can only be one of the following:
55
+ - partial
56
+ - planned
57
+ - complete
58
+ - none
59
+ control_origins:
60
+ - shared
61
+ - inherited
62
+ - Other text representing the control origination.
63
+ parameters:
64
+ - key: "The key for a particular parameter of the specific control"
65
+ text: "The parameter text for a particular parameter of a specific control"
66
+ covered_by:
67
+ - verification_key: The specific verification ID that the reference links, no component or system is needed for internal references
68
+ - system_key: System name of the verification (can link to other systems / components)
69
+ component_key: System name of the verification (can link to other systems / components)
70
+ verification_key: The specific verification ID that the reference links to
71
+ ```
72
+
73
+ ### Validation
74
+
75
+ ```bash
76
+ kwalify -f kwalify/component/v3.0.0.yaml examples/component_v3.0.0.yaml
77
+ # OR
78
+ pykwalify -s kwalify/component/v3.0.0.yaml -d examples/component_v3.0.0.yaml
79
+ ```
80
+
81
+ ## Standards
82
+
83
+ A standard is a list composed of individual security requirements called controls.
84
+
85
+ ### Examples
86
+
87
+ ```yaml
88
+ # nist-800-53.yaml
89
+ standards:
90
+ C-2:
91
+ name: User Access
92
+ description: There is an affordance for managing access by...
93
+
94
+ # PCI.yaml
95
+ standards:
96
+ Regulation-6:
97
+ name: User Access PCI
98
+ description: There is an affordance for managing access by...
99
+ ```
100
+
101
+ #### See also
102
+
103
+ * [Freedonia FRIST](https://github.com/opencontrol/freedonia-frist)
104
+ * [National Institute of Standards and Technology (NIST) 800-53](https://github.com/opencontrol/NIST-800-53-Standards)
105
+ * [Payment Card Industry Data Security Standard (PCI DSS)](https://github.com/opencontrol/PCI-DSS-Certifications)
106
+
107
+ ## Certifications
108
+
109
+ Since standards can have thousands of security requirements (aka controls), agencies like the [GSA](http://www.gsa.gov/) or organizations such as [FedRAMP](https://www.fedramp.gov) have curated a list of controls they require in order grant an IT system Authority to Operate (ATO). These are also known as "baselines". The GSA, for example, developed a baseline called [the Lightweight ATO (LATO)](https://gsablogs.gsa.gov/innovation/2014/12/10/it-security-security-in-an-agile-development-cloud-world-by-kurt-garbars/), which uses only 24 controls.
110
+
111
+ ### Example
112
+
113
+ ```yaml
114
+ # Fisma.yaml
115
+ standards:
116
+ NIST-800-53:
117
+ C-2:
118
+ C-3:
119
+ PCI:
120
+ 6:
121
+ ```
122
+
123
+ #### See also
124
+
125
+ * [Freedonia FRIST](https://github.com/opencontrol/freedonia-frist)
126
+ * [General Services Administration (GSA) certifications](https://github.com/18F/GSA-Certifications)
127
+
128
+ ## Systems
129
+
130
+ The `opencontrol.yaml` file defines an application's documentation configuration settings.
131
+
132
+ ### Structure
133
+
134
+ ```yaml
135
+ schema_version: "1.0.0" # 1.0.0 is the current opencontrol.yaml schema version
136
+ name: Project_Name # Name of the project
137
+ metadata:
138
+ description: "A description of the system"
139
+ maintainers:
140
+ - maintainer_email@email.com
141
+ components: # A list of paths to components written in the opencontrol format for more information view: https://github.com/opencontrol/schemas
142
+ - ./component-1
143
+ certifications: # An optional list of certifications for more information visit: https://github.com/opencontrol/schemas
144
+ - ./cert-1.yaml
145
+ standards: # An optional list of standards for more information visit: https://github.com/opencontrol/schemas
146
+ - ./standard-1.yaml
147
+ dependencies:
148
+ certifications: # An optional list of certifications stored remotely
149
+ - url: https://github.com/18F/GSA-Certifications
150
+ revision: master
151
+ systems: # An optional list of repos that contain an opencontrol.yaml stored remotely
152
+ - url: https://github.com/18F/cg-compliance
153
+ revision: master
154
+ standards: # An optional list of remote repos containing standards info that contain an opencontrol.yaml
155
+ - url: https://github.com/opencontrol/NIST-800-53-Standards
156
+ revision: master
157
+ ```
158
+
159
+ For version control systems, a option key `contextdir` can be specified to handle multiple opencontrol content directories in a single repository.
160
+ For example:
161
+
162
+ ```
163
+ dependencies:
164
+ - url: https://github.com/organization/repository
165
+ contextdir: subdirectory_in_repository
166
+ revision: branch
167
+ ```
168
+
169
+ ### Validation
170
+
171
+ ```bash
172
+ kwalify -f kwalify/opencontrol/v1.0.0.yaml examples/opencontrol_v1.0.0.yaml
173
+ # OR
174
+ pykwalify -s kwalify/opencontrol/v1.0.0.yaml -d examples/opencontrol_v1.0.0.yaml
175
+ ```
@@ -0,0 +1,70 @@
1
+ documentation_complete: false
2
+ name: Amazon Elastic Compute Cloud
3
+ references:
4
+ - name: Reference
5
+ path: http://VerificationURL.com
6
+ satisfies:
7
+ - control_key: CM-2
8
+ covered_by:
9
+ - verification_key: EC2_Verification_1
10
+ - component_key: UAA
11
+ system_key: CloudFoundry
12
+ verification_key: UAA_Verification_1
13
+ implementation_status: partial
14
+ control_origin: shared
15
+ narrative:
16
+ - key: "a"
17
+ text: "Justification in narrative form A for CM-2"
18
+ - key: "b"
19
+ text: "Justification in narrative form B for CM-2"
20
+ standard_key: NIST-800-53
21
+ - control_key: 1.1
22
+ covered_by:
23
+ - verification_key: EC2_Verification_1
24
+ - component_key: UAA
25
+ system_key: CloudFoundry
26
+ verification_key: UAA_Verification_1
27
+ implementation_status: partial
28
+ control_origin: inherited
29
+ parameters:
30
+ - key: "a"
31
+ text: "Parameter A for 1.1"
32
+ - key: "b"
33
+ text: "Parameter B for 1.1"
34
+ narrative:
35
+ - key: "a"
36
+ text: "Justification in narrative form A for 1.1"
37
+ - key: "b"
38
+ text: "Justification in narrative form B for 1.1"
39
+ standard_key: PCI-DSS-MAY-2015
40
+ - control_key: 1.1.1
41
+ covered_by: []
42
+ implementation_status: partial
43
+ control_origin: inherited
44
+ narrative:
45
+ - key: "a"
46
+ text: "Justification in narrative form A for 1.1.1"
47
+ - key: "b"
48
+ text: "Justification in narrative form B for 1.1.1"
49
+ parameters:
50
+ - key: "a"
51
+ text: "Parameter A for 1.1.1"
52
+ - key: "b"
53
+ text: "Parameter B for 1.1.1"
54
+ standard_key: PCI-DSS-MAY-2015
55
+ - control_key: 2.1
56
+ covered_by: []
57
+ implementation_status: partial
58
+ control_origin: inherited
59
+ narrative:
60
+ - text: "Justification in narrative form for 2.1"
61
+ standard_key: PCI-DSS-MAY-2015
62
+ responsible_role: "AWS Staff"
63
+ schema_version: 3.0.0
64
+ verifications:
65
+ - key: EC2_Verification_2
66
+ name: EC2 Governor 2
67
+ path: artifact-ec2-1.png
68
+ - key: EC2_Verification_1
69
+ name: EC2 Verification 1
70
+ path: http://VerificationURL.com
@@ -0,0 +1,81 @@
1
+ documentation_complete: false
2
+ name: Amazon Elastic Compute Cloud
3
+ references:
4
+ - name: Reference
5
+ path: http://VerificationURL.com
6
+ type: URL
7
+ satisfies:
8
+ - control_key: CM-2
9
+ covered_by:
10
+ - verification_key: EC2_Verification_1
11
+ - component_key: UAA
12
+ system_key: CloudFoundry
13
+ verification_key: UAA_Verification_1
14
+ implementation_statuses:
15
+ - partial
16
+ - planned
17
+ control_origins:
18
+ - shared
19
+ - inherited
20
+ references:
21
+ - name: Reference2
22
+ path: http://VerificationURL2.com
23
+ type: URL
24
+ narrative:
25
+ - key: "a"
26
+ text: "Justification in narrative form A for CM-2"
27
+ - key: "b"
28
+ text: "Justification in narrative form B for CM-2"
29
+ standard_key: NIST-800-53
30
+ - control_key: 1.1
31
+ covered_by:
32
+ - verification_key: EC2_Verification_1
33
+ - component_key: UAA
34
+ system_key: CloudFoundry
35
+ verification_key: UAA_Verification_1
36
+ implementation_status: partial
37
+ control_origin: inherited
38
+ parameters:
39
+ - key: "a"
40
+ text: "Parameter A for 1.1"
41
+ - key: "b"
42
+ text: "Parameter B for 1.1"
43
+ narrative:
44
+ - key: "a"
45
+ text: "Justification in narrative form A for 1.1"
46
+ - key: "b"
47
+ text: "Justification in narrative form B for 1.1"
48
+ standard_key: PCI-DSS-MAY-2015
49
+ - control_key: 1.1.1
50
+ covered_by: []
51
+ implementation_status: partial
52
+ control_origin: inherited
53
+ narrative:
54
+ - key: "a"
55
+ text: "Justification in narrative form A for 1.1.1"
56
+ - key: "b"
57
+ text: "Justification in narrative form B for 1.1.1"
58
+ parameters:
59
+ - key: "a"
60
+ text: "Parameter A for 1.1.1"
61
+ - key: "b"
62
+ text: "Parameter B for 1.1.1"
63
+ standard_key: PCI-DSS-MAY-2015
64
+ - control_key: 2.1
65
+ covered_by: []
66
+ implementation_status: partial
67
+ control_origin: inherited
68
+ narrative:
69
+ - text: "Justification in narrative form for 2.1"
70
+ standard_key: PCI-DSS-MAY-2015
71
+ responsible_role: "AWS Staff"
72
+ schema_version: 3.0.0
73
+ verifications:
74
+ - key: EC2_Verification_2
75
+ name: EC2 Governor 2
76
+ path: artifact-ec2-1.png
77
+ type: Image
78
+ - key: EC2_Verification_1
79
+ name: EC2 Verification 1
80
+ path: http://VerificationURL.com
81
+ type: URL
@@ -0,0 +1,22 @@
1
+ schema_version: "1.0.0" # 1.0.0 is the current opencontrol.yaml schema version
2
+ name: Project_Name # Name of the project
3
+ metadata:
4
+ description: "A description of the system"
5
+ maintainers:
6
+ - maintainer_email@email.com
7
+ components: # A list of paths to components written in the opencontrol format for more information view: https://github.com/opencontrol/schemas
8
+ - ./component-1
9
+ certifications: # An optional list of certifications for more information visit: https://github.com/opencontrol/schemas
10
+ - ./cert-1.yaml
11
+ standards: # An optional list of standards for more information visit: https://github.com/opencontrol/schemas
12
+ - ./standard-1.yaml
13
+ dependencies:
14
+ certifications: # An optional list of certifications stored remotely
15
+ - url: https://github.com/18F/GSA-Certifications
16
+ revision: master
17
+ systems: # An optional list of repos that contain an opencontrol.yaml stored remotely
18
+ - url: https://github.com/18F/cg-compliance
19
+ revision: master
20
+ standards: # An optional list of remote repos containing standards info that contain an opencontrol.yaml
21
+ - url: https://github.com/opencontrol/NIST-800-53-Standards
22
+ revision: master
@@ -0,0 +1,31 @@
1
+ # Kwalify schema files
2
+
3
+ The files in the subdirectories of this folder are organized by the type of file, and then named by the version of that file's schema. These YAML files are in the [Kwalify](http://www.kuwata-lab.com/kwalify/) format—see that site for documentation.
4
+
5
+ ## Validation
6
+
7
+ To validate your OpenControl files, do the following from your project root directory:
8
+
9
+ 1. Install Python (2 or 3).
10
+ 1. Ignore the `schemas/` directory from version control (e.g. `.gitignore`).
11
+ 1. Clone (or update) the [schemas](https://github.com/opencontrol/schemas) repository.
12
+
13
+ ```bash
14
+ git clone https://github.com/opencontrol/schemas.git
15
+ # or
16
+ cd schemas && git pull origin master && cd ..
17
+ ```
18
+
19
+ 1. Install the dependencies.
20
+
21
+ ```bash
22
+ pip install -r pip install -r schemas/kwalify/requirements.txt
23
+ ```
24
+
25
+ 1. Run the tests.
26
+
27
+ ```bash
28
+ pytest
29
+ ```
30
+
31
+ For a more advanced setup, see [18F's cloud.gov compliance repository](https://github.com/18F/cg-compliance) as an example of using these tests as part of continuous integration.
@@ -0,0 +1,12 @@
1
+ type: map
2
+ mapping:
3
+ standards:
4
+ type: map
5
+ mapping:
6
+ =:
7
+ type: map
8
+ mapping:
9
+ =:
10
+ type: any
11
+ name:
12
+ type: str
@@ -0,0 +1,25 @@
1
+ from glob import iglob
2
+ from pykwalify.core import Core
3
+ import yaml
4
+
5
+ def get_schema(version):
6
+ path = 'schemas/kwalify/component/v{}.yaml'.format(version)
7
+ contents = open(path)
8
+ return yaml.load(contents)
9
+
10
+ def create_validator(source_data):
11
+ version = source_data.get('schema_version', '3.1.0')
12
+ schema = get_schema(version)
13
+ validator = Core(source_data={}, schema_data=schema)
14
+ validator.source = source_data
15
+ return validator
16
+
17
+ def test_data_valid():
18
+ """ Check that the content of data fits with masonry schema v2 """
19
+ for component_file in iglob('*/component.yaml'):
20
+ source_data = yaml.load(open(component_file))
21
+ validator = create_validator(source_data)
22
+ try:
23
+ validator.validate(raise_exception=True)
24
+ except:
25
+ assert False, "Error found in: {0}".format(component_file)