File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,19 @@ def description
2626 def rationale
2727 @rationale ||= @rule_xml . at_css ( 'rationale' ) . children . text . delete ( "\n " )
2828 end
29+
30+ def references
31+ @references ||= @rule_xml . css ( 'reference' ) . map do |node |
32+ { href : node [ 'href' ] , label : node . text }
33+ end
34+ end
35+
36+ def identifier
37+ @identifier ||= {
38+ label : @rule_xml . at_css ( 'ident' ) &.text ,
39+ system : ( ident = @rule_xml . at_css ( 'ident' ) ) && ident [ 'system' ]
40+ }
41+ end
2942 end
3043end
3144
Original file line number Diff line number Diff line change @@ -53,5 +53,21 @@ def setup
5353 should 'list all rules' do
5454 assert_empty ( @arbitrary_rules - @report_parser . rule_ids )
5555 end
56+
57+ should 'parse rule references' do
58+ rule = @report_parser . rule_objects . find do |r |
59+ r . title == 'Disable At Service (atd)'
60+ end
61+
62+ references = [
63+ { :href => "http://iase.disa.mil/stigs/cci/Pages/index.aspx" ,
64+ :label => "CCI-000381" } ,
65+ { :href => 'http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.' \
66+ '800-53r4.pdf' ,
67+ :label => "CM-7" }
68+ ]
69+
70+ assert_equal references , rule . references
71+ end
5672 end
5773end
Original file line number Diff line number Diff line change 11$LOAD_PATH. unshift File . expand_path ( "../../lib" , __FILE__ )
22require "openscap_parser"
3+ require 'pathname'
34
45require "minitest/autorun"
56require 'shoulda-context'
You can’t perform that action at this time.
0 commit comments