Open SCAP Library

xccdf_policy.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina.
00003  * All Rights Reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful, 
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software 
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 
00031 #ifndef XCCDF_POLICY_H_
00032 #define XCCDF_POLICY_H_
00033 
00034 #include <xccdf_benchmark.h>
00035 #include <stdbool.h>
00036 #include <time.h>
00037 #include <oscap.h>
00038 
00043 struct xccdf_policy_model;
00044 
00049 struct xccdf_policy;
00050 
00055 struct xccdf_value_binding;
00056 
00057 struct xccdf_value_binding_iterator;
00058 
00064 struct xccdf_policy_iterator;
00065 
00070 typedef enum {
00071         POLICY_ENGINE_QUERY_NAMES_FOR_HREF = 1,         
00072 } xccdf_policy_engine_query_t;
00073 
00088 typedef void *(*xccdf_policy_engine_query_fn) (void *, xccdf_policy_engine_query_t, void *);
00089 
00098 typedef 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);
00099 
00100 /************************************************************/
00101 
00111 struct xccdf_policy_model *xccdf_policy_model_new(struct xccdf_benchmark *benchmark);
00112 
00119 struct xccdf_policy * xccdf_policy_new(struct xccdf_policy_model * model, struct xccdf_profile * profile);
00120 
00126 struct xccdf_value_binding * xccdf_value_binding_new(void);
00127 
00132 void xccdf_policy_model_free(struct xccdf_policy_model *);
00133 
00138 void xccdf_policy_free(struct xccdf_policy *);
00139 
00144 void xccdf_value_binding_free(struct xccdf_value_binding *);
00145 
00161 bool xccdf_policy_model_set_tailoring(struct xccdf_policy_model *model, struct xccdf_tailoring *tailoring);
00162 
00167 struct xccdf_tailoring *xccdf_policy_model_get_tailoring(struct xccdf_policy_model *model);
00168 
00178 char *xccdf_policy_get_readable_item_title(struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang);
00179 
00190 char *xccdf_policy_get_readable_item_description(struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang);
00191 
00196 bool xccdf_policy_model_add_cpe_dict_source(struct xccdf_policy_model * model, struct oscap_source *source);
00197 
00204 bool xccdf_policy_model_add_cpe_dict(struct xccdf_policy_model * model, const char * cpe_dict);
00205 
00210 bool xccdf_policy_model_add_cpe_lang_model_source(struct xccdf_policy_model * model, struct oscap_source *source);
00211 
00218 OSCAP_DEPRECATED(bool xccdf_policy_model_add_cpe_lang_model(struct xccdf_policy_model * model, const char *cpe_lang));
00219 
00225 bool xccdf_policy_model_add_cpe_autodetect_source(struct xccdf_policy_model *model, struct oscap_source *source);
00226 
00234 OSCAP_DEPRECATED(bool xccdf_policy_model_add_cpe_autodetect(struct xccdf_policy_model *model, const char *filepath));
00235 
00240 struct oscap_htable_iterator *xccdf_policy_model_get_cpe_oval_sessions(struct xccdf_policy_model *model);
00241 
00254 OSCAP_DEPRECATED(bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model * model, char * sys, void * func, void * usr));
00255 
00266 bool xccdf_policy_model_register_engine_and_query_callback(struct xccdf_policy_model *model, char *sys, xccdf_policy_engine_eval_fn eval_fn, void *usr, xccdf_policy_engine_query_fn query_fn);
00267 
00268 typedef int (*policy_reporter_output)(struct xccdf_rule_result *, void *);
00269 
00278 bool xccdf_policy_model_register_output_callback(struct xccdf_policy_model * model, policy_reporter_output func, void * usr);
00279 
00280 typedef int (*policy_reporter_start)(struct xccdf_rule *, void *);
00281 
00290 bool xccdf_policy_model_register_start_callback(struct xccdf_policy_model * model, policy_reporter_start func, void * usr);
00291 
00292 /************************************************************/
00306 struct xccdf_policy_model * xccdf_policy_get_model(const struct xccdf_policy * policy);
00307 
00314 struct xccdf_benchmark * xccdf_policy_model_get_benchmark(const struct xccdf_policy_model * item);
00315 
00320 struct xccdf_value_binding_iterator  * xccdf_policy_get_values(const struct xccdf_policy * item);
00321 
00329 struct xccdf_policy_iterator * xccdf_policy_model_get_policies(const struct xccdf_policy_model *model);
00330 
00339 int xccdf_policy_model_build_all_useful_policies(struct xccdf_policy_model *policy_model);
00340 
00347 struct xccdf_select_iterator * xccdf_policy_get_selected_rules(struct xccdf_policy *);
00348 
00354 struct xccdf_profile * xccdf_policy_get_profile(const struct xccdf_policy *);
00355 
00361 struct xccdf_select_iterator * xccdf_policy_get_selects(const struct xccdf_policy *);
00362 
00368 char * xccdf_value_binding_get_name(const struct xccdf_value_binding *);
00369 
00375 char * xccdf_value_binding_get_value(const struct xccdf_value_binding *);
00376 
00382 xccdf_value_type_t xccdf_value_binding_get_type(const struct xccdf_value_binding *);
00383 
00389 xccdf_operator_t xccdf_value_binding_get_operator(const struct xccdf_value_binding *);
00390 
00396 char * xccdf_value_binding_get_setvalue(const struct xccdf_value_binding *);
00397 
00402 struct xccdf_result_iterator * xccdf_policy_get_results(const struct xccdf_policy * policy);
00403 
00409 struct xccdf_result * xccdf_policy_get_result_by_id(struct xccdf_policy * policy, const char * id);
00410 
00417 const char * xccdf_policy_get_id(struct xccdf_policy * policy);
00418 
00426 struct xccdf_policy * xccdf_policy_model_get_policy_by_id(struct xccdf_policy_model * policy_model, const char * id);
00427 
00428 /************************************************************/
00431 /************************************************************/
00444 bool xccdf_policy_model_add_policy(struct xccdf_policy_model *, struct xccdf_policy *);
00445 
00451 bool xccdf_policy_add_select(struct xccdf_policy *, struct xccdf_select *);
00452 
00460 OSCAP_DEPRECATED(
00461 bool xccdf_policy_set_selected(struct xccdf_policy * policy, char * idref)
00462 );
00463 
00468 bool xccdf_policy_add_result(struct xccdf_policy * policy, struct xccdf_result * item);
00469 
00475 bool xccdf_policy_add_value(struct xccdf_policy *, struct xccdf_value_binding *);
00476 
00482 bool xccdf_policy_is_item_selected(struct xccdf_policy *policy, const char *id);
00483 
00488 int xccdf_policy_get_selected_rules_count(struct xccdf_policy *policy);
00489 
00495 struct xccdf_select * xccdf_policy_get_select_by_id(struct xccdf_policy * policy, const char *item_id);
00496 
00497 /************************************************************/
00500 /************************************************************/
00524 struct xccdf_result *  xccdf_policy_evaluate(struct xccdf_policy * policy);
00525 
00534 bool xccdf_policy_resolve(struct xccdf_policy * policy);
00535 
00546 int xccdf_policy_generate_fix(struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, int output_fd);
00547 
00555 OSCAP_DEPRECATED(struct xccdf_item * xccdf_policy_tailor_item(struct xccdf_policy * policy, struct xccdf_item * item));
00556 
00560 struct oscap_file_entry;
00561 
00563 struct oscap_file_entry *oscap_file_entry_new(void);
00565 struct oscap_file_entry *oscap_file_entry_dup(struct oscap_file_entry* file_entry);
00567 void oscap_file_entry_free(struct oscap_file_entry* entry);
00569 const char* oscap_file_entry_get_system(struct oscap_file_entry* entry);
00571 const char* oscap_file_entry_get_file(struct oscap_file_entry* entry);
00572 
00576 struct oscap_file_entry_iterator;
00577 
00579 const struct oscap_file_entry *oscap_file_entry_iterator_next(struct oscap_file_entry_iterator *it);
00581 bool oscap_file_entry_iterator_has_more(struct oscap_file_entry_iterator *it);
00583 void oscap_file_entry_iterator_free(struct oscap_file_entry_iterator *it);
00585 void oscap_file_entry_iterator_reset(struct oscap_file_entry_iterator *it);
00586 
00590 struct oscap_file_entry_list;
00591 
00593 struct oscap_file_entry_list* oscap_file_entry_list_new(void);
00595 void oscap_file_entry_list_free(struct oscap_file_entry_list* list);
00597 struct oscap_file_entry_iterator* oscap_file_entry_list_get_files(struct oscap_file_entry_list* list);
00598 
00607 struct oscap_file_entry_list * xccdf_policy_model_get_systems_and_files(struct xccdf_policy_model * policy_model);
00608 
00616 struct oscap_file_entry_list * xccdf_item_get_systems_and_files(struct xccdf_item * item);
00617 
00623 struct oscap_stringlist * xccdf_policy_model_get_files(struct xccdf_policy_model * policy_model);
00624 
00630 struct oscap_stringlist * xccdf_item_get_files(struct xccdf_item * item);
00631 
00637 xccdf_test_result_type_t xccdf_test_result_resolve_and_operation(xccdf_test_result_type_t A, xccdf_test_result_type_t B);
00638 
00639 /************************************************************/
00642 /************************************************************/
00652 bool xccdf_policy_iterator_has_more(struct xccdf_policy_iterator *it);
00653 
00658 struct xccdf_policy * xccdf_policy_iterator_next(struct xccdf_policy_iterator *it);
00659 
00664 void xccdf_policy_iterator_free(struct xccdf_policy_iterator *it);
00665 
00670 void xccdf_policy_iterator_reset(struct xccdf_policy_iterator *it);
00671 
00676 bool xccdf_value_binding_iterator_has_more(struct xccdf_value_binding_iterator *it);
00677 
00682 struct xccdf_value_binding * xccdf_value_binding_iterator_next(struct xccdf_value_binding_iterator *it);
00683 
00688 void xccdf_value_binding_iterator_free(struct xccdf_value_binding_iterator *it);
00689 
00694 void xccdf_value_binding_iterator_reset(struct xccdf_value_binding_iterator *it);
00695 
00703 struct xccdf_score * xccdf_policy_get_score(struct xccdf_policy * policy, struct xccdf_result * test_result, const char * system);
00704 
00711 int xccdf_policy_recalculate_score(struct xccdf_policy * policy, struct xccdf_result * test_result);
00712 
00721 const char *xccdf_policy_get_value_of_item(struct xccdf_policy * policy, struct xccdf_item * item);
00722 
00728 char* xccdf_policy_substitute(const char *text, struct xccdf_policy *policy);
00729 
00730 /************************************************************/
00736 #endif
00737 
00738 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines