@@ -73,11 +73,42 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, uns
73
73
yaml_event_t event ;
74
74
bool done = false;
75
75
76
+ bool sequence = false;
76
77
do {
77
78
if (yaml_parser_parse (& parser , & event )) {
78
79
done = (event .type == YAML_STREAM_END_EVENT );
79
80
if (yaml_path_filter_event (yaml_path , & parser , & event ,
80
81
YAML_PATH_FILTER_RETURN_ALL )) {
82
+
83
+ if (sequence ) {
84
+ if (event .type == YAML_SEQUENCE_END_EVENT ) {
85
+ sequence = false;
86
+ } else if (event .type != YAML_SCALAR_EVENT ) {
87
+ SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
88
+ "YAML path '%s' contains non-scalar in a sequence." ,
89
+ yaml_path_cstr );
90
+ probe_cobj_add_msg (probe_ctx_getresult (ctx ), msg );
91
+ SEXP_free (msg );
92
+ probe_cobj_set_flag (probe_ctx_getresult (ctx ), SYSCHAR_FLAG_ERROR );
93
+ ret = -1 ;
94
+ goto cleanup ;
95
+ }
96
+ } else {
97
+ if (event .type == YAML_SEQUENCE_START_EVENT ) {
98
+ sequence = true;
99
+ }
100
+ if (event .type == YAML_MAPPING_START_EVENT ) {
101
+ SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
102
+ "YAML path '%s' matches a mapping." ,
103
+ yaml_path_cstr );
104
+ probe_cobj_add_msg (probe_ctx_getresult (ctx ), msg );
105
+ SEXP_free (msg );
106
+ probe_cobj_set_flag (probe_ctx_getresult (ctx ), SYSCHAR_FLAG_ERROR );
107
+ ret = -1 ;
108
+ goto cleanup ;
109
+ }
110
+ }
111
+
81
112
if (!yaml_emitter_emit (& emitter , & event )) {
82
113
SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
83
114
"YAML emitter error: yaml_emitter_emit returned 0: %s" ,
0 commit comments