@@ -17,7 +17,7 @@ def initialize(xccdf, replace_tags = nil)
1717 @xccdf = replace_tags_in_xccdf ( replace_tags , @xccdf ) unless replace_tags . nil?
1818 cci_list_path = File . join ( File . dirname ( __FILE__ ) , '../data/U_CCI_List.xml' )
1919 @cci_items = HappyMapperTools ::CCIAttributes ::CCI_List . parse ( File . read ( cci_list_path ) )
20- # @cci_items = HappyMapperTools::CCIAttributes::CCI_List.parse(File.read('./data/U_CCI_List.xml'))
20+ register_after_parse_callbacks
2121 @benchmark = HappyMapperTools ::StigAttributes ::Benchmark . parse ( @xccdf )
2222 end
2323
@@ -89,6 +89,14 @@ def inject_metadata(metadata = '{}')
8989
9090 private
9191
92+ def register_after_parse_callbacks
93+ # Determine if the parsed Ident is refrencing a legacy ID number.
94+ HappyMapperTools ::StigAttributes ::Ident . after_parse do |object |
95+ object . cci = object . system . eql? ( 'http://cyber.mil/cci' )
96+ object . legacy = !object . cci
97+ end
98+ end
99+
92100 def replace_tags_in_xccdf ( replace_tags , xccdf_xml )
93101 replace_tags . each do |tag |
94102 xccdf_xml = xccdf_xml . gsub ( /(<|<)#{ tag } (>|>)/ , "$#{ tag } " )
@@ -133,8 +141,9 @@ def insert_controls
133141 control [ 'tags' ] [ 'rid' ] = group . rule . id
134142 control [ 'tags' ] [ 'stig_id' ] = group . rule . version
135143 control [ 'tags' ] [ 'fix_id' ] = group . rule . fix . id
136- control [ 'tags' ] [ 'cci' ] = group . rule . idents
137- control [ 'tags' ] [ 'nist' ] = @cci_items . fetch_nists ( group . rule . idents )
144+ control [ 'tags' ] [ 'cci' ] = group . rule . idents . select { |i | i . cci } . map { |i | i . ident }
145+ control [ 'tags' ] [ 'legacy' ] = group . rule . idents . select { |i | i . legacy } . map { |i | i . ident }
146+ control [ 'tags' ] [ 'nist' ] = @cci_items . fetch_nists ( control [ 'tags' ] [ 'cci' ] )
138147 control [ 'tags' ] [ 'false_negatives' ] = group . rule . description . false_negatives if group . rule . description . false_negatives != ''
139148 control [ 'tags' ] [ 'false_positives' ] = group . rule . description . false_positives if group . rule . description . false_positives != ''
140149 control [ 'tags' ] [ 'documentable' ] = group . rule . description . documentable if group . rule . description . documentable != ''
0 commit comments