| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
from import_handler import oscap |
| 17 |
from pprint import pprint |
| 18 |
|
| 19 |
oval_funcs = oscap.oval.introspect_functions() |
| 20 |
|
| 21 |
if oval_funcs.get('oval_variable_get_values') is None: |
| 22 |
raise Exception("method 'oval_variable_get_values' not found in builtins" |
| 23 |
"functions of oval object (should be in oscap.oval.introspect_functions())") |
| 24 |
|
| 25 |
if oval_funcs.get('xccdf_check_get_id') is not None: |
| 26 |
raise Exception("method 'xccdf_check_get_id' should not be found in " |
| 27 |
"oscap.oval.introspect_functions(), because the prefix isn't 'oval')") |
| 28 |
|
| 29 |
if oscap.oval.introspect_all().get('xccdf_check_get_id') is None: |
| 30 |
raise Exception("method 'xccdf_check_get_id' should be present in " |
| 31 |
"oscap.oval.introspect_all(), which returns all available builtins functions") |
| 32 |
|
| 33 |
print("Introspection of builtins functions seems working.") |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
pass_val = oscap.oval.XCCDF_RESULT_PASS |
| 39 |
|
| 40 |
var1 = oscap.oval.introspect_constants(pass_val, "XCCDF_RESULT") |
| 41 |
if len(var1) == 1 and list(var1.keys())[0] == "XCCDF_RESULT_PASS": |
| 42 |
print("Introspection of oscap.oval.XCCDF_RESULT_PASS ok") |
| 43 |
|
| 44 |
|
| 45 |
xccdf_results = oscap.oval.introspect_constants(None, "XCCDF_RESULT") |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
expected_constants = ('XCCDF_RESULT_ERROR', 'XCCDF_RESULT_FAIL', 'XCCDF_RESULT_FIXED', |
| 58 |
'XCCDF_RESULT_INFORMATIONAL', 'XCCDF_RESULT_NOT_APPLICABLE', |
| 59 |
'XCCDF_RESULT_NOT_CHECKED', 'XCCDF_RESULT_PASS', |
| 60 |
'XCCDF_RESULT_NOT_SELECTED', 'XCCDF_RESULT_UNKNOWN') |
| 61 |
|
| 62 |
for c in expected_constants: |
| 63 |
if c not in xccdf_results: |
| 64 |
raise Exception("oscap.oval.introspect_constants(None, 'XCCDF_RESULT) should" |
| 65 |
"contains the constant {0}.".format(c)) |
| 66 |
|
| 67 |
print("Introspection of constants ok with prefix XCCDF_RESULT_*") |