Bug 599093 - XCCDF: xccdf_fix_get_content does not return dereferenced sub element
XCCDF: xccdf_fix_get_content does not return dereferenced sub element
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: openscap (Show other bugs)
14
All Linux
low Severity medium
: ---
: ---
Assigned To: Lukas Kuklinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-02 13:00 EDT by Ed Sealing
Modified: 2011-03-21 23:47 EDT (History)
3 users (show)

See Also:
Fixed In Version: openscap-0.7.1-1.fc15
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-03-21 16:55:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ed Sealing 2010-06-02 13:00:13 EDT
Description of problem:
The <fix> element within an XCCDF Rule allows for a <sub /> element for referencing values. In openscap, the xccdf_fix_get_content() function uses a MACRO to define this function. This fails to dereference the <sub /> element.

When using xccdf_fix_get_content(), it will only return a string up-to the <sub/> element, and nothing else.

This problem will also occur in the associated clone function.

Version-Release number of selected component (if applicable):
ALL

How reproducible:


Steps to Reproduce:
1.
2.
3.
 
Actual results:


Expected results:
Dereference the <sub/> element and return the string + any referenced values.

Additional info:
Comment 1 Lukas Kuklinek 2010-06-14 10:55:49 EDT
The problem is that the model itself (i.e. xccdf_benchmark and its sub-structures) represents a static in-memory representation of a XCCDF document. If <sub/> element points to a XCCDF Value element, its true value (i.e. text to be substituted) depends on selector being set on the value, which in turn depends on selected XCCDF Profile, so it is intentional that the text returns verbatim 'unexpanded' piece of XML.

Note: You may have noticed that xccdf_value maintains an "active selector". This pseudofeature kind of breaks stateless-ness and purity of the data model and will be removed soon (patches are already on the way).

View at a model with respect to a profile is called xccdf_policy in OpenScap terminology. Therefore, expanding <sub/> elements should be done on the policy level of the API.

So there are actually two separate issues:
1. xccdf_fix_get_content should return full contents of the element, it shouldn't stop at the first <sub/> element. This is a bug.
2. xccdf_policy is not able to substitute <sub/> elements. This is a missing feature.

Proposed solution:
1. Fix issue #1 (I'll do it. :))
2. Implement feature #2, function could look like this:
char *xccdf_expand(xccdf_policy *policy, const char *input);
It returns a newly allocated string with all <sub/> elements in input being substituted with proper values with respect to given policy (i.e. roughly a xccdf profile).
Example usage:
char *fix_content = xccdf_expand(my_policy, xccdf_fix_get_content(my_fix));
Comment 2 Bug Zapper 2010-07-30 07:47:21 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Lukas Kuklinek 2011-03-01 10:34:29 EST
This issue has been resolved by commits 970f353d32 and fd3c41a1277 by adding following function:

char* xccdf_policy_substitute(const char *text, struct xccdf_policy *policy);

Which would return a string 'text' with substitutions being replaced with actual values with respect to given XCCDF policy.
Comment 4 Peter Vrabec 2011-03-08 09:37:58 EST
these changes will be available in new openscap release 0.7.1 which is planned for this week.
Comment 5 Fedora Update System 2011-03-11 11:01:23 EST
openscap-0.7.1-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/openscap-0.7.1-1.fc15
Comment 6 Fedora Update System 2011-03-11 11:02:43 EST
openscap-0.7.1-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/openscap-0.7.1-1.fc14
Comment 7 Fedora Update System 2011-03-21 16:55:50 EDT
openscap-0.7.1-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 8 Fedora Update System 2011-03-21 23:46:56 EDT
openscap-0.7.1-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

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