]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Bug 1417 - Record sequence nodes as sequences. 1380/head
authorJason Ish <ish@unx.ca>
Tue, 17 Mar 2015 04:29:22 +0000 (22:29 -0600)
committerJason Ish <ish@unx.ca>
Tue, 17 Mar 2015 04:30:55 +0000 (22:30 -0600)
Nodes that are sequences weren't being recorded as such, causing
rules to fail to load.

Change sequence test name to reflect better what it tests, and
test that the sequence node is detected as a sequence.

src/conf-yaml-loader.c

index 8e873079432fae01e6aa915a55164b998ec68962..49ee6540d1c7076397a4b078174ac788f5cbc23b 100644 (file)
@@ -310,6 +310,7 @@ ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq)
             SCLogDebug("event.type=YAML_SEQUENCE_START_EVENT; state=%d", state);
             if (ConfYamlParse(parser, node, 1) != 0)
                 goto fail;
+            node->is_seq = 1;
             state = CONF_KEY;
         }
         else if (event.type == YAML_SEQUENCE_END_EVENT) {
@@ -451,7 +452,7 @@ ConfYamlLoadString(const char *string, size_t len)
 #ifdef UNITTESTS
 
 static int
-ConfYamlRuleFileTest(void)
+ConfYamlSequenceTest(void)
 {
     char input[] = "\
 %YAML 1.1\n\
@@ -472,6 +473,8 @@ default-log-dir: /tmp\n\
     node = ConfGetNode("rule-files");
     if (node == NULL)
         return 0;
+    if (!ConfNodeIsSequence(node))
+        return 0;
     if (TAILQ_EMPTY(&node->head))
         return 0;
     int i = 0;
@@ -480,10 +483,16 @@ default-log-dir: /tmp\n\
         if (i == 0) {
             if (strcmp(filename->val, "netbios.rules") != 0)
                 return 0;
+            if (ConfNodeIsSequence(filename))
+                return 0;
+            if (filename->is_seq != 0)
+                return 0;
         }
         else if (i == 1) {
             if (strcmp(filename->val, "x11.rules") != 0)
                 return 0;
+            if (ConfNodeIsSequence(filename))
+                return 0;
         }
         else {
             return 0;
@@ -864,7 +873,7 @@ void
 ConfYamlRegisterTests(void)
 {
 #ifdef UNITTESTS
-    UtRegisterTest("ConfYamlRuleFileTest", ConfYamlRuleFileTest, 1);
+    UtRegisterTest("ConfYamlSequenceTest", ConfYamlSequenceTest, 1);
     UtRegisterTest("ConfYamlLoggingOutputTest", ConfYamlLoggingOutputTest, 1);
     UtRegisterTest("ConfYamlNonYamlFileTest", ConfYamlNonYamlFileTest, 1);
     UtRegisterTest("ConfYamlBadYamlVersionTest", ConfYamlBadYamlVersionTest, 1);