| 1 | /** |
| 2 | * @addtogroup OVAL |
| 3 | * @{ |
| 4 | * @addtogroup OVALAGENT |
| 5 | * OVAL Agent interface |
| 6 | * |
| 7 | * This is a high level API for system probing and OVAL Definition content evaluation. |
| 8 | * @{ |
| 9 | * |
| 10 | * @file |
| 11 | * |
| 12 | * @author "Peter Vrabec" <[email protected]> |
| 13 | */ |
| 14 | |
| 15 | /* |
| 16 | * Copyright 2010,2011 Red Hat Inc., Durham, North Carolina. |
| 17 | * All Rights Reserved. |
| 18 | * |
| 19 | * This library is free software; you can redistribute it and/or |
| 20 | * modify it under the terms of the GNU Lesser General Public |
| 21 | * License as published by the Free Software Foundation; either |
| 22 | * version 2.1 of the License, or (at your option) any later version. |
| 23 | * |
| 24 | * This library is distributed in the hope that it will be useful, |
| 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 27 | * Lesser General Public License for more details. |
| 28 | * |
| 29 | * You should have received a copy of the GNU Lesser General Public |
| 30 | * License along with this library; if not, write to the Free Software |
| 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | |
| 36 | #ifndef OVAL_AGENT_XCCDF_API_H_ |
| 37 | #define OVAL_AGENT_XCCDF_API_H_ |
| 38 | |
| 39 | #include <oscap.h> |
| 40 | #include "oval_agent_api.h" |
| 41 | #include "xccdf_policy.h" |
| 42 | #include "oscap_export.h" |
| 43 | |
| 44 | /** |
| 45 | * @param policy XCCDF Policy that is being evaluated |
| 46 | * @param rule_id ID of XCCDF Rule |
| 47 | * @param id ID of OVAL definition |
| 48 | * @param it XCCDF Value Binding iterator with value bindings |
| 49 | * @param usr Void pointer to the user data structure |
| 50 | * @return XCCDF test result type of evaluated rule |
| 51 | * |
| 52 | */ |
| 53 | typedef xccdf_test_result_type_t (xccdf_policy_eval_rule_cb_t) (struct xccdf_policy * policy, const char * rule_id, |
| 54 | const char * id, struct xccdf_value_binding_iterator * it, void * usr); |
| 55 | |
| 56 | /** |
| 57 | * Internal OVAL Agent Callback that can be used to evaluate XCCDF content. |
| 58 | * |
| 59 | * You can either register this function with xccdf_policy (old fashioned way |
| 60 | * as described in the example bellow). Alternativelly you can use high level |
| 61 | * function xccdf_policy_model_register_engine_oval() (recommended) which will |
| 62 | * register the oval_engine. |
| 63 | * |
| 64 | * \par Example |
| 65 | * Next example shows common use of this function in evaluation proccess of XCCDF file. |
| 66 | * \par |
| 67 | * \code |
| 68 | * struct oscap_source *source = oscap_source_new_from_file(file); |
| 69 | * struct oval_definition_model *def_model = oval_definition_model_import_source(source); |
| 70 | * struct xccdf_benchmark *benchmark = xccdf_benchmark_import_source(source); |
| 71 | * struct xccdf_policy_model *policy_model = xccdf_policy_model_new(benchmark); |
| 72 | * struct oval_agent_session *sess = oval_agent_new_session(def_model, "name-of-file"); |
| 73 | * ... |
| 74 | * xccdf_policy_model_register_engine_and_query_callback(policy_model, "http://oval.mitre.org/XMLSchema/oval-definitions-5", oval_agent_eval_rule, (void *) sess, NULL); |
| 75 | * \endcode |
| 76 | * |
| 77 | */ |
| 78 | OSCAP_API xccdf_test_result_type_t oval_agent_eval_rule(struct xccdf_policy *policy, const char *rule_id, const char *id, const char *href, |
| 79 | struct xccdf_value_binding_iterator * it, |
| 80 | struct xccdf_check_import_iterator * check_import_it, |
| 81 | void * usr); |
| 82 | |
| 83 | /** |
| 84 | * Resolve variables from XCCDF Value Bindings and set their values to OVAL Variables |
| 85 | * @param session OVAL Agent Session |
| 86 | * @param it XCCDF Value Bindng iterator |
| 87 | * @return 0 if resolving pass |
| 88 | * \par Example |
| 89 | * Example in oval_agent.c in function oval_agent_eval_rule |
| 90 | */ |
| 91 | OSCAP_API int oval_agent_resolve_variables(struct oval_agent_session * session, struct xccdf_value_binding_iterator *it); |
| 92 | |
| 93 | |
| 94 | /** |
| 95 | * Function to register predefined oval callback for XCCDF evaluation proccess |
| 96 | * @param model XCCDF Policy Model |
| 97 | * @param sess oval_agent_session_t parameter for passing session data to callback |
| 98 | * @memberof xccdf_policy_model |
| 99 | * @return true if callback registered succesfully, false otherwise |
| 100 | */ |
| 101 | OSCAP_API bool xccdf_policy_model_register_engine_oval(struct xccdf_policy_model * model, struct oval_agent_session * sess); |
| 102 | |
| 103 | /** |
| 104 | * @} END OVALDEF |
| 105 | * @} END OVALAGENT |
| 106 | */ |
| 107 | #endif /**OVAL_AGENT_XCCDF_API_H_ */ |
| 108 | |
| 109 |