00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00108 struct xccdf_policy_model *xccdf_policy_model_new(struct xccdf_benchmark *benchmark);
00109
00116 struct xccdf_policy * xccdf_policy_new(struct xccdf_policy_model * model, struct xccdf_profile * profile);
00117
00123 struct xccdf_value_binding * xccdf_value_binding_new(void);
00124
00129 void xccdf_policy_model_free(struct xccdf_policy_model *);
00130
00135 void xccdf_policy_free(struct xccdf_policy *);
00136
00141 void xccdf_value_binding_free(struct xccdf_value_binding *);
00142
00147 bool xccdf_policy_model_add_cpe_dict(struct xccdf_policy_model * model, const char * cpe_dict);
00148
00153 bool xccdf_policy_model_add_cpe_lang_model(struct xccdf_policy_model * model, const char * cpe_lang);
00154
00160 bool xccdf_policy_model_add_cpe_autodetect(struct xccdf_policy_model *model, const char* filepath);
00161
00174 OSCAP_DEPRECATED(bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model * model, char * sys, void * func, void * usr));
00175
00186 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);
00187
00188 typedef int (*policy_reporter_output)(struct xccdf_rule_result *, void *);
00189
00198 bool xccdf_policy_model_register_output_callback(struct xccdf_policy_model * model, policy_reporter_output func, void * usr);
00199
00200 typedef int (*policy_reporter_start)(struct xccdf_rule *, void *);
00201
00210 bool xccdf_policy_model_register_start_callback(struct xccdf_policy_model * model, policy_reporter_start func, void * usr);
00211
00212
00226 struct xccdf_policy_model * xccdf_policy_get_model(const struct xccdf_policy * policy);
00227
00234 struct xccdf_benchmark * xccdf_policy_model_get_benchmark(const struct xccdf_policy_model * item);
00235
00240 struct xccdf_value_binding_iterator * xccdf_policy_get_values(const struct xccdf_policy * item);
00241
00248 struct xccdf_policy_iterator * xccdf_policy_model_get_policies(const struct xccdf_policy_model *model);
00249
00256 struct xccdf_select_iterator * xccdf_policy_get_selected_rules(struct xccdf_policy *);
00257
00263 struct xccdf_profile * xccdf_policy_get_profile(const struct xccdf_policy *);
00264
00270 struct xccdf_select_iterator * xccdf_policy_get_selects(const struct xccdf_policy *);
00271
00277 char * xccdf_value_binding_get_name(const struct xccdf_value_binding *);
00278
00284 char * xccdf_value_binding_get_value(const struct xccdf_value_binding *);
00285
00291 xccdf_value_type_t xccdf_value_binding_get_type(const struct xccdf_value_binding *);
00292
00298 xccdf_operator_t xccdf_value_binding_get_operator(const struct xccdf_value_binding *);
00299
00305 char * xccdf_value_binding_get_setvalue(const struct xccdf_value_binding *);
00306
00311 struct xccdf_result_iterator * xccdf_policy_get_results(const struct xccdf_policy * policy);
00312
00318 struct xccdf_result * xccdf_policy_get_result_by_id(struct xccdf_policy * policy, const char * id);
00319
00326 const char * xccdf_policy_get_id(struct xccdf_policy * policy);
00327
00335 struct xccdf_policy * xccdf_policy_model_get_policy_by_id(struct xccdf_policy_model * policy_model, const char * id);
00336
00337
00340
00353 bool xccdf_policy_model_add_policy(struct xccdf_policy_model *, struct xccdf_policy *);
00354
00360 bool xccdf_policy_add_select(struct xccdf_policy *, struct xccdf_select *);
00361
00367 bool xccdf_policy_set_selected(struct xccdf_policy * policy, char * idref);
00368
00373 bool xccdf_policy_add_result(struct xccdf_policy * policy, struct xccdf_result * item);
00374
00380 bool xccdf_policy_add_value(struct xccdf_policy *, struct xccdf_value_binding *);
00381
00387
00393 struct xccdf_select * xccdf_policy_get_select_by_id(struct xccdf_policy * policy, const char *item_id);
00394
00395
00398
00422 struct xccdf_result * xccdf_policy_evaluate(struct xccdf_policy * policy);
00423
00432 bool xccdf_policy_resolve(struct xccdf_policy * policy);
00433
00440 struct xccdf_item * xccdf_policy_tailor_item(struct xccdf_policy * policy, struct xccdf_item * item);
00441
00445 struct oscap_file_entry;
00446
00448 struct oscap_file_entry *oscap_file_entry_new(void);
00450 struct oscap_file_entry *oscap_file_entry_dup(struct oscap_file_entry* file_entry);
00452 void oscap_file_entry_free(struct oscap_file_entry* entry);
00454 const char* oscap_file_entry_get_system(struct oscap_file_entry* entry);
00456 const char* oscap_file_entry_get_file(struct oscap_file_entry* entry);
00457
00461 struct oscap_file_entry_iterator;
00462
00464 const struct oscap_file_entry *oscap_file_entry_iterator_next(struct oscap_file_entry_iterator *it);
00466 bool oscap_file_entry_iterator_has_more(struct oscap_file_entry_iterator *it);
00468 void oscap_file_entry_iterator_free(struct oscap_file_entry_iterator *it);
00470 void oscap_file_entry_iterator_reset(struct oscap_file_entry_iterator *it);
00471
00475 struct oscap_file_entry_list;
00476
00478 struct oscap_file_entry_list* oscap_file_entry_list_new(void);
00480 void oscap_file_entry_list_free(struct oscap_file_entry_list* list);
00482 struct oscap_file_entry_iterator* oscap_file_entry_list_get_files(struct oscap_file_entry_list* list);
00483
00492 struct oscap_file_entry_list * xccdf_policy_model_get_systems_and_files(struct xccdf_policy_model * policy_model);
00493
00501 struct oscap_file_entry_list * xccdf_item_get_systems_and_files(struct xccdf_item * item);
00502
00508 struct oscap_stringlist * xccdf_policy_model_get_files(struct xccdf_policy_model * policy_model);
00509
00515 struct oscap_stringlist * xccdf_item_get_files(struct xccdf_item * item);
00516
00522 xccdf_test_result_type_t xccdf_test_result_resolve_and_operation(xccdf_test_result_type_t A, xccdf_test_result_type_t B);
00523
00524
00527
00537 bool xccdf_policy_iterator_has_more(struct xccdf_policy_iterator *it);
00538
00543 struct xccdf_policy * xccdf_policy_iterator_next(struct xccdf_policy_iterator *it);
00544
00549 void xccdf_policy_iterator_free(struct xccdf_policy_iterator *it);
00550
00555 void xccdf_policy_iterator_reset(struct xccdf_policy_iterator *it);
00556
00561 bool xccdf_value_binding_iterator_has_more(struct xccdf_value_binding_iterator *it);
00562
00567 struct xccdf_value_binding * xccdf_value_binding_iterator_next(struct xccdf_value_binding_iterator *it);
00568
00573 void xccdf_value_binding_iterator_free(struct xccdf_value_binding_iterator *it);
00574
00579 void xccdf_value_binding_iterator_reset(struct xccdf_value_binding_iterator *it);
00580
00588 struct xccdf_score * xccdf_policy_get_score(struct xccdf_policy * policy, struct xccdf_result * test_result, const char * system);
00589
00595 char* xccdf_policy_substitute(const char *text, struct xccdf_policy *policy);
00596
00597
00603 #endif
00604
00605