Open SCAP Library

sce_engine_api.h
1 /*
2 * Copyright 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors:
20 * "Martin Preisler" <mpreisle@redhat.com>
21 */
22
23 #pragma once
24
25 #ifndef SCE_ENGINE_API_H_
26 #define SCE_ENGINE_API_H_
27
28 #include <xccdf_benchmark.h>
29 #include <xccdf_policy.h>
30
34 struct sce_check_result* sce_check_result_new(void);
35
39 void sce_check_result_free(struct sce_check_result* v);
40
46 void sce_check_result_set_href(struct sce_check_result* v, const char* href);
47
51 const char* sce_check_result_get_href(struct sce_check_result* v);
52
58 void sce_check_result_set_basename(struct sce_check_result* v, const char* basename);
59
63 const char* sce_check_result_get_basename(struct sce_check_result* v);
64
71 void sce_check_result_set_stdout(struct sce_check_result* v, const char* details);
72
76 const char* sce_check_result_get_stdout(struct sce_check_result* v);
77
84 void sce_check_result_set_stderr(struct sce_check_result* v, const char* details);
85
89 const char* sce_check_result_get_stderr(struct sce_check_result* v);
90
95 void sce_check_result_set_exit_code(struct sce_check_result* v, int exit_code);
96
100 int sce_check_result_get_exit_code(struct sce_check_result* v);
101
107 void sce_check_result_reset_environment_variables(struct sce_check_result* v);
108
119 void sce_check_result_add_environment_variable(struct sce_check_result* v, const char* var);
120
126 void sce_check_result_set_xccdf_result(struct sce_check_result* v, xccdf_test_result_type_t result);
127
131 xccdf_test_result_type_t sce_check_result_get_xccdf_result(struct sce_check_result* v);
132
138 void sce_check_result_export(struct sce_check_result* v, const char* target_file);
139
143 struct sce_session* sce_session_new(void);
144
148 void sce_session_free(struct sce_session* s);
149
155 void sce_session_reset(struct sce_session* s);
156
164 void sce_session_add_check_result(struct sce_session* s, struct sce_check_result* result);
165
171 struct sce_check_result_iterator;
172 struct sce_check_result *sce_check_result_iterator_next(struct sce_check_result_iterator *it);
174 bool sce_check_result_iterator_has_more(struct sce_check_result_iterator *it);
176 void sce_check_result_iterator_free(struct sce_check_result_iterator *it);
178 void sce_check_result_iterator_reset(struct sce_check_result_iterator *it);
179
180 struct sce_check_result_iterator *sce_session_get_check_results(struct sce_session* s);
181
187 void sce_session_export_to_directory(struct sce_session* s, const char* directory);
188
192 struct sce_parameters* sce_parameters_new(void);
193
197 void sce_parameters_free(struct sce_parameters* v);
198
205 void sce_parameters_set_xccdf_directory(struct sce_parameters* v, const char* value);
206
210 const char* sce_parameters_get_xccdf_directory(struct sce_parameters* v);
211
219 void sce_parameters_set_session(struct sce_parameters* v, struct sce_session* value);
220
224 struct sce_session* sce_parameters_get_session(struct sce_parameters* v);
225
232 void sce_parameters_allocate_session(struct sce_parameters* v);
233
239 xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const char *rule_id, const char *id, const char *href,
240 struct xccdf_value_binding_iterator *value_binding_it,
241 struct xccdf_check_import_iterator *check_import_it,
242 void *usr);
243
250 bool xccdf_policy_model_register_engine_sce(struct xccdf_policy_model * model, struct sce_parameters *sce_parameters);
251
252 #endif
xccdf_policy.h
Open-scap XCCDF Policy library interface.
xccdf_check_import_iterator
Check import iterator.
Definition: xccdf_benchmark.h:539
sce_check_result_iterator
Iterator over collections of sce_check_results.
sce_check_result
Definition: sce_engine.c:57
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
sce_check_result_iterator::sce_check_result_iterator_free
void sce_check_result_iterator_free(struct sce_check_result_iterator *it)
sce_check_result::sce_check_result_add_environment_variable
void sce_check_result_add_environment_variable(struct sce_check_result *v, const char *var)
Adds an environment variable entry to list of environment variables that were passed to the script...
Definition: sce_engine.c:156
sce_check_result::sce_check_result_export
void sce_check_result_export(struct sce_check_result *v, const char *target_file)
Exports details (in XML form) of given check result to given file.
Definition: sce_engine.c:171
sce_check_result_iterator::sce_check_result_iterator_has_more
bool sce_check_result_iterator_has_more(struct sce_check_result_iterator *it)
xccdf_benchmark.h
Open-scap XCCDF library interface.
xccdf_test_result_type_t
xccdf_test_result_type_t
Test result.
Definition: xccdf_benchmark.h:168
sce_parameters::sce_parameters_allocate_session
void sce_parameters_allocate_session(struct sce_parameters *v)
Just a convenience shortcut of setting a session to a newly allocated session.
Definition: sce_engine.c:312
sce_check_result::sce_check_result_set_exit_code
void sce_check_result_set_exit_code(struct sce_check_result *v, int exit_code)
Sets exit code with which the script ended execution after evaluation.
Definition: sce_engine.c:140
sce_engine_eval_rule
xccdf_test_result_type_t sce_engine_eval_rule(struct xccdf_policy *policy, const char *rule_id, const char *id, const char *href, struct xccdf_value_binding_iterator *value_binding_it, struct xccdf_check_import_iterator *check_import_it, void *usr)
Internal rule evaluation callback, don&#39;t use directly.
Definition: sce_engine.c:349
sce_session
Definition: sce_engine.c:207
sce_parameters_set_xccdf_directory
void sce_parameters_set_xccdf_directory(struct sce_parameters *v, const char *value)
Sets the directory that contains XCCDF that will reference SCE checks.
Definition: sce_engine.c:288
sce_check_result::sce_check_result_set_href
void sce_check_result_set_href(struct sce_check_result *v, const char *href)
Sets the href used to execute the check that yielded given check result.
Definition: sce_engine.c:96
sce_check_result::sce_check_result_set_stderr
void sce_check_result_set_stderr(struct sce_check_result *v, const char *details)
Sets stderr that was captured while script was evaluating.
Definition: sce_engine.c:129
sce_session::sce_session_export_to_directory
void sce_session_export_to_directory(struct sce_session *s, const char *directory)
Exports all check results to given directory.
Definition: sce_engine.c:247
sce_session::sce_session_add_check_result
void sce_session_add_check_result(struct sce_session *s, struct sce_check_result *result)
Adds a check result to the session.
Definition: sce_engine.c:235
sce_check_result::sce_check_result_set_stdout
void sce_check_result_set_stdout(struct sce_check_result *v, const char *details)
Sets stdout that was captured while script was evaluating.
Definition: sce_engine.c:118
sce_check_result_iterator::sce_check_result_iterator_reset
void sce_check_result_iterator_reset(struct sce_check_result_iterator *it)
sce_check_result::sce_check_result_reset_environment_variables
void sce_check_result_reset_environment_variables(struct sce_check_result *v)
Clears the list of passed environment variables.
Definition: sce_engine.c:150
sce_session::sce_session_reset
void sce_session_reset(struct sce_session *s)
Removes all check results from the session.
Definition: sce_engine.c:229
sce_check_result::sce_check_result_set_basename
void sce_check_result_set_basename(struct sce_check_result *v, const char *basename)
Sets basename of the script that was used for check evaluation.
Definition: sce_engine.c:107
sce_parameters
Definition: sce_engine.c:262
xccdf_policy
XCCDF policy structure is abstract (class) structure of Profile element from benchmark.
Definition: xccdf_policy_priv.h:58
sce_check_result::sce_check_result_set_xccdf_result
void sce_check_result_set_xccdf_result(struct sce_check_result *v, xccdf_test_result_type_t result)
Sets the final xccdf result (after exit code to xccdf mapping takes place)
Definition: sce_engine.c:161
xccdf_policy_model_register_engine_sce
bool xccdf_policy_model_register_engine_sce(struct xccdf_policy_model *model, struct sce_parameters *parameters)
Registers SCE to given policy model.
Definition: sce_engine.c:681
sce_parameters::sce_parameters_set_session
void sce_parameters_set_session(struct sce_parameters *v, struct sce_session *value)
Sets SCE session to use for check results storage.
Definition: sce_engine.c:301