@@ -17,7 +17,7 @@ def initialize(xccdf, replace_tags = nil)
17
17
@xccdf = replace_tags_in_xccdf ( replace_tags , @xccdf ) unless replace_tags . nil?
18
18
cci_list_path = File . join ( File . dirname ( __FILE__ ) , '../data/U_CCI_List.xml' )
19
19
@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
21
21
@benchmark = HappyMapperTools ::StigAttributes ::Benchmark . parse ( @xccdf )
22
22
end
23
23
@@ -89,6 +89,14 @@ def inject_metadata(metadata = '{}')
89
89
90
90
private
91
91
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
+
92
100
def replace_tags_in_xccdf ( replace_tags , xccdf_xml )
93
101
replace_tags . each do |tag |
94
102
xccdf_xml = xccdf_xml . gsub ( /(<|<)#{ tag } (>|>)/ , "$#{ tag } " )
@@ -133,8 +141,9 @@ def insert_controls
133
141
control [ 'tags' ] [ 'rid' ] = group . rule . id
134
142
control [ 'tags' ] [ 'stig_id' ] = group . rule . version
135
143
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' ] )
138
147
control [ 'tags' ] [ 'false_negatives' ] = group . rule . description . false_negatives if group . rule . description . false_negatives != ''
139
148
control [ 'tags' ] [ 'false_positives' ] = group . rule . description . false_positives if group . rule . description . false_positives != ''
140
149
control [ 'tags' ] [ 'documentable' ] = group . rule . description . documentable if group . rule . description . documentable != ''
0 commit comments