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