Debian Codegraph @

tests/API/XCCDF/unittests/test_xccdf_overrides.c

raw symbols SCIP
1 /*
2 * Copyright 2014 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Simon Lukasik <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28
29 #include <ds_rds_session.h>
30 #include <oscap_source.h>
31 #include <xccdf_benchmark.h>
32 #include <xccdf_policy.h>
33
34 #include "oscap_assert.h"
35 #include "unit_helper.h"
36
37 int main(int argc, char *argv[])
38 {
39 oscap_assert(argc == 2);
40 struct oscap_source *rds_source = oscap_source_new_from_file(argv[1]);
41 struct ds_rds_session *rds = ds_rds_session_new_from_source(rds_source);
42 oscap_assert(rds != NULL);
43 struct oscap_source *tr_source = ds_rds_session_select_report(rds, NULL);
44 oscap_assert(tr_source != NULL);
45 struct xccdf_result *tr = xccdf_result_import_source(tr_source);
46 oscap_assert(tr != NULL);
47 struct xccdf_rule_result *rr = xccdf_result_get_rule_result_by_id(tr, "x");
48 oscap_assert(rr == NULL);
49 rr = xccdf_result_get_rule_result_by_id(tr, "xccdf_org.ssgproject.content_rule_disable_prelink");
50 oscap_assert(rr != NULL);
51 struct oscap_text* waiver = oscap_text_new();
52 oscap_text_set_text(waiver, "I believe this should have passed");
53 oscap_assert(xccdf_rule_result_override(rr, XCCDF_RESULT_PASS, "yesterday", "intern contractor", waiver));
54 tr_source = xccdf_result_export_source(tr, NULL);
55 oscap_assert(tr_source != NULL);
56
57 // modifies the dom
58 oscap_assert(ds_rds_session_replace_report_with_source(rds, tr_source) == 0);
59 // saves the modified dom
60 oscap_assert(oscap_source_save_as(rds_source, "test_xccdf_overrides.xml.out") == 0);
61
62 xccdf_result_free(tr);
63 ds_rds_session_free(rds);
64 oscap_source_free(rds_source);
65 return 0;
66 }
67