Skip to content

Commit dda6b56

Browse files
[bugfixes] related to oscap-1.2 => 1.3 and python2.7 legacy
1 parent 06ec6b7 commit dda6b56

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

swig/openscap_api.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import logging # Logger for debug/info/error messages
3030
import re
31+
from pprint import pprint
3132
logger = logging.getLogger("openscap")
3233

3334
from sys import version_info
@@ -272,9 +273,10 @@ def __getattr__(self, name):
272273
return self.__func_wrapper(obj)
273274

274275
""" There is not function with the name 'name' let return the OSCAP_Object
275-
This should return None, why is this here ? TODO
276+
This should return None, why is this here ?
276277
"""
277-
return OSCAP_Object(self.object + "_" + name)
278+
raise AttributeError("Attribute {0} not found for object {1}"
279+
.format(name, self.object))
278280

279281
def __dir__(self):
280282
"""Lists all attributes inside this object.
@@ -412,6 +414,7 @@ def query_objects(self):
412414

413415
def get_all_values(self):
414416

417+
# first ensure that we are using an item (or convert to it otherwise)
415418
if self.object != "xccdf_item":
416419
item = self.to_item()
417420
if item is None:
@@ -520,8 +523,8 @@ def __parse_value(self, value):
520523
if self.profile is not None:
521524
for r_value in self.profile.refine_values:
522525
if r_value.item == value.id:
523-
item["selected"] = (
524-
r_value.selector, item["options"][r_value.selector])
526+
item["selected"] = ( # will return None if invalid selector TODO: raise err ?
527+
r_value.selector, item["options"].get(r_value.selector))
525528
for s_value in self.profile.setvalues:
526529
if s_value.item == value.id:
527530
item["selected"] = ('', s_value.value)
@@ -749,14 +752,16 @@ def init(self, path, paths={}):
749752
f_XCCDF = path
750753

751754
benchmark = self.benchmark_import(f_XCCDF)
755+
752756
if benchmark.instance is None:
753757
if OSCAP.oscap_err():
754758
desc = OSCAP.oscap_err_desc()
755759
else:
756760
desc = "Unknown error, please report this bug (http://bugzilla.redhat.com/)"
757761
raise ImportError(
758762
"Benchmark \"%s\" loading failed: %s" % (f_XCCDF, desc))
759-
policy_model = self.policy_model(benchmark)
763+
764+
policy_model = self.policy_model_new(benchmark)
760765
files = policy_model.get_files()
761766
def_models = []
762767
sessions = {}
@@ -767,7 +772,8 @@ def init(self, path, paths={}):
767772
else:
768773
f_OVAL = os.path.join(dirname, file)
769774
if os.path.exists(f_OVAL):
770-
def_model = oval.definition_model_import(f_OVAL)
775+
def_model = oval.definition_model_import_source(
776+
OSCAP.oscap_source_new_from_file(f_OVAL))
771777
if def_model.instance is None:
772778
if OSCAP.oscap_err():
773779
desc = OSCAP.oscap_err_desc()

0 commit comments

Comments
 (0)