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 struct xccdf_value_val {
00102 union xccdf_value_unit value;
00103 union xccdf_value_unit defval;
00104 struct oscap_list *choices;
00105 bool must_match;
00106 union {
00107 struct {
00108 xccdf_numeric lower_bound;
00109 xccdf_numeric upper_bound;
00110 } n;
00111 struct {
00112 char *match;
00113 } s;
00114 } limits;
00115 };
00116
00117 struct xccdf_value_item {
00118 xccdf_value_type_t type;
00119 xccdf_interface_hint_t interface_hint;
00120 xccdf_operator_t oper;
00121 char *selector;
00122
00123 struct xccdf_value_val *value;
00124 struct oscap_htable *values;
00125
00126 struct oscap_list *sources;
00127 };
00128
00129 struct xccdf_result_item {
00130 time_t start_time;
00131 time_t end_time;
00132 char *test_system;
00133 char *benchmark_uri;
00134 char *profile;
00135
00136 struct oscap_list *identities;
00137 struct oscap_list *targets;
00138 struct oscap_list *organizations;
00139 struct oscap_list *remarks;
00140 struct oscap_list *target_addresses;
00141 struct oscap_list *target_facts;
00142 struct oscap_list *setvalues;
00143 struct oscap_list *rule_results;
00144 struct oscap_list *scores;
00145 };
00146
00147 struct xccdf_profile_item {
00148 char *note_tag;
00149 struct oscap_list *selects;
00150 struct oscap_list *setvalues;
00151 struct oscap_list *refine_values;
00152 struct oscap_list *refine_rules;
00153 };
00154
00155 struct xccdf_benchmark_item {
00156
00157 struct oscap_htable *dict;
00158 struct oscap_list *notices;
00159 struct oscap_htable *plain_texts;
00160
00161 char *style;
00162 char *style_href;
00163 char *metadata;
00164
00165 struct oscap_list *front_matter;
00166 struct oscap_list *rear_matter;
00167
00168 struct oscap_list *models;
00169 struct oscap_list *profiles;
00170 struct oscap_list *values;
00171 struct oscap_list *content;
00172 struct oscap_list *results;
00173 };
00174
00175 struct xccdf_item {
00176 xccdf_type_t type;
00177 struct xccdf_item_base item;
00178 union {
00179 struct xccdf_profile_item profile;
00180 struct xccdf_benchmark_item bench;
00181 struct xccdf_rule_item rule;
00182 struct xccdf_group_item group;
00183 struct xccdf_value_item value;
00184 struct xccdf_result_item result;
00185 } sub;
00186 };
00187
00188 struct xccdf_warning {
00189 struct oscap_text *text;
00190 xccdf_warning_category_t category;
00191 };
00192
00193 struct xccdf_notice {
00194 char *id;
00195 struct oscap_text *text;
00196 };
00197
00198 struct xccdf_status {
00199 xccdf_status_type_t status;
00200 time_t date;
00201 };
00202
00203 struct xccdf_model {
00204 char *system;
00205 struct oscap_htable *params;
00206 };
00207
00208 struct xccdf_select {
00209 char *item;
00210 bool selected;
00211 struct oscap_list *remarks;
00212 };
00213
00214 struct xccdf_refine_rule {
00215 char *item;
00216 char *selector;
00217 xccdf_role_t role;
00218 xccdf_level_t severity;
00219 float weight;
00220 struct oscap_list *remarks;
00221 };
00222
00223 struct xccdf_refine_value {
00224 char *item;
00225 char *selector;
00226 xccdf_operator_t oper;
00227 struct oscap_list *remarks;
00228 };
00229
00230 struct xccdf_setvalue {
00231 char *item;
00232 char *value;
00233 };
00234
00235 struct xccdf_ident {
00236 char *id;
00237 char *system;
00238 };
00239
00240 struct xccdf_check {
00241 xccdf_bool_operator_t oper;
00242 struct oscap_list *children;
00243 struct xccdf_item *parent;
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 extern const struct oscap_string_map XCCDF_LEVEL_MAP[];
00357 extern const struct oscap_string_map XCCDF_ROLE_MAP[];
00358 extern const struct oscap_string_map XCCDF_OPERATOR_MAP[];
00359 extern const struct oscap_string_map XCCDF_STRATEGY_MAP[];
00360 extern const struct oscap_string_map XCCDF_FACT_TYPE_MAP[];
00361 extern const struct oscap_string_map XCCDF_RESULT_MAP[];
00362
00363 extern const struct oscap_text_traits XCCDF_TEXT_PLAIN;
00364 extern const struct oscap_text_traits XCCDF_TEXT_HTML;
00365 extern const struct oscap_text_traits XCCDF_TEXT_PLAINSUB;
00366 extern const struct oscap_text_traits XCCDF_TEXT_HTMLSUB;
00367 extern const struct oscap_text_traits XCCDF_TEXT_NOTICE;
00368 extern const struct oscap_text_traits XCCDF_TEXT_PROFNOTE;
00369
00370 extern const size_t XCCDF_NUMERIC_SIZE;
00371 extern const char *XCCDF_NUMERIC_FORMAT;
00372
00373 struct xccdf_item *xccdf_item_new(xccdf_type_t type, struct xccdf_item *parent);
00374 void xccdf_item_release(struct xccdf_item *item);
00375 void xccdf_item_print(struct xccdf_item *item, int depth);
00376 void xccdf_item_dump(struct xccdf_item *item, int depth);
00377 struct xccdf_item* xccdf_item_get_benchmark_internal(struct xccdf_item* item);
00378
00379 struct xccdf_item *xccdf_benchmark_new(void);
00380 bool xccdf_benchmark_parse(struct xccdf_item *benchmark, xmlTextReaderPtr reader);
00381 void xccdf_benchmark_dump(struct xccdf_benchmark *benchmark);
00382 bool xccdf_benchmark_register_item(struct xccdf_benchmark *benchmark, struct xccdf_item *item);
00383 bool xccdf_benchmark_unregister_item(struct xccdf_item *item);
00384 bool xccdf_benchmark_rename_item(struct xccdf_item *item, const char *newid);
00385 char *xccdf_benchmark_gen_id(struct xccdf_benchmark *benchmark, const char *prefix);
00386 bool xccdf_add_item(struct oscap_list *list, struct xccdf_item *parent, struct xccdf_item *item, const char *prefix);
00387
00388 struct xccdf_item *xccdf_profile_new(struct xccdf_item *bench);
00389 struct xccdf_item *xccdf_profile_parse(xmlTextReaderPtr reader, struct xccdf_item *bench);
00390 void xccdf_profile_dump(struct xccdf_item *prof, int depth);
00391 void xccdf_profile_free(struct xccdf_item *prof);
00392
00393 bool xccdf_item_process_attributes(struct xccdf_item *item, xmlTextReaderPtr reader);
00394 bool xccdf_item_process_element(struct xccdf_item *item, xmlTextReaderPtr reader);
00395
00396 bool xccdf_content_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00397 struct xccdf_item *xccdf_group_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00398 struct xccdf_item *xccdf_group_new(struct xccdf_item *parent);
00399 void xccdf_group_dump(struct xccdf_item *group, int depth);
00400 void xccdf_group_free(struct xccdf_item *group);
00401
00402 struct xccdf_item *xccdf_rule_new(struct xccdf_item *parent);
00403 struct xccdf_item *xccdf_rule_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00404 void xccdf_rule_dump(struct xccdf_item *rule, int depth);
00405 void xccdf_rule_free(struct xccdf_item *rule);
00406
00407 struct xccdf_item *xccdf_value_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00408 struct xccdf_item *xccdf_value_new(struct xccdf_item *parent, xccdf_value_type_t type);
00409 void xccdf_value_dump(struct xccdf_item *value, int depth);
00410 void xccdf_value_free(struct xccdf_item *val);
00411
00412 struct xccdf_notice *xccdf_notice_new(void);
00413 struct xccdf_notice *xccdf_notice_new_parse(xmlTextReaderPtr reader);
00414 void xccdf_notice_dump(struct xccdf_notice *notice, int depth);
00415 void xccdf_notice_free(struct xccdf_notice *notice);
00416
00417 struct xccdf_status *xccdf_status_new(const char *status, const char *date);
00418 void xccdf_status_dump(struct xccdf_status *status, int depth);
00419 void xccdf_status_free(struct xccdf_status *status);
00420
00421 struct xccdf_model *xccdf_model_new_xml(xmlTextReaderPtr reader);
00422 void xccdf_model_free(struct xccdf_model *model);
00423
00424 void xccdf_cstring_dump(const char *data, int depth);
00425 void xccdf_result_dump(struct xccdf_result *res, int depth);
00426 struct xccdf_result *xccdf_result_new_parse(xmlTextReaderPtr reader);
00427
00428 struct xccdf_ident *xccdf_ident_new(const char *id, const char *system);
00429 void xccdf_ident_free(struct xccdf_ident *ident);
00430
00431 struct xccdf_check *xccdf_check_new(struct xccdf_item *parent);
00432 struct xccdf_check *xccdf_check_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00433 void xccdf_check_dump(struct xccdf_check *check, int depth);
00434 void xccdf_check_free(struct xccdf_check *check);
00435 void xccdf_check_content_ref_free(struct xccdf_check_content_ref *ref);
00436 void xccdf_check_content_ref_dump(struct xccdf_check_content_ref *ref, int depth);
00437 struct xccdf_ident *xccdf_ident_new(const char *id, const char *system);
00438 struct xccdf_ident *xccdf_ident_parse(xmlTextReaderPtr reader);
00439 void xccdf_ident_dump(struct xccdf_ident *ident, int depth);
00440 void xccdf_ident_free(struct xccdf_ident *ident);
00441 void xccdf_profile_note_free(struct xccdf_profile_note *note);
00442 void xccdf_check_import_free(struct xccdf_check_import *item);
00443 void xccdf_check_export_free(struct xccdf_check_export *item);
00444 struct xccdf_fix *xccdf_fix_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00445 struct xccdf_fixtext *xccdf_fixtext_parse(xmlTextReaderPtr reader, struct xccdf_item *parent);
00446 void xccdf_fixtext_free(struct xccdf_fixtext *item);
00447 void xccdf_fix_free(struct xccdf_fix *item);
00448
00449
00450 struct xccdf_refine_value *xccdf_refine_value_new(void);
00451 struct xccdf_refine_rule *xccdf_refine_rule_new(void);
00452 struct xccdf_setvalue *xccdf_setvalue_new(void);
00453 struct xccdf_setvalue *xccdf_setvalue_new_parse(xmlTextReaderPtr reader);
00454 void xccdf_setvalue_dump(struct xccdf_setvalue *sv, int depth);
00455
00456 struct xccdf_warning *xccdf_warning_new(void);
00457 struct xccdf_warning *xccdf_warning_new_parse(xmlTextReaderPtr reader);
00458 void xccdf_warning_free(struct xccdf_warning * warn);
00459
00460 struct xccdf_reference *xccdf_reference_new(void);
00461 struct xccdf_reference *xccdf_reference_new_parse(xmlTextReaderPtr reader);
00462 void xccdf_reference_free(struct xccdf_reference * ref);
00463
00464 #include "unused.h"
00465
00466 OSCAP_HIDDEN_END;
00467
00468 #endif