RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1753603 - openscap_api.xccdf.benchmark_import benchmark.get_results() fails on RHEL8
Summary: openscap_api.xccdf.benchmark_import benchmark.get_results() fails on RHEL8
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: openscap
Version: 8.4
Hardware: x86_64
OS: Linux
medium
high
Target Milestone: rc
: 8.2
Assignee: Watson Yuuma Sato
QA Contact: Vojtech Polasek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-09-19 11:56 UTC by amitkuma
Modified: 2020-11-14 04:36 UTC (History)
6 users (show)

Fixed In Version: openscap-1.3.2-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 15:40:54 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:1629 0 None None None 2020-04-28 15:41:06 UTC

Description amitkuma 2019-09-19 11:56:50 UTC
Description of problem:
On RHEL-8
# yum install openscap openscap-python3 scap-security-guide
# 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)))

# 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

# 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>


***************My thoughts***********************
1. It looks code is trying to retrieve value from Dictionary OSCAP for this key 
(wig Object of type 'struct xccdf_result_iterator *' at 0x7f7d310cb030>_has_more_new) and Dictionary does not have any key present.

        # It's maybe looking for "new" ?
        obj = OSCAP.__dict__.get(self.object+"_new") <<<<<<<<<
        if obj != None:
            return OSCAP_Object.new(obj(*newargs))

2. _openscap_py module is imported as shared Object.
# ls -ltr /usr/lib64/python3.6/site-packages/_openscap_py.so
-rwxr-xr-x. 1 root root 1672096 Jun 14 05:00 /usr/lib64/python3.6/site-packages/_openscap_py.so
    def _import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_openscap_py', [dirname(__file__)])
        except ImportError:

When I see OSCAP.__dict__ it does not contain object address rather it contains function names and built in types.
How it this dictionary created?
********************************************

Version-Release number of selected component (if applicable):
# rpm -qa|grep openscap
openscap-1.3.1-1.el8.x86_64
openscap-python3-1.3.1-1.el8.x86_64


How reproducible:
Always

Steps to Reproduce:
1. Mentioned above
2.
3.

Actual results:
get_results() API fails

Expected results:
get_results() API should not fail

Additional info:
same script does not throw exception on RHEL-7

Comment 1 Matěj Týč 2019-10-04 11:33:00 UTC
https://github.com/OpenSCAP/openscap/pull/1402

Comment 3 Jan Černý 2020-01-13 15:27:10 UTC
The upstream test is located in tests/bindings/python/benchmark_import_results.py

Comment 8 errata-xmlrpc 2020-04-28 15:40:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1629


Note You need to log in before you can comment on or make changes to this bug.