| 1 | /** |
| 2 | * @file variable_probe.c |
| 3 | * @brief variable probe |
| 4 | * @author "Tomas Heinrich" <[email protected]> |
| 5 | * |
| 6 | * This probe is able to process a variable_object as defined in OVAL 5.8. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 12 | * All Rights Reserved. |
| 13 | * |
| 14 | * This library is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU Lesser General Public |
| 16 | * License as published by the Free Software Foundation; either |
| 17 | * version 2.1 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This library is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * Lesser General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Lesser General Public |
| 25 | * License along with this library; if not, write to the Free Software |
| 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | * |
| 28 | * Authors: |
| 29 | * "Tomas Heinrich" <[email protected]> |
| 30 | */ |
| 31 | |
| 32 | /* |
| 33 | * variable probe |
| 34 | * |
| 35 | * reference: |
| 36 | * http://oval.mitre.org/language/version5.8/ovaldefinition/documentation/independent-definitions-schema.html#variable_object |
| 37 | */ |
| 38 | |
| 39 | #ifdef HAVE_CONFIG_H |
| 40 | #include <config.h> |
| 41 | #endif |
| 42 | |
| 43 | #include <stdlib.h> |
| 44 | #include <string.h> |
| 45 | #include <stdio.h> |
| 46 | #include <errno.h> |
| 47 | |
| 48 | #include <probe/probe.h> |
| 49 | #include <probe/option.h> |
| 50 | #include "_seap.h" |
| 51 | #include "probe-api.h" |
| 52 | #include "probe/entcmp.h" |
| 53 | #include "variable_probe.h" |
| 54 | |
| 55 | int variable_probe_offline_mode_supported() |
| 56 | { |
| 57 | return PROBE_OFFLINE_ALL; |
| 58 | } |
| 59 | |
| 60 | int variable_probe_main(probe_ctx *ctx, void *arg) |
| 61 | { |
| 62 | SEXP_t *probe_in, *vr_ent, *sid, *sval, *svallst, *item; |
| 63 | |
| 64 | probe_in = probe_ctx_getobject(ctx); |
| 65 | vr_ent = probe_obj_getent(probe_in, "var_ref", 1); |
| 66 | sid = probe_ent_getattrval(vr_ent, "var_ref"); |
| 67 | probe_ent_getvals(vr_ent, &svallst); |
| 68 | |
| 69 | item = probe_item_create(OVAL_INDEPENDENT_VARIABLE, NULL, |
| 70 | "var_ref", OVAL_DATATYPE_SEXP, sid, |
| 71 | NULL); |
| 72 | |
| 73 | SEXP_list_foreach(sval, svallst) |
| 74 | probe_item_ent_add(item, "value", NULL, sval); |
| 75 | |
| 76 | probe_item_collect(ctx, item); |
| 77 | SEXP_free(vr_ent); |
| 78 | SEXP_free(sid); |
| 79 | SEXP_free(svallst); |
| 80 | |
| 81 | return 0; |
| 82 | } |