Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_html_guide returns NULL since 1.2.11 #744

Closed
evgeni opened this issue May 19, 2017 · 8 comments
Closed

get_html_guide returns NULL since 1.2.11 #744

evgeni opened this issue May 19, 2017 · 8 comments

Comments

@evgeni
Copy link
Contributor

evgeni commented May 19, 2017

Ohai,

given the following code, all releases until 1.2.10 would print me some HTML guide:

#include <stdio.h>
#include <oscap.h>
#include <oscap_source.h>
#include <ds_sds_session.h>
#include <oscap_debug.h>
#include <oscap_error.h>

int main() {
	oscap_init();
	oscap_set_verbose("DEBUG", NULL, false);
	struct oscap_source * source = oscap_source_new_from_file("/tmp/smart_proxy_openscap/test/data/ssg-rhel7-ds.xml");
	struct ds_sds_session * sds = ds_sds_session_new_from_source(source);
	struct oscap_source * source2 = ds_sds_session_select_checklist(sds, NULL, NULL, NULL);
	char * html = ds_sds_session_get_html_guide(sds, "xccdf_org.ssgproject.content_profile_rht-ccp");
	printf("%s", html);
	if (html == NULL) {
		char * error = oscap_err_get_full_error();
		printf("%s", error);
	}
	return 0;
}

However, starting with 1.2.11, I just get NULL.
The file I am using is this one: https://github.com/theforeman/smart_proxy_openscap/blob/master/test/data/ssg-rhel7-ds.xml

Now I wonder, is the code wrong, or is that a bug in OpenSCAP?

@mpreisler
Copy link
Member

mpreisler commented May 19, 2017

Could you please include <oscap_debug.h> and use:

oscap_set_verbose("DEBUG", NULL, false);

?

Let's see if openscap tells us what's wrong.

EDIT: call oscap_set_verbose after oscap_init().

@evgeni
Copy link
Contributor Author

evgeni commented May 19, 2017

There seems to be no additional output after calling that.

@evgeni
Copy link
Contributor Author

evgeni commented May 19, 2017

OK, for added fun: I wanted to try to bisect that, and fetched OpenSCAP from git. But even with 1.2.9 and 1.2.10 from git I get NULL back.
The previous observation about the breakage between 1.2.10 and 1.2.11 was based on the Fedora 25 packages.

reading oscap_err_get_full_error helps, I had the prefix wrongly set up.

@evgeni
Copy link
Contributor Author

evgeni commented May 19, 2017

So with the error code in place, I get the following output on bad versions:

Internal error: Could not acquire handle to xccdf.xml source. [ds_sds_session.c:313]

and now really bisecting, says that the following is the first bad commit:

commit b8defed4fdea58a1ae6b88ef11b20d56c499cd80
Author: Jan Černý <jcerny@redhat.com>
Date:   Thu Sep 22 12:42:40 2016 +0200

    Support tailoring of a checklist located in a different datstream
    
    This commit fixes processing of tailoring within datastreams.
    It is now possible to have a datastream collection with multiple datastreams,
    where XCCDF tailoring and XCCDF checklist are not both in the same datastream.

@evgeni
Copy link
Contributor Author

evgeni commented May 19, 2017

Confirmed, reverting b8defed on top of current maint-1.2 makes my code work again.

@mpreisler
Copy link
Member

@jan-cerny Could you provide any insight into this? It's probably because components are no longer registered using a hardcoded ID but using their checklist id.

@mpreisler
Copy link
Member

This seems like a real bug. See https://github.com/OpenSCAP/openscap/blob/maint-1.2/src/DS/ds_sds_session.c#L355

It still uses the hardcoded ID even though we no longer register under it. b8defed causes a regression.

@evgeni
Copy link
Contributor Author

evgeni commented May 19, 2017

Indeed, the following patch fixes it for me:

diff --git a/src/DS/ds_sds_session.c b/src/DS/ds_sds_session.c
index db7692a..9f57ae2 100644
--- a/src/DS/ds_sds_session.c
+++ b/src/DS/ds_sds_session.c
@@ -352,7 +352,7 @@ char *ds_sds_session_get_html_guide(struct ds_sds_session *session, const char *
                "profile_id", profile_id,
                NULL
        };
-       struct oscap_source *xccdf = oscap_htable_get(session->component_sources, "xccdf.xml");
+       struct oscap_source *xccdf = oscap_htable_get(session->component_sources, session->checklist_id);
        if (xccdf == NULL) {
                oscap_seterr(OSCAP_EFAMILY_OSCAP, "Internal error: Could not acquire handle to xccdf.xml source.");
                return NULL;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants