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
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
00173 bool xccdf_policy_model_add_cpe_dict(struct xccdf_policy_model * model, const char * cpe_dict);
00174
00179 bool xccdf_policy_model_add_cpe_lang_model(struct xccdf_policy_model * model, const char * cpe_lang);
00180
00186 bool xccdf_policy_model_add_cpe_autodetect(struct xccdf_policy_model *model, const char* filepath);
00187
00192 struct oscap_htable_iterator *xccdf_policy_model_get_cpe_oval_sessions(struct xccdf_policy_model *model);
00193
00206 OSCAP_DEPRECATED(bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model * model, char * sys, void * func, void * usr));
00207
00218 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);
00219
00220 typedef int (*policy_reporter_output)(struct xccdf_rule_result *, void *);
00221
00230 bool xccdf_policy_model_register_output_callback(struct xccdf_policy_model * model, policy_reporter_output func, void * usr);
00231
00232 typedef int (*policy_reporter_start)(struct xccdf_rule *, void *);
00233
00242 bool xccdf_policy_model_register_start_callback(struct xccdf_policy_model * model, policy_reporter_start func, void * usr);
00243
00244
00258 struct xccdf_policy_model * xccdf_policy_get_model(const struct xccdf_policy * policy);
00259
00266 struct xccdf_benchmark * xccdf_policy_model_get_benchmark(const struct xccdf_policy_model * item);
00267
00272 struct xccdf_value_binding_iterator * xccdf_policy_get_values(const struct xccdf_policy * item);
00273
00281 struct xccdf_policy_iterator * xccdf_policy_model_get_policies(const struct xccdf_policy_model *model);
00282
00289 struct xccdf_select_iterator * xccdf_policy_get_selected_rules(struct xccdf_policy *);
00290
00296 struct xccdf_profile * xccdf_policy_get_profile(const struct xccdf_policy *);
00297
00303 struct xccdf_select_iterator * xccdf_policy_get_selects(const struct xccdf_policy *);
00304
00310 char * xccdf_value_binding_get_name(const struct xccdf_value_binding *);
00311
00317 char * xccdf_value_binding_get_value(const struct xccdf_value_binding *);
00318
00324 xccdf_value_type_t xccdf_value_binding_get_type(const struct xccdf_value_binding *);
00325
00331 xccdf_operator_t xccdf_value_binding_get_operator(const struct xccdf_value_binding *);
00332
00338 char * xccdf_value_binding_get_setvalue(const struct xccdf_value_binding *);
00339
00344 struct xccdf_result_iterator * xccdf_policy_get_results(const struct xccdf_policy * policy);
00345
00351 struct xccdf_result * xccdf_policy_get_result_by_id(struct xccdf_policy * policy, const char * id);
00352
00359 const char * xccdf_policy_get_id(struct xccdf_policy * policy);
00360
00368 struct xccdf_policy * xccdf_policy_model_get_policy_by_id(struct xccdf_policy_model * policy_model, const char * id);
00369
00370
00373
00386 bool xccdf_policy_model_add_policy(struct xccdf_policy_model *, struct xccdf_policy *);
00387
00393 bool xccdf_policy_add_select(struct xccdf_policy *, struct xccdf_select *);
00394
00402 OSCAP_DEPRECATED(
00403 bool xccdf_policy_set_selected(struct xccdf_policy * policy, char * idref)
00404 );
00405
00410 bool xccdf_policy_add_result(struct xccdf_policy * policy, struct xccdf_result * item);
00411
00417 bool xccdf_policy_add_value(struct xccdf_policy *, struct xccdf_value_binding *);
00418
00424 bool xccdf_policy_is_item_selected(struct xccdf_policy *policy, const char *id);
00425
00430 int xccdf_policy_get_selected_rules_count(struct xccdf_policy *policy);
00431
00437 struct xccdf_select * xccdf_policy_get_select_by_id(struct xccdf_policy * policy, const char *item_id);
00438
00439
00442
00466 struct xccdf_result * xccdf_policy_evaluate(struct xccdf_policy * policy);
00467
00476 bool xccdf_policy_resolve(struct xccdf_policy * policy);
00477
00488 int xccdf_policy_generate_fix(struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, int output_fd);
00489
00496 struct xccdf_item * xccdf_policy_tailor_item(struct xccdf_policy * policy, struct xccdf_item * item);
00497
00501 struct oscap_file_entry;
00502
00504 struct oscap_file_entry *oscap_file_entry_new(void);
00506 struct oscap_file_entry *oscap_file_entry_dup(struct oscap_file_entry* file_entry);
00508 void oscap_file_entry_free(struct oscap_file_entry* entry);
00510 const char* oscap_file_entry_get_system(struct oscap_file_entry* entry);
00512 const char* oscap_file_entry_get_file(struct oscap_file_entry* entry);
00513
00517 struct oscap_file_entry_iterator;
00518
00520 const struct oscap_file_entry *oscap_file_entry_iterator_next(struct oscap_file_entry_iterator *it);
00522 bool oscap_file_entry_iterator_has_more(struct oscap_file_entry_iterator *it);
00524 void oscap_file_entry_iterator_free(struct oscap_file_entry_iterator *it);
00526 void oscap_file_entry_iterator_reset(struct oscap_file_entry_iterator *it);
00527
00531 struct oscap_file_entry_list;
00532
00534 struct oscap_file_entry_list* oscap_file_entry_list_new(void);
00536 void oscap_file_entry_list_free(struct oscap_file_entry_list* list);
00538 struct oscap_file_entry_iterator* oscap_file_entry_list_get_files(struct oscap_file_entry_list* list);
00539
00548 struct oscap_file_entry_list * xccdf_policy_model_get_systems_and_files(struct xccdf_policy_model * policy_model);
00549
00557 struct oscap_file_entry_list * xccdf_item_get_systems_and_files(struct xccdf_item * item);
00558
00564 struct oscap_stringlist * xccdf_policy_model_get_files(struct xccdf_policy_model * policy_model);
00565
00571 struct oscap_stringlist * xccdf_item_get_files(struct xccdf_item * item);
00572
00578 xccdf_test_result_type_t xccdf_test_result_resolve_and_operation(xccdf_test_result_type_t A, xccdf_test_result_type_t B);
00579
00580
00583
00593 bool xccdf_policy_iterator_has_more(struct xccdf_policy_iterator *it);
00594
00599 struct xccdf_policy * xccdf_policy_iterator_next(struct xccdf_policy_iterator *it);
00600
00605 void xccdf_policy_iterator_free(struct xccdf_policy_iterator *it);
00606
00611 void xccdf_policy_iterator_reset(struct xccdf_policy_iterator *it);
00612
00617 bool xccdf_value_binding_iterator_has_more(struct xccdf_value_binding_iterator *it);
00618
00623 struct xccdf_value_binding * xccdf_value_binding_iterator_next(struct xccdf_value_binding_iterator *it);
00624
00629 void xccdf_value_binding_iterator_free(struct xccdf_value_binding_iterator *it);
00630
00635 void xccdf_value_binding_iterator_reset(struct xccdf_value_binding_iterator *it);
00636
00644 struct xccdf_score * xccdf_policy_get_score(struct xccdf_policy * policy, struct xccdf_result * test_result, const char * system);
00645
00651 char* xccdf_policy_substitute(const char *text, struct xccdf_policy *policy);
00652
00653
00659 #endif
00660
00661