Skip to content

Commit 42337d4

Browse files
committed
Process lists correctly
Creates multiple value_of elements within a single yamlfilecontent_item element instead of creating multiple yamlfilecontent_item elements containing single value_of elements. According to the schema proposal the value_of element can occur 0 to unbounded times. Also, this behavior is consistent with xmlfilecontent probe.
1 parent 728938b commit 42337d4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/OVAL/probes/independent/yamlfilecontent_probe.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,26 @@ static int process_yaml_file(const char *prefix, const char *path, const char *f
143143
}
144144

145145
struct oscap_iterator *values_it = oscap_iterator_new(values);
146-
while (oscap_iterator_has_more(values_it)) {
147-
char *value = oscap_iterator_next(values_it);
148-
/* TODO: type conversion of 'value' data */
149-
146+
if (oscap_iterator_has_more(values_it)) {
150147
SEXP_t *item = probe_item_create(
151148
OVAL_INDEPENDENT_YAML_FILE_CONTENT,
152149
NULL,
153150
"filepath", OVAL_DATATYPE_STRING, filepath,
154151
"path", OVAL_DATATYPE_STRING, path,
155152
"filename", OVAL_DATATYPE_STRING, filename,
156153
"yamlpath", OVAL_DATATYPE_STRING, yamlpath,
157-
"value_of", OVAL_DATATYPE_STRING, value,
158154
/*
159155
"windows_view",
160156
*/
161157
NULL
162158
);
159+
while (oscap_iterator_has_more(values_it)) {
160+
char *value = oscap_iterator_next(values_it);
161+
/* TODO: type conversion of 'value' data */
162+
SEXP_t *value_sexp = SEXP_string_new(value, strlen(value));
163+
probe_item_ent_add(item, "value_of", NULL, value_sexp);
164+
SEXP_free(value_sexp);
165+
}
163166
probe_item_collect(ctx, item);
164167
}
165168
oscap_iterator_free(values_it);

0 commit comments

Comments
 (0)