00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef XCCDF_ITEM_
00024 #define XCCDF_ITEM_
00025
00026 #include <assert.h>
00027
00028 #include "public/xccdf_benchmark.h"
00029 #include "elements.h"
00030
00031 #include "common/reference_priv.h"
00032 #include "common/list.h"
00033 #include "common/util.h"
00034 #include "common/text_priv.h"
00035
00036 OSCAP_HIDDEN_START;
00037
00038 struct xccdf_flags {
00039 bool selected:1;
00040 bool hidden:1;
00041 bool resolved:1;
00042 bool abstract:1;
00043 bool prohibit_changes:1;
00044 bool interactive:1;
00045 bool multiple:1;
00046 };
00047
00048 struct xccdf_defflags {
00049 bool selected:1;
00050 bool hidden:1;
00051 bool resolved:1;
00052 bool abstract:1;
00053 bool prohibit_changes:1;
00054 bool interactive:1;
00055 bool multiple:1;
00056 bool weight:1;
00057 bool role:1;
00058 bool severity:1;
00059 };
00060
00061 struct xccdf_item;
00062 struct xccdf_check;
00063
00064 struct xccdf_item_base {
00065 char *id;
00066 char *cluster_id;
00067 float weight;
00068
00069 struct oscap_list *title;
00070 struct oscap_list *description;
00071 struct oscap_list *question;
00072 struct oscap_list *rationale;
00073 struct oscap_list *warnings;
00074
00075 char *version;
00076 char *version_update;
00077 char *version_time;
00078
00079 struct xccdf_item *parent;
00080 char *extends;
00081 struct oscap_list *statuses;
00082 struct oscap_list *dc_statuses;
00083 struct oscap_list *references;
00084 struct oscap_list *platforms;
00085 struct xccdf_flags flags;
00086 struct xccdf_defflags defined_flags;
00087
00088 struct oscap_list *metadata;
00089 };
00090
00091 struct xccdf_rule_item {
00092 char *impact_metric;
00093 xccdf_role_t role;
00094 xccdf_level_t severity;
00095
00096 struct oscap_list *requires;
00097 struct oscap_list *conflicts;
00098
00099 struct oscap_list *profile_notes;
00100 struct oscap_list *idents;
00101 struct oscap_list *checks;
00102 struct oscap_list *fixes;
00103 struct oscap_list *fixtexts;
00104 };
00105
00106 struct xccdf_group_item {
00107 struct oscap_list *requires;
00108 struct oscap_list *conflicts;
00109
00110 struct oscap_list *values;
00111 struct oscap_list *content;
00112 };
00113
00114
00115 struct xccdf_value_instance {
00116 char *selector;
00117 xccdf_value_type_t type;
00118 char *value;
00119 char *defval;
00120 struct oscap_list *choices;
00121 xccdf_numeric lower_bound;
00122 xccdf_numeric upper_bound;
00123 char *match;
00124 struct {
00125 bool value_given : 1;
00126 bool defval_given : 1;
00127 bool must_match_given : 1;
00128 bool must_match : 1;
00129 } flags;
00130 };
00131
00132 struct xccdf_value_item {
00133 xccdf_value_type_t type;
00134 xccdf_interface_hint_t interface_hint;
00135 xccdf_operator_t oper;
00136
00137 struct oscap_list *instances;
00138 struct oscap_list *sources;
00139 };
00140
00141 struct xccdf_result_item {
00142 char *start_time;
00143 char *end_time;
00144 char *test_system;
00145 char *benchmark_uri;
00146 char *profile;
00147
00148 struct oscap_list *identities;
00149 struct oscap_list *targets;
00150 struct oscap_list *organizations;
00151 struct oscap_list *remarks;
00152 struct oscap_list *target_addresses;
00153 struct oscap_list *target_facts;
00154 struct oscap_list *target_id_refs;
00155 struct oscap_list *setvalues;
00156 struct oscap_list *rule_results;
00157 struct oscap_list *scores;
00158 };
00159
00160 struct xccdf_profile_item {
00161 char *note_tag;
00162 struct oscap_list *selects;
00163 struct oscap_list *setvalues;
00164 struct oscap_list *refine_values;
00165 struct oscap_list *refine_rules;
00166 bool tailoring;
00167 };
00168
00169 struct xccdf_tailoring {
00170
00171
00172 char *benchmark_ref;
00173
00174 struct oscap_list *statuses;
00175 struct oscap_list *dc_statuses;
00176
00177 char *version;
00178 char *version_update;
00179 char *version_time;
00180
00181 struct oscap_list *metadata;
00182
00183 struct oscap_list *profiles;
00184 };
00185
00186 struct xccdf_benchmark_item {
00187 const struct xccdf_version_info *schema_version;
00188
00189 struct oscap_htable *items_dict;
00190 struct oscap_htable *profiles_dict;
00191 struct oscap_htable *results_dict;
00192 struct oscap_htable *clusters_dict;
00193 struct oscap_list *notices;
00194 struct oscap_list *plain_texts;
00195
00196 struct cpe_dict_model *cpe_list;
00197 struct cpe_lang_model *cpe_lang_model;
00198
00199 char *style;
00200 char *style_href;
00201 char *lang;
00202
00203 struct oscap_list *front_matter;
00204 struct oscap_list *rear_matter;
00205
00206 struct oscap_list *models;
00207 struct oscap_list *profiles;
00208 struct oscap_list *values;
00209 struct oscap_list *content;
00210 struct oscap_list *results;
00211 };
00212
00213 struct xccdf_item {
00214 xccdf_type_t type;
00215 struct xccdf_item_base item;
00216 union {
00217 struct xccdf_profile_item profile;
00218 struct xccdf_benchmark_item benchmark;
00219 struct xccdf_rule_item rule;
00220 struct xccdf_group_item group;
00221 struct xccdf_value_item value;
00222 struct xccdf_result_item result;
00223 } sub;
00224 };
00225
00226 struct xccdf_warning {
00227 struct oscap_text *text;
00228 xccdf_warning_category_t category;
00229 };
00230
00231 struct xccdf_notice {
00232 char *id;
00233 struct oscap_text *text;
00234 };
00235
00236 struct xccdf_status {
00237 xccdf_status_type_t status;
00238 time_t date;
00239 };
00240
00241 struct xccdf_model {
00242 char *system;
00243 struct oscap_htable *params;
00244 };
00245
00246 struct xccdf_select {
00247 char *item;
00248 bool selected;
00249 struct oscap_list *remarks;
00250 };
00251
00252 struct xccdf_refine_rule {
00253 char *item;
00254 char *selector;
00255 xccdf_role_t role;
00256 xccdf_level_t severity;
00257 xccdf_numeric weight;
00258 struct oscap_list *remarks;
00259 };
00260
00261 struct xccdf_refine_value {
00262 char *item;
00263 char *selector;
00264 xccdf_operator_t oper;
00265 struct oscap_list *remarks;
00266 };
00267
00268 struct xccdf_setvalue {
00269 char *item;
00270 char *value;
00271 };
00272
00273 struct xccdf_ident {
00274 char *id;
00275 char *system;
00276 };
00277
00278 struct xccdf_check {
00279 xccdf_bool_operator_t oper;
00280 struct oscap_list *children;
00281 char *id;
00282 char *system;
00283 char *selector;
00284 char *content;
00285 struct _xccdf_check_flags {
00286 bool multicheck:1;
00287 bool def_multicheck:1;
00288 bool negate:1;
00289 bool def_negate:1;
00290 } flags;
00291 struct oscap_list *imports;
00292 struct oscap_list *exports;
00293 struct oscap_list *content_refs;
00294 };
00295
00296 struct xccdf_check_content_ref {
00297 char *href;
00298 char *name;
00299 };
00300
00301 struct xccdf_check_import {
00302 char *name;
00303 char *xpath;
00304 char *content;
00305 };
00306
00307 struct xccdf_check_export {
00308 char *name;
00309 char *value;
00310 };
00311
00312 struct xccdf_profile_note {
00313 struct oscap_text *text;
00314 char *reftag;
00315 };
00316
00317 struct xccdf_fix {
00318 bool reboot;
00319 xccdf_strategy_t strategy;
00320 xccdf_level_t disruption;
00321 xccdf_level_t complexity;
00322 char *id;
00323 char *content;
00324 char *system;
00325 char *platform;
00326 };
00327
00328 struct xccdf_fixtext {
00329 struct oscap_text *text;
00330 bool reboot;
00331 xccdf_strategy_t strategy;
00332 xccdf_level_t disruption;
00333 xccdf_level_t complexity;
00334 char *fixref;
00335 };
00336
00337 struct xccdf_rule_result {
00338 char *idref;
00339 xccdf_role_t role;
00340 char *time;
00341 float weight;
00342 xccdf_level_t severity;
00343 xccdf_test_result_type_t result;
00344 char *version;
00345
00346 struct oscap_list *overrides;
00347 struct oscap_list *idents;
00348 struct oscap_list *messages;
00349 struct oscap_list *instances;
00350 struct oscap_list *fixes;
00351 struct oscap_list *checks;
00352 };
00353
00354 struct xccdf_identity {
00355 struct {
00356 bool authenticated : 1;
00357 bool privileged : 1;
00358 } sub;
00359 char *name;
00360 };
00361
00362 struct xccdf_score {
00363 xccdf_numeric maximum;
00364 xccdf_numeric score;
00365 char *system;
00366 };
00367
00368 struct xccdf_override {
00369 char *time;
00370 char *authority;
00371 xccdf_test_result_type_t old_result;
00372 xccdf_test_result_type_t new_result;
00373 struct oscap_text *remark;
00374 };
00375
00376 struct xccdf_message {
00377 xccdf_message_severity_t severity;
00378 char *content;
00379 };
00380
00381 struct xccdf_target_fact {
00382 xccdf_value_type_t type;
00383 char *name;
00384 char *value;
00385 };
00386
00387 struct xccdf_target_identifier {
00388 bool any_element;
00389
00390 xmlNodePtr element;
00391
00392 const char* system;
00393 const char* href;
00394 const char* name;
00395 };
00396
00397 struct xccdf_instance {
00398 char *context;
00399 char *parent_context;
00400 char *content;
00401 };
00402
00403 struct xccdf_plain_text {
00404 char *id;
00405 char *text;
00406 };
00407
00408 extern const struct oscap_string_map XCCDF_LEVEL_MAP[];
00409 extern const struct oscap_string_map XCCDF_ROLE_MAP[];
00410 extern const struct oscap_string_map XCCDF_OPERATOR_MAP[];
00411 extern const struct oscap_string_map XCCDF_STRATEGY_MAP[];
00412 extern const struct oscap_string_map XCCDF_FACT_TYPE_MAP[];
00413 extern const struct oscap_string_map XCCDF_RESULT_MAP[];
00414
00415 extern const struct oscap_text_traits XCCDF_TEXT_PLAIN;
00416 extern const struct oscap_text_traits XCCDF_TEXT_HTML;
00417 extern const struct oscap_text_traits XCCDF_TEXT_PLAINSUB;
00418 extern const struct oscap_text_traits XCCDF_TEXT_HTMLSUB;
00419 extern const struct oscap_text_traits XCCDF_TEXT_NOTICE;
00420 extern const struct oscap_text_traits XCCDF_TEXT_PROFNOTE;
00421
00422 extern const size_t XCCDF_NUMERIC_SIZE;
00423 extern const char *XCCDF_NUMERIC_FORMAT;
00424
00425 struct xccdf_item *xccdf_item_new(xccdf_type_t type, struct xccdf_item *parent);
00426 void xccdf_item_release(struct xccdf_item *item);
00427 void xccdf_item_print(struct xccdf_item *item, int depth);
00428 void xccdf_item_dump(struct xccdf_item *item, int depth);
00429 struct xccdf_item* xccdf_item_get_benchmark_internal(struct xccdf_item* item);
00430 bool xccdf_benchmark_parse(struct xccdf_item *benchmark, xmlTextReaderPtr reader);
00431 void xccdf_benchmark_dump(struct xccdf_benchmark *benchmark);
00432 struct oscap_htable_iterator *xccdf_benchmark_get_cluster_items(struct xccdf_benchmark *benchmark, const char *cluster_id);
00433 bool xccdf_benchmark_register_item(struct xccdf_benchmark *benchmark, struct xccdf_item *item);
00434 bool xccdf_benchmark_unregister_item(struct xccdf_item *item);
00435 bool xccdf_benchmark_rename_item(struct xccdf_item *item, const char *newid);
00436 char *xccdf_benchmark_gen_id(struct xccdf_benchmark *benchmark, xccdf_type_t type, const char *prefix);
00437 struct xccdf_profile *xccdf_benchmark_get_profile_by_id(struct xccdf_benchmark *benchmark, const char *profile_id);
00438 struct xccdf_result *xccdf_benchmark_get_result_by_id(struct xccdf_benchmark *benchmark, const char *testresult_id);
00439 bool xccdf_add_item(struct oscap_list *list, struct xccdf_item *parent, struct xccdf_item *item, const char *prefix);
00440
00441 struct xccdf_tailoring *xccdf_tailoring_new(void);
00442 void xccdf_tailoring_free(struct xccdf_tailoring *tailoring);
00443 struct xccdf_tailoring *xccdf_tailoring_parse(xmlTextReaderPtr reader, struct xccdf_item* benchmark);
00444 xmlNodePtr xccdf_tailoring_to_dom(struct xccdf_tailoring *tailoring, xmlDocPtr doc, xmlNodePtr parent, const struct xccdf_version_info *version_info);
00445
00446 struct xccdf_item *xccdf_profile_new_internal(struct xccdf_item *bench);
00447 struct xccdf_item *xccdf_profile_parse(xmlTextReaderPtr reader, struct xccdf_item *bench);
00448 void xccdf_profile_dump(struct xccdf_item *prof, int depth);
00449
00450 bool xccdf_item_process_attributes(struct xccdf_item *item, xmlTextReaderPtr reader);
00451 bool xccdf_item_process_element(struct xccdf_item *item, xmlTextReaderPtr reader);
00452
00453 bool xccdf_content_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00454 struct xccdf_item *xccdf_group_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00455 struct xccdf_item *xccdf_group_new_internal(struct xccdf_item *parent);
00456 void xccdf_group_dump(struct xccdf_item *group, int depth);
00457
00458 struct xccdf_item *xccdf_rule_new_internal(struct xccdf_item *parent);
00459 struct xccdf_item *xccdf_rule_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00460 void xccdf_rule_dump(struct xccdf_item *rule, int depth);
00461 struct xccdf_check_iterator *xccdf_rule_get_checks_filtered(struct xccdf_item *rule, char *selector);
00462 struct xccdf_check_iterator *xccdf_rule_get_complex_checks(struct xccdf_item *rule);
00463
00464 struct xccdf_item *xccdf_value_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00465 struct xccdf_item *xccdf_value_new_internal(struct xccdf_item *parent, xccdf_value_type_t type);
00466 void xccdf_value_dump(struct xccdf_item *value, int depth);
00467
00468 struct xccdf_notice *xccdf_notice_new_parse(xmlTextReaderPtr reader);
00469 void xccdf_notice_dump(struct xccdf_notice *notice, int depth);
00470
00471 void xccdf_status_dump(struct xccdf_status *status, int depth);
00472
00473 struct xccdf_model *xccdf_model_new_xml(xmlTextReaderPtr reader);
00474
00475 void xccdf_cstring_dump(const char *data, int depth);
00476 void xccdf_result_dump(struct xccdf_result *res, int depth);
00477 struct xccdf_result *xccdf_result_new_parse(xmlTextReaderPtr reader);
00478 int xccdf_rule_result_set_time_current(struct xccdf_rule_result *item);
00479 int xccdf_result_set_start_time_current(struct xccdf_result *item);
00480 int xccdf_result_set_end_time_current(struct xccdf_result *item);
00481
00482
00483 struct xccdf_check *xccdf_check_parse(xmlTextReaderPtr reader);
00484 void xccdf_check_dump(struct xccdf_check *check, int depth);
00485 bool xccdf_check_inject_content_ref(struct xccdf_check *check, const struct xccdf_check_content_ref *content, const char *name);
00486 void xccdf_check_content_ref_dump(struct xccdf_check_content_ref *ref, int depth);
00487 struct xccdf_ident *xccdf_ident_parse(xmlTextReaderPtr reader);
00488 void xccdf_ident_dump(struct xccdf_ident *ident, int depth);
00489 struct xccdf_fix *xccdf_fix_parse(xmlTextReaderPtr reader);
00490 struct xccdf_fixtext *xccdf_fixtext_parse(xmlTextReaderPtr reader);
00491
00492 struct xccdf_setvalue *xccdf_setvalue_new_parse(xmlTextReaderPtr reader);
00493 void xccdf_setvalue_dump(struct xccdf_setvalue *sv, int depth);
00494
00495 struct xccdf_warning *xccdf_warning_new_parse(xmlTextReaderPtr reader);
00496
00497
00498
00499 void xccdf_item_base_clone(struct xccdf_item_base *new_base, const struct xccdf_item_base *old_base);
00500
00501
00502 void xccdf_profile_item_clone(struct xccdf_profile_item *clone, const struct xccdf_profile_item * item);
00503 struct xccdf_benchmark_item * xccdf_benchmark_item_clone(struct xccdf_item *clone, const struct xccdf_benchmark * bench);
00504 void xccdf_rule_item_clone(struct xccdf_rule_item *clone, const struct xccdf_rule_item * item);
00505 void xccdf_group_item_clone(struct xccdf_item *parent, const struct xccdf_group_item * item);
00506 void xccdf_value_item_clone(struct xccdf_value_item *clone, const struct xccdf_value_item * item);
00507 struct xccdf_value_instance * xccdf_value_instance_clone(const struct xccdf_value_instance * val);
00508 void xccdf_result_item_clone(struct xccdf_result_item *clone, const struct xccdf_result_item * item);
00509 struct xccdf_profile_note * xccdf_profile_note_clone(const struct xccdf_profile_note * note);
00510 void xccdf_reparent_list(struct oscap_list * item_list, struct xccdf_item * parent);
00511 void xccdf_reparent_item(struct xccdf_item * item, struct xccdf_item * parent);
00512
00513 void xccdf_texts_to_dom(struct oscap_text_iterator *texts, xmlNode *parent, const char *elname);
00514
00515 #include "unused.h"
00516
00517 OSCAP_HIDDEN_END;
00518
00519 #endif