From: Jason Ish Date: Tue, 17 Mar 2015 04:29:22 +0000 (-0600) Subject: Bug 1417 - Record sequence nodes as sequences. X-Git-Tag: suricata-2.1beta4~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1380%2Fhead;p=thirdparty%2Fsuricata.git Bug 1417 - Record sequence nodes as sequences. 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. --- diff --git a/src/conf-yaml-loader.c b/src/conf-yaml-loader.c index 8e87307943..49ee6540d1 100644 --- a/src/conf-yaml-loader.c +++ b/src/conf-yaml-loader.c @@ -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);