28
28
29
29
import logging # Logger for debug/info/error messages
30
30
import re
31
+ from pprint import pprint
31
32
logger = logging .getLogger ("openscap" )
32
33
33
34
from sys import version_info
@@ -272,9 +273,10 @@ def __getattr__(self, name):
272
273
return self .__func_wrapper (obj )
273
274
274
275
""" 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 ?
276
277
"""
277
- return OSCAP_Object (self .object + "_" + name )
278
+ raise AttributeError ("Attribute {0} not found for object {1}"
279
+ .format (name , self .object ))
278
280
279
281
def __dir__ (self ):
280
282
"""Lists all attributes inside this object.
@@ -412,6 +414,7 @@ def query_objects(self):
412
414
413
415
def get_all_values (self ):
414
416
417
+ # first ensure that we are using an item (or convert to it otherwise)
415
418
if self .object != "xccdf_item" :
416
419
item = self .to_item ()
417
420
if item is None :
@@ -520,8 +523,8 @@ def __parse_value(self, value):
520
523
if self .profile is not None :
521
524
for r_value in self .profile .refine_values :
522
525
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 ) )
525
528
for s_value in self .profile .setvalues :
526
529
if s_value .item == value .id :
527
530
item ["selected" ] = ('' , s_value .value )
@@ -749,14 +752,16 @@ def init(self, path, paths={}):
749
752
f_XCCDF = path
750
753
751
754
benchmark = self .benchmark_import (f_XCCDF )
755
+
752
756
if benchmark .instance is None :
753
757
if OSCAP .oscap_err ():
754
758
desc = OSCAP .oscap_err_desc ()
755
759
else :
756
760
desc = "Unknown error, please report this bug (http://bugzilla.redhat.com/)"
757
761
raise ImportError (
758
762
"Benchmark \" %s\" loading failed: %s" % (f_XCCDF , desc ))
759
- policy_model = self .policy_model (benchmark )
763
+
764
+ policy_model = self .policy_model_new (benchmark )
760
765
files = policy_model .get_files ()
761
766
def_models = []
762
767
sessions = {}
@@ -767,7 +772,8 @@ def init(self, path, paths={}):
767
772
else :
768
773
f_OVAL = os .path .join (dirname , file )
769
774
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 ))
771
777
if def_model .instance is None :
772
778
if OSCAP .oscap_err ():
773
779
desc = OSCAP .oscap_err_desc ()
0 commit comments