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