Open SCAP Library
xccdf_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009--2014 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  */
20 
21 
31 #ifndef XCCDF_POLICY_H_
32 #define XCCDF_POLICY_H_
33 
34 #include <xccdf_benchmark.h>
35 #include <stdbool.h>
36 #include <time.h>
37 #include <oscap.h>
38 
43 struct xccdf_policy_model;
44 
49 struct xccdf_policy;
50 
55 struct xccdf_value_binding;
56 
57 struct xccdf_value_binding_iterator;
58 
65 
70 typedef enum {
71  POLICY_ENGINE_QUERY_NAMES_FOR_HREF = 1,
73 
88 typedef void *(*xccdf_policy_engine_query_fn) (void *, xccdf_policy_engine_query_t, void *);
89 
98 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);
99 
100 /************************************************************/
101 
112 
120 
127 
133 
138 void xccdf_policy_free(struct xccdf_policy *);
139 
145 
161 bool xccdf_policy_model_set_tailoring(struct xccdf_policy_model *model, struct xccdf_tailoring *tailoring);
162 
168 
178 char *xccdf_policy_get_readable_item_title(struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang);
179 
190 char *xccdf_policy_get_readable_item_description(struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang);
191 
196 bool xccdf_policy_model_add_cpe_dict(struct xccdf_policy_model * model, const char * cpe_dict);
197 
202 bool xccdf_policy_model_add_cpe_lang_model(struct xccdf_policy_model * model, const char * cpe_lang);
203 
209 bool xccdf_policy_model_add_cpe_autodetect(struct xccdf_policy_model *model, const char* filepath);
210 
216 
229 OSCAP_DEPRECATED(bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model * model, char * sys, void * func, void * usr));
230 
242 
243 typedef int (*policy_reporter_output)(struct xccdf_rule_result *, void *);
244 
253 bool xccdf_policy_model_register_output_callback(struct xccdf_policy_model * model, policy_reporter_output func, void * usr);
254 
255 typedef int (*policy_reporter_start)(struct xccdf_rule *, void *);
256 
265 bool xccdf_policy_model_register_start_callback(struct xccdf_policy_model * model, policy_reporter_start func, void * usr);
266 
267 /************************************************************/
281 struct xccdf_policy_model * xccdf_policy_get_model(const struct xccdf_policy * policy);
282 
290 
295 struct xccdf_value_binding_iterator * xccdf_policy_get_values(const struct xccdf_policy * item);
296 
305 
313 
319 struct xccdf_profile * xccdf_policy_get_profile(const struct xccdf_policy *);
320 
327 
334 
341 
348 
355 
362 
367 struct xccdf_result_iterator * xccdf_policy_get_results(const struct xccdf_policy * policy);
368 
374 struct xccdf_result * xccdf_policy_get_result_by_id(struct xccdf_policy * policy, const char * id);
375 
382 const char * xccdf_policy_get_id(struct xccdf_policy * policy);
383 
391 struct xccdf_policy * xccdf_policy_model_get_policy_by_id(struct xccdf_policy_model * policy_model, const char * id);
392 
393 /************************************************************/
396 /************************************************************/
410 
416 bool xccdf_policy_add_select(struct xccdf_policy *, struct xccdf_select *);
417 
426 bool xccdf_policy_set_selected(struct xccdf_policy * policy, char * idref)
427 );
428 
433 bool xccdf_policy_add_result(struct xccdf_policy * policy, struct xccdf_result * item);
434 
441 
447 bool xccdf_policy_is_item_selected(struct xccdf_policy *policy, const char *id);
448 
454 
460 struct xccdf_select * xccdf_policy_get_select_by_id(struct xccdf_policy * policy, const char *item_id);
461 
462 /************************************************************/
465 /************************************************************/
489 struct xccdf_result * xccdf_policy_evaluate(struct xccdf_policy * policy);
490 
499 bool xccdf_policy_resolve(struct xccdf_policy * policy);
500 
511 int xccdf_policy_generate_fix(struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, int output_fd);
512 
519 struct xccdf_item * xccdf_policy_tailor_item(struct xccdf_policy * policy, struct xccdf_item * item);
520 
524 struct oscap_file_entry;
525 
529 struct oscap_file_entry *oscap_file_entry_dup(struct oscap_file_entry* file_entry);
531 void oscap_file_entry_free(struct oscap_file_entry* entry);
533 const char* oscap_file_entry_get_system(struct oscap_file_entry* entry);
535 const char* oscap_file_entry_get_file(struct oscap_file_entry* entry);
536 
541 
550 
554 struct oscap_file_entry_list;
555 
562 
572 
581 
588 
594 struct oscap_stringlist * xccdf_item_get_files(struct xccdf_item * item);
595 
602 
603 /************************************************************/
606 /************************************************************/
617 
623 
629 
635 
640 bool xccdf_value_binding_iterator_has_more(struct xccdf_value_binding_iterator *it);
641 
646 struct xccdf_value_binding * xccdf_value_binding_iterator_next(struct xccdf_value_binding_iterator *it);
647 
652 void xccdf_value_binding_iterator_free(struct xccdf_value_binding_iterator *it);
653 
658 void xccdf_value_binding_iterator_reset(struct xccdf_value_binding_iterator *it);
659 
667 struct xccdf_score * xccdf_policy_get_score(struct xccdf_policy * policy, struct xccdf_result * test_result, const char * system);
668 
677 const char *xccdf_policy_get_value_of_item(struct xccdf_policy * policy, struct xccdf_item * item);
678 
684 char* xccdf_policy_substitute(const char *text, struct xccdf_policy *policy);
685 
686 /************************************************************/
692 #endif
693 
694