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