File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ #
2+ # Copyright (c) 2015--2016 Red Hat Inc.
3+ #
4+ # This software is licensed to you under the GNU General Public License,
5+ # version 2 (GPLv2). There is NO WARRANTY for this software, express or
6+ # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7+ # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
8+ # along with this software; if not, see
9+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
10+ #
11+
12+ module OpenSCAP
13+ module Xccdf
14+ class Ident
15+ def initialize ( raw )
16+ raise OpenSCAP ::OpenSCAPError , "Cannot initialize #{ self . class . name } with '#{ raw } '" \
17+ unless raw . is_a? ( FFI ::Pointer )
18+ @raw = raw
19+ end
20+
21+ def system
22+ OpenSCAP . xccdf_ident_get_system ( @raw )
23+ end
24+
25+ def id
26+ OpenSCAP . xccdf_ident_get_id ( @raw )
27+ end
28+
29+
30+ end
31+ end
32+ attach_function :xccdf_ident_get_system , [ :pointer ] , :string
33+ attach_function :xccdf_ident_get_id , [ :pointer ] , :string
34+ end
35+
36+
37+
Original file line number Diff line number Diff line change @@ -64,6 +64,17 @@ def rationale(prefered_lang = nil)
6464 rationale
6565 end
6666
67+ def idents
68+ idenss = [ ]
69+ idenss_it = OpenSCAP . xccdf_rule_get_idents ( @raw )
70+ while OpenSCAP . xccdf_ident_iterator_has_more idenss_it
71+ idens = OpenSCAP ::Xccdf ::Ident . new ( OpenSCAP . xccdf_ident_iterator_next ( idenss_it ) )
72+ idenss << idens
73+ end
74+ OpenSCAP . xccdf_ident_iterator_free idenss_it
75+ idenss
76+ end
77+
6778 def references
6879 refs = [ ]
6980 refs_it = OpenSCAP . xccdf_item_get_references ( @raw )
@@ -124,4 +135,9 @@ def sub_items_init
124135 attach_function :oscap_reference_iterator_has_more , [ :pointer ] , :bool
125136 attach_function :oscap_reference_iterator_next , [ :pointer ] , :pointer
126137 attach_function :oscap_reference_iterator_free , [ :pointer ] , :void
138+
139+ attach_function :xccdf_rule_get_idents , [ :pointer ] , :pointer
140+ attach_function :xccdf_ident_iterator_has_more , [ :pointer ] , :bool
141+ attach_function :xccdf_ident_iterator_next , [ :pointer ] , :pointer
142+ attach_function :xccdf_ident_iterator_free , [ :pointer ] , :void
127143end
You can’t perform that action at this time.
0 commit comments