openscap_api.xccdf.benchmark_import benchmark.get_results() crash at NameError on RHEL 8

Solution Verified - Updated -

Issue

  • Whenever a user is trying to interpret oscap evaluated system results crash happens openscap_api.py.
  • These are steps to reproduce on RHEL-8 system.
    1] Install openscap and related packages.
# yum install openscap openscap-python3 scap-security-guide

2] Create a python file to interpret the scan results.

# vim /root/get_results.py
import openscap_api

benchmark = openscap_api.xccdf.benchmark_import("/tmp/scap-results.xml")

# Print the ID to show that simple characters work
print("Title is: {0}".format(benchmark.get_id()))

# Print the results array to show that arrays also work and show the number of items to show that this is a python array
results = benchmark.get_results()
print(results)
print("Number of items: {0}".format(len(results)))

3] Scan the system using oscap.

# oscap xccdf eval --results /tmp/scap-results.xml --profile xccdf_org.ssgproject.content_profile_ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

4] Interpret the results using script earlier and see the Exception.

# python3 get_results.py
Title is: xccdf_org.ssgproject.content_benchmark_RHEL-8
Traceback (most recent call last):
  File "get_results.py", line 17, in <module>
    results = benchmark.get_results()
  File "/usr/lib64/python3.6/site-packages/openscap_api.py", line 196, in __getter_wrapper
    list.generate(OSCAP_Object.new(retobj))
  File "/usr/lib64/python3.6/site-packages/openscap_api.py", line 89, in generate
    while iterator.has_more():
  File "/usr/lib64/python3.6/site-packages/openscap_api.py", line 277, in __call__
    raise NameError("name '"+self.object+"' is not defined")
NameError: name 'wig Object of type 'struct xccdf_result_iterator *' at 0x7f7f7dc20090>_has_more' is not defined
Exception ignored in: <bound method OSCAP_List.__del__ of []>
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/openscap_api.py", line 81, in __del__
    self.iterator.free()
  File "/usr/lib64/python3.6/site-packages/openscap_api.py", line 314, in free
    raise Exception("Can't free %s" % (self.object,))
Exception: Can't free wig Object of type 'struct xccdf_result_iterator *' at 0x7f7f7dc20090>

Environment

  • Red Hat Enterprise Linux 8.X

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content