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