]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/dns: don't log warning if dns log version not set
authorJason Ish <jason.ish@oisf.net>
Wed, 16 Oct 2019 15:03:14 +0000 (09:03 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 17 Oct 2019 09:30:41 +0000 (11:30 +0200)
If the DNS log version is not set, we default to v2. This should
not be warning, but better logged at the config level.

A warning will still be logged if the value is set but is not
1 or 2.

src/output-json-dns.c

index 676866b7503e2027caefc4ada54da2e5fc413613..4045c97da39bee541ed974ee34aecda38c01442a 100644 (file)
@@ -510,28 +510,36 @@ static DnsVersion JsonDnsParseVersion(ConfNode *conf)
 
     DnsVersion version = DNS_VERSION_DEFAULT;
     intmax_t config_version;
-    if (ConfGetChildValueInt(conf, "version", &config_version)) {
-        switch(config_version) {
-            case 1:
-                version = DNS_VERSION_1;
-                break;
-            case 2:
-                version = DNS_VERSION_2;
-                break;
-            default:
-                SCLogWarning(SC_ERR_INVALID_ARGUMENT,
-                        "invalid eve-log dns version option: %"PRIuMAX", "
-                        "forcing it to version %u",
-                        config_version, DNS_VERSION_DEFAULT);
-                version = DNS_VERSION_DEFAULT;
-                break;
+    const ConfNode *has_version = ConfNodeLookupChild(conf, "version");
+
+    if (has_version != NULL) {
+        bool invalid = false;
+        if (ConfGetChildValueInt(conf, "version", &config_version)) {
+            switch(config_version) {
+                case 1:
+                    version = DNS_VERSION_1;
+                    break;
+                case 2:
+                    version = DNS_VERSION_2;
+                    break;
+                default:
+                    invalid = true;
+                    break;
+            }
+        } else {
+            invalid = true;
+        }
+        if (invalid) {
+            SCLogWarning(SC_ERR_INVALID_ARGUMENT,
+                    "invalid eve-log dns version option: %s, "
+                    "defaulting to version %u",
+                    has_version->val, version);
         }
     } else {
-        SCLogWarning(SC_ERR_INVALID_ARGUMENT,
-                "eve-log dns version not found, forcing it to version %u",
-                DNS_VERSION_DEFAULT);
-        version = DNS_VERSION_DEFAULT;
+        SCLogConfig("eve-log dns version not set, defaulting to version %u",
+                version);
     }
+
     return version;
 }