Skip to content

Commit d4ee848

Browse files
janeunerBialogs
andauthored
to_xccdf: Enable STIGViewer support for automatic CCI descriptions. (#222)
* XCCDF ident elements with CCI values should use a cyber.mil/cci system attribute to display correctly in STIG Viewer. * inspec2xccdf: Add support for Legacy IDs in the DISA STIGViewer. * to_xccdf: refactored ident system logic for CCIs into the Ident constructor Signed-off-by: Jarod Neuner <jarod@neuner.us> Co-authored-by: Kyle <Bialogs@users.noreply.github.com>
1 parent d982e0d commit d4ee848

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

lib/happy_mapper_tools/benchmark.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ class Ident
6565
tag 'ident'
6666
attribute :system, String, tag: 'system'
6767
content :ident, String
68+
def initialize(ident_str)
69+
@ident = ident_str
70+
if ident_str =~ /^(CCI-[0-9]{6})$/
71+
@system = 'http://cyber.mil/cci'
72+
else
73+
@system = 'http://cyber.mil/legacy'
74+
end
75+
end
6876
end
6977

7078
# Class Fixtext maps from the 'fixtext' from Benchmark XML file using HappyMapper

lib/utilities/xccdf/from_inspec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def parse_data_for_xccdf(json) # rubocop:disable Metrics/AbcSize, Metrics/Cyclom
3434
c_data[c_id]['rweight'] = control['tags']['rweight'] if control['tags']['rweight'] # Optional attribute where N/A is not schema compliant
3535
c_data[c_id]['stig_id'] = control['tags']['stig_id'] || DATA_NOT_FOUND_MESSAGE
3636
c_data[c_id]['cci'] = control['tags']['cci'] if control['tags']['cci'] # Optional attribute
37+
c_data[c_id]['legacy'] = control['tags']['legacy'] if control['tags']['legacy'] # Optional attribute
3738
c_data[c_id]['nist'] = control['tags']['nist'] || ['unmapped']
3839
c_data[c_id]['check'] = control['tags']['check'] || DATA_NOT_FOUND_MESSAGE
3940
c_data[c_id]['checkref'] = control['tags']['checkref'] || DATA_NOT_FOUND_MESSAGE

lib/utilities/xccdf/to_xccdf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def build_groups # rubocop:disable Metrics/AbcSize
7474
end
7575

7676
group.rule.ident = build_rule_idents(control['cci']) if control['cci']
77+
group.rule.ident += build_rule_idents(control['legacy']) if control['legacy']
7778

7879
group.rule.fixtext = HappyMapperTools::Benchmark::Fixtext.new
7980
group.rule.fixtext.fixref = control['fix_id']
@@ -126,10 +127,7 @@ def build_rule_idents(idents)
126127

127128
# Each rule identifier is a different element
128129
idents.map do |identifier|
129-
ident = HappyMapperTools::Benchmark::Ident.new
130-
ident.system = 'https://public.cyber.mil/stigs/cci/'
131-
ident.ident = identifier
132-
ident
130+
ident = HappyMapperTools::Benchmark::Ident.new identifier
133131
end
134132
end
135133

@@ -227,6 +225,7 @@ def populate_rule_result(control, result, result_status)
227225
rule_result.instance = result['code_desc']
228226

229227
rule_result.ident = build_rule_idents(control['cci']) if control['cci']
228+
rule_result.ident += build_rule_idents(control['legacy']) if control['legacy']
230229

231230
# Fix information is only necessary when there are failed tests
232231
rule_result.fix = build_rule_fix(control['fix_id']) if control['fix_id'] && result_status == 'fail'

0 commit comments

Comments
 (0)