Skip to content

Commit dc0e419

Browse files
janeunerKyle Fagan
and
Kyle Fagan
authored
inspec2xccdf: Check Text, Fix Text, and MISC→Mitigations (#226)
* .gitignore *.swp (vim) and .raketasks~ * inspec2xccdf: Add support for the Check Text, Fix Text, and MISC→Mitigations fields in the DISA STIGViewer. * Move utilities into inspec. Update the conversion from inspec to xccdf for newer inspec runs. * Update tests to work without Utils * Add test for v4.28 inspec result output json Co-authored-by: Kyle Fagan <kfagan@mitre.org>
1 parent 3cd5ad4 commit dc0e419

File tree

10 files changed

+1224
-900
lines changed

10 files changed

+1224
-900
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
platform: [ ubuntu-16.04, ubuntu-latest, macos-latest, windows-latest ]
15+
platform: [ ubuntu-latest, macos-latest, windows-latest ]
1616
ruby: [ 2.7 ]
1717
runs-on: ${{ matrix.platform }}
1818

@@ -57,7 +57,8 @@ jobs:
5757
inspec_tools inspec2ckl -j examples/sample_json/rhel-simp.json -o inspec2ckl_test_1.ckl
5858
inspec_tools inspec2ckl -j test/data/inspec_1.json -o test/data/inspec2ckl_test_2.ckl
5959
inspec_tools inspec2xccdf -j examples/sample_json/rhel-simp.json -a lib/data/attributes.yml -o inspec2xccdf_test.xml
60-
inspec_tools inspec2xccdf -j examples/sample_json/rhel-simp.json -a examples/inspec2xccdf/xccdf_compliant_attribute.json -m examples/inspec2xccdf/metadata.json -o inspec2xccdf_11.xml
60+
inspec_tools inspec2xccdf -j examples/sample_json/rhel-simp.json -a examples/inspec2xccdf/xccdf_compliant_attribute.json -m examples/inspec2xccdf/metadata.json -o inspec2xccdf_11_1.xml
61+
inspec_tools inspec2xccdf -j examples/sample_json/inspec-v4.28.0.json -a examples/inspec2xccdf/xccdf_compliant_attribute.json -o inspec2xccdf_11_2.xml
6162
inspec_tools compliance -j examples/sample_json/single_control_results.json -f examples/sample_yaml/threshold.yaml
6263
env:
6364
CHEF_LICENSE: "accept"
@@ -72,20 +73,26 @@ jobs:
7273
env:
7374
CHEF_LICENSE: "accept"
7475
- name: Validate Output CKL with xmllint
75-
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'ubuntu-16.04'
76+
if: matrix.platform == 'ubuntu-latest'
7677
uses: ChristophWurst/xmllint-action@v1
7778
with:
7879
xml-file: inspec2ckl_test_1.ckl
7980
xml-schema-file: test/schemas/U_Checklist_Schema_V2-3.xsd
8081
- name: Validate Output CKL with xmllint
81-
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'ubuntu-16.04'
82+
if: matrix.platform == 'ubuntu-latest'
8283
uses: ChristophWurst/xmllint-action@v1
8384
with:
8485
xml-file: test/data/inspec2ckl_test_2.ckl
8586
xml-schema-file: test/schemas/U_Checklist_Schema_V2-3.xsd
86-
- name: Validate XCCDF 1.1 with xmllint
87-
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'ubuntu-16.04'
87+
- name: Validate XCCDF 1.1 with xmllint (Inspec Version < 4.28)
88+
if: matrix.platform == 'ubuntu-latest'
8889
uses: ChristophWurst/xmllint-action@v1
8990
with:
90-
xml-file: inspec2xccdf_11.xml
91+
xml-file: inspec2xccdf_11_1.xml
92+
xml-schema-file: test/schemas/xccdf_114/xccdf-1.1.4.xsd
93+
- name: Validate XCCDF 1.1 with xmllint (Inspec Version > 4.28)
94+
if: matrix.platform == 'ubuntu-latest'
95+
uses: ChristophWurst/xmllint-action@v1
96+
with:
97+
xml-file: inspec2xccdf_11_2.xml
9198
xml-schema-file: test/schemas/xccdf_114/xccdf-1.1.4.xsd

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
*.gem
22
*.rbc
3+
*.swp
34
.bundle
45
.config
56
.idea
67
.yardoc
8+
.rake_tasks~
79
_yardoc
810
Gemfile.lock
911
coverage

.rubocop_todo.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2021-05-27 14:19:48 UTC using RuboCop version 1.14.0.
3+
# on 2021-05-11 19:56:27 UTC using RuboCop version 1.14.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -13,30 +13,30 @@ Lint/FloatComparison:
1313
- 'lib/utilities/inspec_util.rb'
1414
- 'lib/utilities/xccdf/xccdf_score.rb'
1515

16-
# Offense count: 41
16+
# Offense count: 42
1717
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
1818
Metrics/AbcSize:
1919
Max: 182
2020

2121
# Offense count: 9
2222
# Configuration parameters: CountComments, CountAsOne.
2323
Metrics/ClassLength:
24-
Max: 296
24+
Max: 550
2525

26-
# Offense count: 18
26+
# Offense count: 17
2727
# Configuration parameters: IgnoredMethods.
2828
Metrics/CyclomaticComplexity:
2929
Max: 30
3030

31-
# Offense count: 49
31+
# Offense count: 66
3232
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
3333
Metrics/MethodLength:
34-
Max: 46
34+
Max: 44
3535

36-
# Offense count: 15
36+
# Offense count: 14
3737
# Configuration parameters: IgnoredMethods.
3838
Metrics/PerceivedComplexity:
39-
Max: 31
39+
Max: 30
4040

4141
# Offense count: 2
4242
# Configuration parameters: AllowedNames.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"name": "example_id",
3+
"title": "bTitle",
4+
"maintainer": "The Authors",
5+
"copyright": "The Authors",
6+
"copyright_email": "you@example.com",
7+
"license": "Apache-2.0",
8+
"summary": "bDescription",
9+
"version": "0.1.0",
10+
"supports": [],
11+
"controls": [
12+
{
13+
"title": "Ensure configuration is set in situations",
14+
"desc": "Identify the threat actor and threat vector.\n \n Describe the mitigation.\n \n Note the external dependencies of the configuration.",
15+
"descriptions": {
16+
"default": "Identify the threat actor and threat vector.\n \n Describe the mitigation.\n \n Note the external dependencies of the configuration.",
17+
"rationale": "",
18+
"check": "Describe preconditions for conducting the check.\n \nList each step of the check.\n\nIdentify mitigating factors.\n\nDefine success or failure conditions.",
19+
"fix": "Describe preconditions for changing the configuration.\n\nList each step of applying the configuration.\n\nIdentify risks to confidentialty, integrity, or availability associated with applying the configuration."
20+
},
21+
"impact": 0.5,
22+
"refs": [],
23+
"tags": {
24+
"severity": "low",
25+
"gtitle": "SRG-APP-000220-ZZZ-567890",
26+
"gid": "gid_unused",
27+
"rid": "r1_rule",
28+
"stig_id": "stig_id_unused",
29+
"fix_id": "fix_id_unused",
30+
"cci": [
31+
"CCI-001499",
32+
"CCI-000197"
33+
],
34+
"legacy": [
35+
"V-72845",
36+
"SV-87497"
37+
],
38+
"nist": [
39+
"CM-5 (6)",
40+
"IA-5 (1) (c)"
41+
]
42+
},
43+
"code": "control 'X-123456' do\n title 'Ensure configuration is set in situations'\n desc \"Identify the threat actor and threat vector.\n \n Describe the mitigation.\n \n Note the external dependencies of the configuration.\n \"\n desc 'rationale', ''\n desc 'check', \"Describe preconditions for conducting the check.\n \nList each step of the check.\n\nIdentify mitigating factors.\n\nDefine success or failure conditions.\n\"\n desc 'fix', \"\n Describe preconditions for changing the configuration.\n\n List each step of applying the configuration.\n\n Identify risks to confidentialty, integrity, or availability associated with applying the configuration.\n \"\n impact 0.5\n tag severity: 'low'\n tag gtitle: 'SRG-APP-000220-ZZZ-567890'\n tag gid: 'gid_unused'\n tag rid: 'r1_rule'\n tag stig_id: 'stig_id_unused'\n tag fix_id: 'fix_id_unused'\n tag cci: ['CCI-001499', 'CCI-000197']\n tag legacy: ['V-72845', 'SV-87497']\n tag nist: ['CM-5 (6)', 'IA-5 (1) (c)']\nend\n",
44+
"source_location": {
45+
"ref": "./controls/g1Identifier.rb",
46+
"line": 3
47+
},
48+
"id": "X-123456"
49+
},
50+
{
51+
"title": "Ensure a log metric filter and alarm exist for AWS Config\nconfiguration changes",
52+
"desc": "Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.",
53+
"descriptions": {
54+
"default": "Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.",
55+
"rationale": "",
56+
"check": "N/A",
57+
"fix": "ft2FixText"
58+
},
59+
"impact": 0.5,
60+
"refs": [],
61+
"tags": {
62+
"severity": "medium",
63+
"gtitle": "g2Title",
64+
"gid": "g2Identifier",
65+
"rid": "r2_rule",
66+
"stig_id": "r2Version",
67+
"fix_id": "f2Identifier",
68+
"cci": [
69+
"CCI-001495",
70+
"CCI-000196"
71+
],
72+
"legacy": [
73+
"identVLegacy3",
74+
"identVLegacy4"
75+
],
76+
"nist": [
77+
"AU-9",
78+
"IA-5 (1) (c)"
79+
]
80+
},
81+
"code": "control 'g2Identifier' do\n title \"Ensure a log metric filter and alarm exist for AWS Config\nconfiguration changes\"\n desc \"Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.\"\n desc 'rationale', ''\n desc 'check', 'N/A'\n desc 'fix', 'ft2FixText'\n impact 0.5\n tag severity: 'medium'\n tag gtitle: 'g2Title'\n tag gid: 'g2Identifier'\n tag rid: 'r2_rule'\n tag stig_id: 'r2Version'\n tag fix_id: 'f2Identifier'\n tag cci: ['CCI-001495', 'CCI-000196']\n tag legacy: ['identVLegacy3', 'identVLegacy4']\n tag nist: ['AU-9', 'IA-5 (1) (c)']\nend\n",
82+
"source_location": {
83+
"ref": "./controls/g2Identifier.rb",
84+
"line": 3
85+
},
86+
"id": "g2Identifier"
87+
},
88+
{
89+
"title": "Ensure a log metric filter and alarm exist for AWS Config\nconfiguration changes",
90+
"desc": "Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.",
91+
"descriptions": {
92+
"default": "Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.",
93+
"rationale": "",
94+
"check": "N/A",
95+
"fix": "ft3FixText"
96+
},
97+
"impact": 0.5,
98+
"refs": [],
99+
"tags": {
100+
"severity": "medium",
101+
"gtitle": "g3Title",
102+
"gid": "g3Identifier",
103+
"rid": "r3_rule",
104+
"stig_id": "r3Version",
105+
"fix_id": "f3Identifier",
106+
"cci": [
107+
"CCI-001495",
108+
"CCI-000196"
109+
],
110+
"legacy": [
111+
"identVLegacy5",
112+
"identVLegacy6"
113+
],
114+
"nist": [
115+
"AU-9",
116+
"IA-5 (1) (c)"
117+
]
118+
},
119+
"code": "control 'g3Identifier' do\n title \"Ensure a log metric filter and alarm exist for AWS Config\nconfiguration changes\"\n desc \"Real-time monitoring of API calls can be achieved by directing\nCloudTrail Logs to CloudWatch Logs and establishing corresponding metric\nfilters and alarms. It is recommended that a metric filter and alarm be\nestablished for detecting changes to CloudTrail's configurations.\"\n desc 'rationale', ''\n desc 'check', 'N/A'\n desc 'fix', 'ft3FixText'\n impact 0.5\n tag severity: 'medium'\n tag gtitle: 'g3Title'\n tag gid: 'g3Identifier'\n tag rid: 'r3_rule'\n tag stig_id: 'r3Version'\n tag fix_id: 'f3Identifier'\n tag cci: ['CCI-001495', 'CCI-000196']\n tag legacy: ['identVLegacy5', 'identVLegacy6']\n tag nist: ['AU-9', 'IA-5 (1) (c)']\nend\n",
120+
"source_location": {
121+
"ref": "./controls/g3Identifier.rb",
122+
"line": 3
123+
},
124+
"id": "g3Identifier"
125+
}
126+
],
127+
"groups": [
128+
{
129+
"title": null,
130+
"controls": [
131+
"X-123456"
132+
],
133+
"id": "controls/g1Identifier.rb"
134+
},
135+
{
136+
"title": null,
137+
"controls": [
138+
"g2Identifier"
139+
],
140+
"id": "controls/g2Identifier.rb"
141+
},
142+
{
143+
"title": null,
144+
"controls": [
145+
"g3Identifier"
146+
],
147+
"id": "controls/g3Identifier.rb"
148+
}
149+
],
150+
"inputs": [],
151+
"sha256": "4e73883fc2f0d7c85e953346717c149539978c2780bc52c99276e3d6d6fe0567",
152+
"status_message": "",
153+
"status": "loaded",
154+
"generator": {
155+
"name": "inspec",
156+
"version": "4.28.0"
157+
}
158+
}

0 commit comments

Comments
 (0)