Skip to content

Commit 681ced2

Browse files
committed
Introduce OpenSCAP::Xccdf::Policy
1 parent f96eb78 commit 681ced2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/openscap/xccdf/policy.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (c) 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+
require 'openscap/exceptions'
13+
14+
module OpenSCAP
15+
module Xccdf
16+
class Policy
17+
def initialize(p)
18+
case p
19+
when FFI::Pointer
20+
@raw = p
21+
else
22+
fail OpenSCAP::OpenSCAPError,
23+
"Cannot initialize OpenSCAP::Xccdf::Policy with '#{p}'"
24+
end
25+
OpenSCAP.raise! if @raw.null?
26+
end
27+
28+
def id
29+
OpenSCAP.xccdf_policy_get_id raw
30+
end
31+
end
32+
end
33+
34+
attach_function :xccdf_policy_get_id, [:pointer], :string
35+
end

0 commit comments

Comments
 (0)