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 const struct xccdf_version_info *schema_version;
00143
00144 char *start_time;
00145 char *end_time;
00146 char *test_system;
00147 char *benchmark_uri;
00148 char *profile;
00149
00150 struct oscap_list *identities;
00151 struct oscap_list *targets;
00152 struct oscap_list *organizations;
00153 struct oscap_list *remarks;
00154 struct oscap_list *target_addresses;
00155 struct oscap_list *target_facts;
00156 struct oscap_list *target_id_refs;
00157 struct oscap_list *applicable_platforms;
00158 struct oscap_list *setvalues;
00159 struct oscap_list *rule_results;
00160 struct oscap_list *scores;
00161 };
00162
00163 struct xccdf_profile_item {
00164 char *note_tag;
00165 struct oscap_list *selects;
00166 struct oscap_list *setvalues;
00167 struct oscap_list *refine_values;
00168 struct oscap_list *refine_rules;
00169 bool tailoring;
00170 };
00171
00172 struct xccdf_tailoring {
00173
00174 char *id;
00175
00176
00177
00178 char *benchmark_ref;
00179
00180 char *benchmark_ref_version;
00181
00182 struct oscap_list *statuses;
00183 struct oscap_list *dc_statuses;
00184
00185 char *version;
00186 char *version_update;
00187 char *version_time;
00188
00189 struct oscap_list *metadata;
00190
00191 struct oscap_list *profiles;
00192 };
00193
00194 struct xccdf_benchmark_item {
00195 const struct xccdf_version_info *schema_version;
00196
00197 struct oscap_htable *items_dict;
00198 struct oscap_htable *profiles_dict;
00199 struct oscap_htable *results_dict;
00200 struct oscap_htable *clusters_dict;
00201 struct oscap_list *notices;
00202 struct oscap_list *plain_texts;
00203
00204 struct cpe_dict_model *cpe_list;
00205 struct cpe_lang_model *cpe_lang_model;
00206
00207 char *style;
00208 char *style_href;
00209 char *lang;
00210
00211 struct oscap_list *front_matter;
00212 struct oscap_list *rear_matter;
00213
00214 struct oscap_list *models;
00215 struct oscap_list *profiles;
00216 struct oscap_list *values;
00217 struct oscap_list *content;
00218 struct oscap_list *results;
00219 };
00220
00221 struct xccdf_item {
00222 xccdf_type_t type;
00223 struct xccdf_item_base item;
00224 union {
00225 struct xccdf_profile_item profile;
00226 struct xccdf_benchmark_item benchmark;
00227 struct xccdf_rule_item rule;
00228 struct xccdf_group_item group;
00229 struct xccdf_value_item value;
00230 struct xccdf_result_item result;
00231 } sub;
00232 };
00233
00234 struct xccdf_warning {
00235 struct oscap_text *text;
00236 xccdf_warning_category_t category;
00237 };
00238
00239 struct xccdf_notice {
00240 char *id;
00241 struct oscap_text *text;
00242 };
00243
00244 struct xccdf_status {
00245 xccdf_status_type_t status;
00246 time_t date;
00247 };
00248
00249 struct xccdf_model {
00250 char *system;
00251 struct oscap_htable *params;
00252 };
00253
00254 struct xccdf_select {
00255 char *item;
00256 bool selected;
00257 struct oscap_list *remarks;
00258 };
00259
00260 struct xccdf_refine_rule {
00261 char *item;
00262 char *selector;
00263 xccdf_role_t role;
00264 xccdf_level_t severity;
00265 xccdf_numeric weight;
00266 struct oscap_list *remarks;
00267 };
00268
00269 struct xccdf_refine_value {
00270 char *item;
00271 char *selector;
00272 xccdf_operator_t oper;
00273 struct oscap_list *remarks;
00274 };
00275
00276 struct xccdf_setvalue {
00277 char *item;
00278 char *value;
00279 };
00280
00281 struct xccdf_ident {
00282 char *id;
00283 char *system;
00284 };
00285
00286 struct xccdf_check {
00287 xccdf_bool_operator_t oper;
00288 struct oscap_list *children;
00289 char *id;
00290 char *system;
00291 char *selector;
00292 char *content;
00293 struct _xccdf_check_flags {
00294 bool multicheck:1;
00295 bool def_multicheck:1;
00296 bool negate:1;
00297 bool def_negate:1;
00298 } flags;
00299 struct oscap_list *imports;
00300 struct oscap_list *exports;
00301 struct oscap_list *content_refs;
00302 };
00303
00304 struct xccdf_check_content_ref {
00305 char *href;
00306 char *name;
00307 };
00308
00309 struct xccdf_check_import {
00310 char *name;
00311 char *xpath;
00312 char *content;
00313 };
00314
00315 struct xccdf_check_export {
00316 char *name;
00317 char *value;
00318 };
00319
00320 struct xccdf_profile_note {
00321 struct oscap_text *text;
00322 char *reftag;
00323 };
00324
00325 struct xccdf_fix {
00326 bool reboot;
00327 xccdf_strategy_t strategy;
00328 xccdf_level_t disruption;
00329 xccdf_level_t complexity;
00330 char *id;
00331 char *content;
00332 char *system;
00333 char *platform;
00334 };
00335
00336 struct xccdf_fixtext {
00337 struct oscap_text *text;
00338 bool reboot;
00339 xccdf_strategy_t strategy;
00340 xccdf_level_t disruption;
00341 xccdf_level_t complexity;
00342 char *fixref;
00343 };
00344
00345 struct xccdf_rule_result {
00346 char *idref;
00347 xccdf_role_t role;
00348 char *time;
00349 float weight;
00350 xccdf_level_t severity;
00351 xccdf_test_result_type_t result;
00352 char *version;
00353
00354 struct oscap_list *overrides;
00355 struct oscap_list *idents;
00356 struct oscap_list *messages;
00357 struct oscap_list *instances;
00358 struct oscap_list *fixes;
00359 struct oscap_list *checks;
00360 };
00361
00362 struct xccdf_identity {
00363 struct {
00364 bool authenticated : 1;
00365 bool privileged : 1;
00366 } sub;
00367 char *name;
00368 };
00369
00370 struct xccdf_score {
00371 xccdf_numeric maximum;
00372 xccdf_numeric score;
00373 char *system;
00374 };
00375
00376 struct xccdf_override {
00377 char *time;
00378 char *authority;
00379 xccdf_test_result_type_t old_result;
00380 xccdf_test_result_type_t new_result;
00381 struct oscap_text *remark;
00382 };
00383
00384 struct xccdf_message {
00385 xccdf_message_severity_t severity;
00386 char *content;
00387 };
00388
00389 struct xccdf_target_fact {
00390 xccdf_value_type_t type;
00391 char *name;
00392 char *value;
00393 };
00394
00395 struct xccdf_target_identifier {
00396 bool any_element;
00397
00398 xmlNodePtr element;
00399
00400 char *system;
00401 char *href;
00402 char *name;
00403 };
00404
00405 struct xccdf_instance {
00406 char *context;
00407 char *parent_context;
00408 char *content;
00409 };
00410
00411 struct xccdf_plain_text {
00412 char *id;
00413 char *text;
00414 };
00415
00416 extern const struct oscap_string_map XCCDF_LEVEL_MAP[];
00417 extern const struct oscap_string_map XCCDF_ROLE_MAP[];
00418 extern const struct oscap_string_map XCCDF_OPERATOR_MAP[];
00419 extern const struct oscap_string_map XCCDF_BOOLOP_MAP[];
00420 extern const struct oscap_string_map XCCDF_STRATEGY_MAP[];
00421 extern const struct oscap_string_map XCCDF_FACT_TYPE_MAP[];
00422 extern const struct oscap_string_map XCCDF_RESULT_MAP[];
00423
00424 extern const struct oscap_text_traits XCCDF_TEXT_PLAIN;
00425 extern const struct oscap_text_traits XCCDF_TEXT_HTML;
00426 extern const struct oscap_text_traits XCCDF_TEXT_PLAINSUB;
00427 extern const struct oscap_text_traits XCCDF_TEXT_HTMLSUB;
00428 extern const struct oscap_text_traits XCCDF_TEXT_NOTICE;
00429 extern const struct oscap_text_traits XCCDF_TEXT_PROFNOTE;
00430
00431 extern const size_t XCCDF_NUMERIC_SIZE;
00432 extern const char *XCCDF_NUMERIC_FORMAT;
00433
00434 struct xccdf_item *xccdf_item_new(xccdf_type_t type, struct xccdf_item *parent);
00435 void xccdf_item_release(struct xccdf_item *item);
00436 void xccdf_item_print(struct xccdf_item *item, int depth);
00437 void xccdf_item_dump(struct xccdf_item *item, int depth);
00438 struct xccdf_item* xccdf_item_get_benchmark_internal(struct xccdf_item* item);
00439 bool xccdf_benchmark_parse(struct xccdf_item *benchmark, xmlTextReaderPtr reader);
00440 void xccdf_benchmark_dump(struct xccdf_benchmark *benchmark);
00441 struct oscap_htable_iterator *xccdf_benchmark_get_cluster_items(struct xccdf_benchmark *benchmark, const char *cluster_id);
00442 bool xccdf_benchmark_register_item(struct xccdf_benchmark *benchmark, struct xccdf_item *item);
00443 bool xccdf_benchmark_unregister_item(struct xccdf_item *item);
00444 bool xccdf_benchmark_rename_item(struct xccdf_item *item, const char *newid);
00445 char *xccdf_benchmark_gen_id(struct xccdf_benchmark *benchmark, xccdf_type_t type, const char *prefix);
00446 struct xccdf_result *xccdf_benchmark_get_result_by_id(struct xccdf_benchmark *benchmark, const char *testresult_id);
00447 struct xccdf_result *xccdf_benchmark_get_result_by_id_suffix(struct xccdf_benchmark *benchmark, const char *testresult_suffix);
00448 bool xccdf_add_item(struct oscap_list *list, struct xccdf_item *parent, struct xccdf_item *item, const char *prefix);
00449
00450 struct xccdf_tailoring *xccdf_tailoring_parse(xmlTextReaderPtr reader, struct xccdf_item* benchmark);
00451 xmlNodePtr xccdf_tailoring_to_dom(struct xccdf_tailoring *tailoring, xmlDocPtr doc, xmlNodePtr parent, const struct xccdf_version_info *version_info);
00452
00453 struct xccdf_item *xccdf_profile_new_internal(struct xccdf_item *bench);
00454 struct xccdf_item *xccdf_profile_parse(xmlTextReaderPtr reader, struct xccdf_item *bench);
00455 void xccdf_profile_dump(struct xccdf_item *prof, int depth);
00456
00457 bool xccdf_item_process_attributes(struct xccdf_item *item, xmlTextReaderPtr reader);
00458 bool xccdf_item_process_element(struct xccdf_item *item, xmlTextReaderPtr reader);
00459
00460 bool xccdf_content_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00461 struct xccdf_item *xccdf_group_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00462 struct xccdf_item *xccdf_group_new_internal(struct xccdf_item *parent);
00463 void xccdf_group_dump(struct xccdf_item *group, int depth);
00464
00465 struct xccdf_item *xccdf_rule_new_internal(struct xccdf_item *parent);
00466 struct xccdf_item *xccdf_rule_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00467 void xccdf_rule_dump(struct xccdf_item *rule, int depth);
00468 struct xccdf_check_iterator *xccdf_rule_get_checks_filtered(struct xccdf_item *rule, char *selector);
00469 struct xccdf_check_iterator *xccdf_rule_get_complex_checks(struct xccdf_item *rule);
00470
00471 struct xccdf_item *xccdf_value_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00472 struct xccdf_item *xccdf_value_new_internal(struct xccdf_item *parent, xccdf_value_type_t type);
00473 void xccdf_value_dump(struct xccdf_item *value, int depth);
00474
00475 struct xccdf_notice *xccdf_notice_new_parse(xmlTextReaderPtr reader);
00476 void xccdf_notice_dump(struct xccdf_notice *notice, int depth);
00477
00478 void xccdf_status_dump(struct xccdf_status *status, int depth);
00479
00480 struct xccdf_model *xccdf_model_new_xml(xmlTextReaderPtr reader);
00481
00482 void xccdf_cstring_dump(const char *data, int depth);
00483 void xccdf_result_dump(struct xccdf_result *res, int depth);
00484 struct xccdf_result *xccdf_result_new_parse(xmlTextReaderPtr reader);
00485 int xccdf_rule_result_set_time_current(struct xccdf_rule_result *item);
00486 int xccdf_result_set_start_time_current(struct xccdf_result *item);
00487 int xccdf_result_set_end_time_current(struct xccdf_result *item);
00488 const struct xccdf_version_info* xccdf_result_get_schema_version(const struct xccdf_result *item);
00489 bool xccdf_result_set_schema_version(struct xccdf_result *item, const struct xccdf_version_info* newval);
00490
00491
00492 struct xccdf_check *xccdf_check_parse(xmlTextReaderPtr reader);
00493 void xccdf_check_dump(struct xccdf_check *check, int depth);
00494 bool xccdf_check_inject_content_ref(struct xccdf_check *check, const struct xccdf_check_content_ref *content, const char *name);
00495 void xccdf_check_content_ref_dump(struct xccdf_check_content_ref *ref, int depth);
00496 struct xccdf_ident *xccdf_ident_parse(xmlTextReaderPtr reader);
00497 void xccdf_ident_dump(struct xccdf_ident *ident, int depth);
00498 struct xccdf_fix *xccdf_fix_parse(xmlTextReaderPtr reader);
00499 struct xccdf_fixtext *xccdf_fixtext_parse(xmlTextReaderPtr reader);
00500
00501 struct xccdf_setvalue *xccdf_setvalue_new_parse(xmlTextReaderPtr reader);
00502 void xccdf_setvalue_dump(struct xccdf_setvalue *sv, int depth);
00503
00504 struct xccdf_warning *xccdf_warning_new_parse(xmlTextReaderPtr reader);
00505
00506
00507
00508 void xccdf_item_base_clone(struct xccdf_item_base *new_base, const struct xccdf_item_base *old_base);
00509
00510
00511 void xccdf_profile_item_clone(struct xccdf_profile_item *clone, const struct xccdf_profile_item * item);
00512 struct xccdf_benchmark_item * xccdf_benchmark_item_clone(struct xccdf_item *clone, const struct xccdf_benchmark * bench);
00513 void xccdf_rule_item_clone(struct xccdf_rule_item *clone, const struct xccdf_rule_item * item);
00514 void xccdf_group_item_clone(struct xccdf_item *parent, const struct xccdf_group_item * item);
00515 void xccdf_value_item_clone(struct xccdf_value_item *clone, const struct xccdf_value_item * item);
00516 struct xccdf_value_instance * xccdf_value_instance_clone(const struct xccdf_value_instance * val);
00517 void xccdf_result_item_clone(struct xccdf_result_item *clone, const struct xccdf_result_item * item);
00518 struct xccdf_profile_note * xccdf_profile_note_clone(const struct xccdf_profile_note * note);
00519 void xccdf_reparent_list(struct oscap_list * item_list, struct xccdf_item * parent);
00520 void xccdf_reparent_item(struct xccdf_item * item, struct xccdf_item * parent);
00521
00522 void xccdf_texts_to_dom(struct oscap_text_iterator *texts, xmlNode *parent, const char *elname);
00523
00524 #include "unused.h"
00525
00526 OSCAP_HIDDEN_END;
00527
00528 #endif