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