Open SCAP Library: xccdf_session.h Source File

Open SCAP Library

xccdf_session.h
Go to the documentation of this file.
1
12 /*
13 * Copyright 2013 Red Hat Inc., Durham, North Carolina.
14 * All Rights Reserved.
15 *
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 */
31
32 #ifndef XCCDF_SESSION_H_
33 #define XCCDF_SESSION_H_
34
35 #include "xccdf_policy.h"
36 #include "oscap_download_cb.h"
37
42 struct xccdf_session;
43
49 typedef enum {
50 XCCDF_SESSION_LOAD_NONE = 0,
51 XCCDF_SESSION_LOAD_XCCDF = 1 << 0,
52 XCCDF_SESSION_LOAD_CPE = 1 << 1,
53 XCCDF_SESSION_LOAD_OVAL = 1 << 2,
54 XCCDF_SESSION_LOAD_CHECK_ENGINE_PLUGINS = 1 << 3,
55 XCCDF_SESSION_LOAD_ALL = XCCDF_SESSION_LOAD_XCCDF | XCCDF_SESSION_LOAD_CPE | XCCDF_SESSION_LOAD_OVAL | XCCDF_SESSION_LOAD_CHECK_ENGINE_PLUGINS
56 } xccdf_session_loading_flags_t;
57
65 struct xccdf_session *xccdf_session_new(const char *filename);
66
74 struct xccdf_session *xccdf_session_new_from_source(struct oscap_source *source);
75
81 void xccdf_session_free(struct xccdf_session *session);
82
87 const char *xccdf_session_get_filename(const struct xccdf_session *session);
88
95 bool xccdf_session_is_sds(const struct xccdf_session *session);
96
104 void xccdf_session_set_rule(struct xccdf_session *session, const char *rule);
105
116 void xccdf_session_set_validation(struct xccdf_session *session, bool validate, bool full_validation);
117
126 void xccdf_session_set_thin_results(struct xccdf_session *session, bool thin_result);
127
136 void xccdf_session_set_datastream_id(struct xccdf_session *session, const char *datastream_id);
137
143 const char *xccdf_session_get_datastream_id(struct xccdf_session *session);
144
153 void xccdf_session_set_component_id(struct xccdf_session *session, const char *component_id);
154
160 const char *xccdf_session_get_component_id(struct xccdf_session *session);
161
168 void xccdf_session_set_benchmark_id(struct xccdf_session *session, const char *benchmark_id);
169
175 const char *xccdf_session_get_benchmark_id(struct xccdf_session *session);
176
181 const char *xccdf_session_get_result_id(struct xccdf_session *session);
182
190 void xccdf_session_set_user_cpe(struct xccdf_session *session, const char *user_cpe);
191
199 void xccdf_session_set_user_tailoring_file(struct xccdf_session *session, const char *user_tailoring_file);
200
208 void xccdf_session_set_user_tailoring_cid(struct xccdf_session *session, const char *user_tailoring_cid);
209
218 void xccdf_session_set_remote_resources(struct xccdf_session *session, bool allowed, download_progress_calllback_t callback);
219
226 void xccdf_session_set_loading_flags(struct xccdf_session *session, xccdf_session_loading_flags_t flags);
227
236 void xccdf_session_set_custom_oval_files(struct xccdf_session *session, char **oval_filenames);
237
245 void xccdf_session_set_custom_oval_eval_fn(struct xccdf_session *session, xccdf_policy_engine_eval_fn eval_fn);
246
254 bool xccdf_session_set_product_cpe(struct xccdf_session *session, const char *product_cpe);
255
262 void xccdf_session_set_without_sys_chars_export(struct xccdf_session *session, bool without_sys_chars);
263
270 void xccdf_session_set_oval_results_export(struct xccdf_session *session, bool to_export_oval_results);
271
278 void xccdf_session_set_check_engine_plugins_results_export(struct xccdf_session *session, bool to_export_results);
279
286 OSCAP_DEPRECATED(void xccdf_session_set_sce_results_export(struct xccdf_session *session, bool to_export_sce_results));
287
294 void xccdf_session_set_oval_variables_export(struct xccdf_session *session, bool to_export_oval_variables);
295
303 bool xccdf_session_set_xccdf_export(struct xccdf_session *session, const char *xccdf_file);
304
312 bool xccdf_session_set_xccdf_stig_viewer_export(struct xccdf_session *session, const char *xccdf_stig_viewer_file);
313
321 bool xccdf_session_set_arf_export(struct xccdf_session *session, const char *arf_file);
322
330 bool xccdf_session_set_report_export(struct xccdf_session *session, const char *report_file);
331
339 bool xccdf_session_set_profile_id(struct xccdf_session *session, const char *profile_id);
340
349 int xccdf_session_set_profile_id_by_suffix(struct xccdf_session *session, const char *profile_suffix);
350
356 const char *xccdf_session_get_profile_id(struct xccdf_session *session);
357
365 struct ds_sds_index *xccdf_session_get_sds_idx(struct xccdf_session *session);
366
374 int xccdf_session_load(struct xccdf_session *session);
375
388 int xccdf_session_load_xccdf(struct xccdf_session *session);
389
397 int xccdf_session_load_cpe(struct xccdf_session *session);
398
405 int xccdf_session_load_oval(struct xccdf_session *session);
406
421 int xccdf_session_load_check_engine_plugin2(struct xccdf_session *session, const char* plugin_name, bool quiet);
422 int xccdf_session_load_check_engine_plugin(struct xccdf_session *session, const char* plugin_name);
423
434 int xccdf_session_load_check_engine_plugins(struct xccdf_session *session);
435
441 OSCAP_DEPRECATED(int xccdf_session_load_sce(struct xccdf_session *session));
442
449 int xccdf_session_load_tailoring(struct xccdf_session *session);
450
457 int xccdf_session_evaluate(struct xccdf_session *session);
458
465 int xccdf_session_export_xccdf(struct xccdf_session *session);
466
473 int xccdf_session_export_oval(struct xccdf_session *session);
474
483 int xccdf_session_export_check_engine_plugins(struct xccdf_session *session);
484
493 OSCAP_DEPRECATED(int xccdf_session_export_sce(struct xccdf_session *session));
494
501 int xccdf_session_export_arf(struct xccdf_session *session);
502
510 struct xccdf_policy_model *xccdf_session_get_policy_model(const struct xccdf_session *session);
511
518 struct xccdf_policy *xccdf_session_get_xccdf_policy(const struct xccdf_session *session);
519
526 float xccdf_session_get_base_score(const struct xccdf_session *session);
527
534 unsigned int xccdf_session_get_oval_agents_count(const struct xccdf_session *session);
535
544 unsigned int xccdf_session_get_cpe_oval_agents_count(const struct xccdf_session *session);
545
552 bool xccdf_session_contains_fail_result(const struct xccdf_session *session);
553
562 int xccdf_session_remediate(struct xccdf_session *session);
563
574 int xccdf_session_build_policy_from_testresult(struct xccdf_session *session, const char *testresult_id);
575
583 int xccdf_session_add_report_from_source(struct xccdf_session *session, struct oscap_source *report_source);
584
587 #endif
xccdf_session::xccdf_session_set_custom_oval_eval_fn
void xccdf_session_set_custom_oval_eval_fn(struct xccdf_session *session, xccdf_policy_engine_eval_fn eval_fn)
Set custom OVAL eval function to register with each OVAL session.
Definition: xccdf_session.c:368
xccdf_session_load_sce
int xccdf_session_load_sce(struct xccdf_session *session)
Definition: xccdf_session.c:1134
xccdf_session::xccdf_session_free
void xccdf_session_free(struct xccdf_session *session)
Destructor of xccdf_session.
Definition: xccdf_session.c:244
xccdf_session::xccdf_session_set_xccdf_stig_viewer_export
bool xccdf_session_set_xccdf_stig_viewer_export(struct xccdf_session *session, const char *xccdf_stig_viewer_file)
Set where to export STIG Viewer XCCDF file.
Definition: xccdf_session.c:419
xccdf_session::xccdf_session_load_tailoring
int xccdf_session_load_tailoring(struct xccdf_session *session)
Load Tailoring file (if applicable) to the XCCDF session.
Definition: xccdf_session.c:1139
xccdf_session::xccdf_session_is_sds
bool xccdf_session_is_sds(const struct xccdf_session *session)
Query if the session is based on Source DataStream.
Definition: xccdf_session.c:284
xccdf_session
A structure encapsulating the context of XCCDF operations.
Definition: xccdf_session.c:65
xccdf_session::xccdf_session_set_datastream_id
void xccdf_session_set_datastream_id(struct xccdf_session *session, const char *datastream_id)
Set requested datastream_id for this session.
Definition: xccdf_session.c:305
xccdf_session::xccdf_session_get_component_id
const char * xccdf_session_get_component_id(struct xccdf_session *session)
Retrieves the component id.
Definition: xccdf_session.c:325
xccdf_policy.h
Open-scap XCCDF Policy library interface.
xccdf_session::xccdf_session_get_base_score
float xccdf_session_get_base_score(const struct xccdf_session *session)
Get the base score of the latest XCCDF evaluation in the session.
xccdf_session::xccdf_session_set_rule
void xccdf_session_set_rule(struct xccdf_session *session, const char *rule)
Set rule for session - if rule is not NULL, session will use only this one rule.
Definition: xccdf_session.c:289
xccdf_session::xccdf_session_load_check_engine_plugin2
int xccdf_session_load_check_engine_plugin2(struct xccdf_session *session, const char *plugin_name, bool quiet)
Load extra check engine from a plugin of given name to the XCCDF session.
Definition: xccdf_session.c:1075
OSCAP_DEPRECATED
#define OSCAP_DEPRECATED(func)
This macro will warn, when a deprecated function is used.
Definition: oscap.h:50
xccdf_session::xccdf_stig_viewer_file
char * xccdf_stig_viewer_file
Path to STIG Viewer XCCDF file to export.
Definition: xccdf_session.c:100
xccdf_session::xccdf_session_load
int xccdf_session_load(struct xccdf_session *session)
Load and parse all XCCDF structures needed to evaluate this session.
Definition: xccdf_session.c:581
xccdf_session::profile_id
char * profile_id
Last selected profile.
Definition: xccdf_session.c:73
xccdf_session::xccdf_session_new_from_source
struct xccdf_session * xccdf_session_new_from_source(struct oscap_source *source)
Costructor of xccdf_session.
Definition: xccdf_session.c:128
xccdf_session::xccdf_session_export_check_engine_plugins
int xccdf_session_export_check_engine_plugins(struct xccdf_session *session)
Export results (if any) from any check engine plugins that are loaded.
Definition: xccdf_session.c:1584
xccdf_session::xccdf_file
char * xccdf_file
Path to XCCDF file to export.
Definition: xccdf_session.c:99
xccdf_session::xccdf_session_set_sce_results_export
void xccdf_session_set_sce_results_export(struct xccdf_session *session, bool to_export_sce_results)
Set that SCE reult files shall be exported.
Definition: xccdf_session.c:400
xccdf_policy_model
XCCDF policy model structure contains xccdf_benchmark as reference to Benchmark element in XML file a...
Definition: xccdf_policy_priv.h:39
xccdf_session::xccdf_session_set_profile_id_by_suffix
int xccdf_session_set_profile_id_by_suffix(struct xccdf_session *session, const char *profile_suffix)
Select XCCDF Profile for evaluation with only profile suffix as input.
Definition: xccdf_session.c:487
xccdf_session::xccdf_session_export_xccdf
int xccdf_session_export_xccdf(struct xccdf_session *session)
Export XCCDF file.
Definition: xccdf_session.c:1319
xccdf_session::report_file
char * report_file
Path to HTML file to eport.
Definition: xccdf_session.c:101
xccdf_session::xccdf_session_set_user_cpe
void xccdf_session_set_user_cpe(struct xccdf_session *session, const char *user_cpe)
Set path to custom CPE dictionary for the session.
Definition: xccdf_session.c:349
xccdf_session::xccdf_session_set_thin_results
void xccdf_session_set_thin_results(struct xccdf_session *session, bool thin_result)
Set whether the thin results override is enabled.
Definition: xccdf_session.c:300
xccdf_session::rule
const char * rule
Single-rule feature: if not NULL, the session will work only with this one rule.
Definition: xccdf_session.c:67
xccdf_session::xccdf_session_set_check_engine_plugins_results_export
void xccdf_session_set_check_engine_plugins_results_export(struct xccdf_session *session, bool to_export_results)
Set that check engine plugin&#39;s result files shall be exported.
Definition: xccdf_session.c:395
xccdf_session::xccdf_session_get_datastream_id
const char * xccdf_session_get_datastream_id(struct xccdf_session *session)
Retrieves the datastream id.
Definition: xccdf_session.c:311
xccdf_session::xccdf_session_set_profile_id
bool xccdf_session_set_profile_id(struct xccdf_session *session, const char *profile_id)
Select XCCDF Profile for evaluation.
Definition: xccdf_session.c:433
ds_sds_index
Represents <data-stream-collection> element - the root element of each source datastream.
Definition: sds_index.c:215
xccdf_session::xccdf_session_set_without_sys_chars_export
void xccdf_session_set_without_sys_chars_export(struct xccdf_session *session, bool without_sys_chars)
Set whether the System Characteristics shall be exported in result files.
Definition: xccdf_session.c:380
xccdf_session::xccdf_session_export_oval
int xccdf_session_export_oval(struct xccdf_session *session)
Export OVAL (result and variables) files.
Definition: xccdf_session.c:1531
xccdf_session::xccdf_session_get_result_id
const char * xccdf_session_get_result_id(struct xccdf_session *session)
Retrieves the result id.
Definition: xccdf_session.c:344
xccdf_session::xccdf_session_set_product_cpe
bool xccdf_session_set_product_cpe(struct xccdf_session *session, const char *product_cpe)
Set custom product CPE name.
Definition: xccdf_session.c:373
xccdf_session::user_cpe
char * user_cpe
Path to CPE dictionary required by user.
Definition: xccdf_session.c:108
xccdf_session::without_sys_chars
bool without_sys_chars
Shall system characteristics be exported?
Definition: xccdf_session.c:105
xccdf_session::xccdf_session_build_policy_from_testresult
int xccdf_session_build_policy_from_testresult(struct xccdf_session *session, const char *testresult_id)
Load xccdf:TestResult to the session from file and prepare session for remediation.
Definition: xccdf_session.c:1718
xccdf_session::xccdf_session_get_benchmark_id
const char * xccdf_session_get_benchmark_id(struct xccdf_session *session)
Retrieves the benchmark_id.
Definition: xccdf_session.c:339
xccdf_policy_engine_eval_fn
xccdf_test_result_type_t(* xccdf_policy_engine_eval_fn)(struct xccdf_policy *policy, const char *rule_id, const char *definition_id, const char *href_if, struct xccdf_value_binding_iterator *value_binding_it, struct xccdf_check_import_iterator *check_imports_it, void *user_data)
Type of function which implements OpenSCAP checking engine.
Definition: xccdf_policy.h:98
xccdf_session::xccdf_session_get_xccdf_policy
struct xccdf_policy * xccdf_session_get_xccdf_policy(const struct xccdf_session *session)
Get xccdf_policy of the session.
Definition: xccdf_session.c:1639
oscap_source
Definition: oscap_source.c:62
xccdf_session::xccdf_session_add_report_from_source
int xccdf_session_add_report_from_source(struct xccdf_session *session, struct oscap_source *report_source)
Load xccdf:TestResult to the session from oscap_source.
Definition: xccdf_session.c:1748
xccdf_session::xccdf_session_set_loading_flags
void xccdf_session_set_loading_flags(struct xccdf_session *session, xccdf_session_loading_flags_t flags)
Disable or allow loading of depending content (OVAL, SCE, CPE)
xccdf_session::xccdf_session_set_report_export
bool xccdf_session_set_report_export(struct xccdf_session *session, const char *report_file)
Set where to export HTML Report file.
Definition: xccdf_session.c:426
xccdf_session::xccdf_session_evaluate
int xccdf_session_evaluate(struct xccdf_session *session)
Evaluate XCCDF Policy.
Definition: xccdf_session.c:1188
xccdf_session::xccdf_session_get_policy_model
struct xccdf_policy_model * xccdf_session_get_policy_model(const struct xccdf_session *session)
Get policy_model of the session.
xccdf_session::xccdf_session_export_arf
int xccdf_session_export_arf(struct xccdf_session *session)
Export ARF (if enabled by xccdf_session_set_arf_export).
Definition: xccdf_session.c:1613
xccdf_session::xccdf_session_set_arf_export
bool xccdf_session_set_arf_export(struct xccdf_session *session, const char *arf_file)
Set where to export ARF file.
Definition: xccdf_session.c:405
xccdf_session::xccdf_session_load_oval
int xccdf_session_load_oval(struct xccdf_session *session)
Load and parse OVAL definitions files for the XCCDF session.
Definition: xccdf_session.c:995
xccdf_session::xccdf_session_set_user_tailoring_cid
void xccdf_session_set_user_tailoring_cid(struct xccdf_session *session, const char *user_tailoring_cid)
Set ID of Tailoring component for the session.
Definition: xccdf_session.c:362
xccdf_session::xccdf_session_load_check_engine_plugins
int xccdf_session_load_check_engine_plugins(struct xccdf_session *session)
Load extra check engines (if any are available) to the XCCDF session.
Definition: xccdf_session.c:1099
xccdf_session::xccdf_session_remediate
int xccdf_session_remediate(struct xccdf_session *session)
Run XCCDF Remediation.
Definition: xccdf_session.c:1692
xccdf_session::xccdf_session_set_custom_oval_files
void xccdf_session_set_custom_oval_files(struct xccdf_session *session, char **oval_filenames)
Set custom oval files for this session.
Definition: xccdf_session.c:851
xccdf_session::filename
const char * filename
File name of SCAP (SDS or XCCDF) file for this session.
Definition: xccdf_session.c:66
xccdf_session::xccdf_session_set_component_id
void xccdf_session_set_component_id(struct xccdf_session *session, const char *component_id)
Set requested component_id for this session.
Definition: xccdf_session.c:319
xccdf_session::xccdf_session_set_validation
void xccdf_session_set_validation(struct xccdf_session *session, bool validate, bool full_validation)
Set XSD validation level to one of three possibilities:
Definition: xccdf_session.c:294
xccdf_session::xccdf_session_load_cpe
int xccdf_session_load_cpe(struct xccdf_session *session)
Load and parse CPE dictionaries.
Definition: xccdf_session.c:766
xccdf_session::arf_file
char * arf_file
Path to ARF file to export.
Definition: xccdf_session.c:98
xccdf_policy
XCCDF policy structure is abstract (class) structure of Profile element from benchmark.
Definition: xccdf_policy_priv.h:58
xccdf_session::xccdf_session_load_xccdf
int xccdf_session_load_xccdf(struct xccdf_session *session)
Load and parse XCCDF file.
Definition: xccdf_session.c:720
xccdf_session::xccdf_session_new
struct xccdf_session * xccdf_session_new(const char *filename)
Costructor of xccdf_session.
Definition: xccdf_session.c:170
xccdf_session::xccdf_session_loading_flags_t
xccdf_session_loading_flags_t
Loading flags for XCCDF session.
Definition: xccdf_session.h:49
xccdf_session::xccdf_session_set_benchmark_id
void xccdf_session_set_benchmark_id(struct xccdf_session *session, const char *benchmark_id)
Sets requested benchmark_id for this session.
Definition: xccdf_session.c:333
xccdf_session::xccdf_session_export_sce
int xccdf_session_export_sce(struct xccdf_session *session)
Export SCE files (if enabled by xccdf_session_set_sce_results_export).
Definition: xccdf_session.c:1608
xccdf_session::xccdf_session_get_sds_idx
struct ds_sds_index * xccdf_session_get_sds_idx(struct xccdf_session *session)
Get Source DataStream index of the session.
Definition: xccdf_session.c:573
xccdf_session::full_validation
bool full_validation
True value indicates that every possible step will be validated by XSD.
Definition: xccdf_session.c:114
xccdf_session::product_cpe
char * product_cpe
CPE of scanner product.
Definition: xccdf_session.c:91
xccdf_session::xccdf_session_set_oval_results_export
void xccdf_session_set_oval_results_export(struct xccdf_session *session, bool to_export_oval_results)
Set whether the OVAL result files shall be exported.
Definition: xccdf_session.c:385
xccdf_session::validate
bool validate
False value indicates to skip any XSD validation.
Definition: xccdf_session.c:113
xccdf_session::xccdf_session_contains_fail_result
bool xccdf_session_contains_fail_result(const struct xccdf_session *session)
Query if the result of evaluation contains FAIL, ERROR, or UNKNOWN rule-result elements.
Definition: xccdf_session.c:1675
xccdf_session::xccdf_session_set_xccdf_export
bool xccdf_session_set_xccdf_export(struct xccdf_session *session, const char *xccdf_file)
Set where to export XCCDF file.
Definition: xccdf_session.c:412
xccdf_session::source
struct oscap_source * source
Main source assigned with the main file (SDS or XCCDF)
Definition: xccdf_session.c:68
xccdf_session::xccdf_session_set_remote_resources
void xccdf_session_set_remote_resources(struct xccdf_session *session, bool allowed, download_progress_calllback_t callback)
Set properties of remote content.
Definition: xccdf_session.c:544
xccdf_session::xccdf_session_set_user_tailoring_file
void xccdf_session_set_user_tailoring_file(struct xccdf_session *session, const char *user_tailoring_file)
Set path to custom Tailoring file for the session.
Definition: xccdf_session.c:355
xccdf_session::xccdf_session_set_oval_variables_export
void xccdf_session_set_oval_variables_export(struct xccdf_session *session, bool to_export_oval_variables)
Set whether the OVAL variables files shall be exported.
Definition: xccdf_session.c:390
xccdf_session::xccdf_session_get_oval_agents_count
unsigned int xccdf_session_get_oval_agents_count(const struct xccdf_session *session)
Get count of OVAL agent sessions not used for CPE in the xccdf_session.
Definition: xccdf_session.c:1648
xccdf_session::xccdf_session_get_profile_id
const char * xccdf_session_get_profile_id(struct xccdf_session *session)
Retrieves ID of the profile that we will evaluate with, or NULL.
Definition: xccdf_session.c:529
xccdf_session::xccdf_session_get_cpe_oval_agents_count
unsigned int xccdf_session_get_cpe_oval_agents_count(const struct xccdf_session *session)
Get count of OVAL agent sessions for CPE in the xccdf_session.
Definition: xccdf_session.c:1657
xccdf_session::session
struct ds_sds_session * session
SDS Registry abstract structure.
Definition: xccdf_session.c:79
xccdf_session::xccdf_session_get_filename
const char * xccdf_session_get_filename(const struct xccdf_session *session)
Retrieves the filename the session was created with.
Definition: xccdf_session.c:279