summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df089f4)
raw | patch | inline | side by side (parent: df089f4)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 16:19:39 +0000 (18:19 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 17:19:13 +0000 (19:19 +0200) |
Previously, expressions like 'host.foo != 123' would be silently accepted by
the parser.
Added test cases to reproduce and catch the problem.
the parser.
Added test cases to reproduce and catch the problem.
src/core/store_lookup.c | patch | blob | history | |
t/unit/core/store_lookup_test.c | patch | blob | history |
index 86acd10ea17ccf0a05ca7a7d1faeda5b09c52446..d53bd58f35d743228ee054ccdfdd530e94360f6f 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
return NULL;
if (value.type != SDB_TYPE_STRING) {
sdb_data_free_datum(&value);
+ if (type != SDB_ATTRIBUTE)
+ return NULL;
return parse_attr_cmp(attr, op, expr);
}
index b356fa0dd7b95858bddc93767a26ce4890136d23..754eb13f18808fba615ed1e809ac4d4b39a526e7 100644 (file)
START_TEST(test_parse_cmp)
{
- sdb_data_t hostname = { SDB_TYPE_STRING, { .string = "hostname" } };
- sdb_data_t metricname = { SDB_TYPE_STRING, { .string = "metricname" } };
- sdb_data_t srvname = { SDB_TYPE_STRING, { .string = "srvname" } };
- sdb_data_t attrname = { SDB_TYPE_STRING, { .string = "attrname" } };
+ sdb_data_t hostname = { SDB_TYPE_STRING, { .string = "hostname" } };
+ sdb_data_t metricname = { SDB_TYPE_STRING, { .string = "metricname" } };
+ sdb_data_t srvname = { SDB_TYPE_STRING, { .string = "srvname" } };
+ sdb_data_t attrname = { SDB_TYPE_STRING, { .string = "attrname" } };
+ sdb_data_t attrvalue = { SDB_TYPE_INTEGER, { .integer = 4711 } };
sdb_store_matcher_t *check;
{ "host", NULL, "!~", &hostname, MATCHER_NOT },
{ "host", "attr", "=", &hostname, -1 },
{ "host", "attr", "!=", &hostname, -1 },
+ { "host", "attr", "!=", &attrvalue, -1 },
+ { "host", "attr", "<=", &attrvalue, -1 },
{ "host", NULL, "&^", &hostname, -1 },
{ "host", NULL, "<", &hostname, -1 },
{ "host", NULL, "<=", &hostname, -1 },
{ "metric", NULL, "!~", &metricname, MATCHER_NOT },
{ "metric", "attr", "=", &metricname, -1 },
{ "metric", "attr", "!=", &metricname, -1 },
+ { "metric", "attr", "!=", &attrvalue, -1 },
+ { "metric", "attr", "<=", &attrvalue, -1 },
{ "metric", NULL, "&^", &metricname, -1 },
{ "metric", NULL, "<", &metricname, -1 },
{ "metric", NULL, "<=", &metricname, -1 },
{ "service", NULL, "!~", &srvname, MATCHER_NOT },
{ "service", "attr", "=", &srvname, -1 },
{ "service", "attr", "!=", &srvname, -1 },
+ { "service", "attr", "!=", &attrvalue, -1 },
+ { "service", "attr", "<=", &attrvalue, -1 },
{ "service", NULL, "&^", &srvname, -1 },
{ "service", NULL, "<", &srvname, -1 },
{ "service", NULL, "<=", &srvname, -1 },