From 8dbcbc4f42a1cb2151a0bb4ee31e69f947abfd5c Mon Sep 17 00:00:00 2001 From: ElektroVodka <211697683+Elektr0Vodka@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:50:55 +0100 Subject: [PATCH] fix(filter): five repeater filter bugs - Malformed scan: a group text the Public key cannot open (a private channel whose hash byte collides with Public's 0x11) decrypted to len 0 and was dropped as MALFORMED_SHORT, so about 1 in 256 private channels was blocked. Content is now judged only when the decrypt succeeds, as the companion filter already does. - `filter malformed ` wrote no reply; over the mesh that left the reply buffer uninitialised. It now returns a syntax error. - The group-text rate limit ran before the channel block list and the content rules, so traffic those drop used up the budget legitimate channels share. GRP_TXT is now rate-limited last. - `filter hops`, `filter rate` and `filter hash` parsed into uint8_t / uint16_t, so out-of-range input wrapped (`filter hops 3 300` stored 44). Values are range-checked as long before narrowing. - `filter channel add [hash]` accepted names that do not fit the 32-byte slot. load() derives the key from the stored name, so after a reboot the cut-off name no longer blocked the channel. Such names are refused. Filter.h also redefined `struct ChannelDetails` from src/helpers/ChannelDetails.h. Renamed to FilterChannel; same layout, so existing /filter_prefs files load unchanged. Tests: new test_filter_behaviour drives Filter through its interface. --- docs/packet_filter_reference.md | 16 +- examples/simple_repeater/Filter.cpp | 84 +++++---- examples/simple_repeater/Filter.h | 11 +- .../test_filter_behaviour.cpp | 162 ++++++++++++++++++ 4 files changed, 235 insertions(+), 38 deletions(-) create mode 100644 test/test_filter_behaviour/test_filter_behaviour.cpp diff --git a/docs/packet_filter_reference.md b/docs/packet_filter_reference.md index 7ff86d5362..bcabddf2e3 100644 --- a/docs/packet_filter_reference.md +++ b/docs/packet_filter_reference.md @@ -262,6 +262,10 @@ This allows up to **20 Group Text packets every 60 seconds**. Setting the limit to **0** disables rate limiting for that packet type. +Group Text (type 05) is counted last: after the channel block list, the +malformed scan, the age limit and the sender/text rules. Traffic those already +drop never uses up the group-text budget that the remaining channels share. + ## Soft cutoff By default a rate limit is a hard cutoff: once a type reaches its limit inside @@ -513,6 +517,9 @@ The channel hash is one byte, so about one channel in 256 shares it with MAC also checks out under the key of `#bot` (the key the apps derive from the name). Other channels with the same hash byte are still forwarded. +A channel name is at most 31 characters, including the `#`. A longer name is +refused with `Failed`. + Block on the hash byte alone, including every other channel that shares it: ```text @@ -625,7 +632,9 @@ When enabled, Group Text packets are checked for: The ±1 week check is skipped while the repeater's clock has not been set (see [Message age limit](#message-age-limit)); a zero timestamp is always rejected. -The malformed scan reads the Public channel only. +The malformed scan reads the Public channel only. A packet the Public key cannot +open (a private channel whose hash byte happens to equal Public's, `11`) is not +judged and passes. Default: @@ -1015,16 +1024,19 @@ Nothing is dropped while dry-run is on; the counters show what *would* be. | `> Filter: command error` | Unrecognised subcommand | | `> Filter: error range is 0-11` | Packet type outside `00`–`11` | | `> Filter: error range is 0-64` | Hop limit outside `0`–`64` | +| `> Filter: error and range is 0-65535` | Rate limit or soft cutoff out of range | +| `> Filter: error must not be negative` | Negative rate window | | `> Filter: error hash bytes range is 1-3` | Minimum path hash size outside `1`–`3` | | `> Filter: error range is 0-720` | Advert window outside `0`–`720` | | `> Filter: error range is 1-10080, or off` | Message age limit out of range or not a number | | `> Filter: error path prefix is 2-8 hex digits` | Path prefix empty, odd-length, longer than 4 bytes, or not hex | | `> Filter: error range is 0-65535, range is 1-100` | Sender/text rule argument out of range or not a number | | `> Filter: error max 15 chars` / `max 23 chars` | Sender name or text pattern too long | +| `> Filter: syntax error 'filter malformed '` | Wrong argument | | `> Filter: syntax error 'filter dryrun '` | Wrong argument | | `> Filter: syntax error 'filter hops '` | Wrong number of arguments | | `> Filter: syntax error 'filter rate '` | Wrong number of arguments | | `> Filter: syntax error 'filter channel [list \| add [hash] \| remove] <#name \| Public>'` | Wrong number of arguments | -| `Failed` | `filter channel add` with the list full, or `remove` with no such channel; `filter path add` with the list full or the prefix already blocked, or `remove` with no such prefix; the same for `filter sender`, `filter text` and `filter watch` (`watch add Public` also fails: it is always watched) | +| `Failed` | `filter channel add` with the list full or a name over 31 characters, or `remove` with no such channel; `filter path add` with the list full or the prefix already blocked, or `remove` with no such prefix; the same for `filter sender`, `filter text` and `filter watch` (`watch add Public` also fails: it is always watched) | An unknown `filter stats` topic is not an error: it returns the list of topics. diff --git a/examples/simple_repeater/Filter.cpp b/examples/simple_repeater/Filter.cpp index d3160ea40e..8f56c5cd0d 100644 --- a/examples/simple_repeater/Filter.cpp +++ b/examples/simple_repeater/Filter.cpp @@ -77,8 +77,10 @@ bool Filter::allowPacketForward(const mesh::Packet* packet) { return drop(packet); } } - // rate limiter (with optional probabilistic soft cutoff) - if (!_limiters[type].allow(_rtc->getCurrentTime(), nextRandom())) { + // rate limiter (with optional probabilistic soft cutoff). Group text is + // limited last instead, after the channel block and the content rules, so + // traffic those already drop never uses up the shared group-text budget. + if (type != PAYLOAD_TYPE_GRP_TXT && overRateLimit(type)) { FilterStat::recordRate(_cnt, type); if (have_src) FilterStat::recordSrc(_cnt, src); return drop(packet); @@ -100,7 +102,7 @@ bool Filter::allowPacketForward(const mesh::Packet* packet) { // only when the MAC also checks out under its key, unless it was added as // hash only. The MAC is computed only on a hash match. for (int i=0; ipayload[PATH_HASH_SIZE], packet->payload_len - PATH_HASH_SIZE); - // malformed - if (want_malformed) { + // malformed; len == 0 means the Public key did not open it (a private + // channel whose hash collides with Public's), so there is no content to judge + if (want_malformed && len > 0) { uint8_t reason; if (!validMessageContent(data, len, &reason)) { FilterStat::recordMalformed(_cnt, reason); @@ -160,6 +163,11 @@ bool Filter::allowPacketForward(const mesh::Packet* packet) { } } } + + if (overRateLimit(type)) { + FilterStat::recordRate(_cnt, type); + return drop(packet); + } } // allowed @@ -174,6 +182,10 @@ bool Filter::channelKeyMatch(const mesh::Packet* packet, const uint8_t* secret) packet->payload_len - PATH_HASH_SIZE) > 0; } +bool Filter::overRateLimit(uint8_t type) { + return !_limiters[type].allow(_rtc->getCurrentTime(), nextRandom()); +} + // The 1-byte identity hash of whoever originated the packet, where the payload // carries one. ACK and TRACE hold no identity and group traffic is encrypted, // so those drops only ever show up in the totals. @@ -315,15 +327,15 @@ void Filter::handleCommand(FILESYSTEM* fs, char* command, char* reply) { } else if (strcmp(parts[1], "hops") == 0) { if (n == 4) { - uint8_t type = atoi(parts[2]); - uint8_t count = atoi(parts[3]); + long type = atol(parts[2]); + long count = atol(parts[3]); if (type < 0 || type >= PAYLOAD_TYPE_COUNT) { strcpy(reply, "> Filter: error range is 0-11"); } else if (count < 0 || count > 64) { strcpy(reply, "> Filter: error range is 0-64"); } else { - _prefs.payload_prefs[type].hops_max = count; + _prefs.payload_prefs[type].hops_max = (uint8_t)count; save(fs); strcpy(reply, "> Filter: OK"); } @@ -335,20 +347,24 @@ void Filter::handleCommand(FILESYSTEM* fs, char* command, char* reply) { } else if (strcmp(parts[1], "rate") == 0) { if (n == 5 || n == 6) { - uint8_t type = atoi(parts[2]); - uint16_t limit = atoi(parts[3]); - uint32_t secs = atoi(parts[4]); - uint16_t soft = (n == 6) ? atoi(parts[5]) : 0; // omitted -> hard cutoff + long type = atol(parts[2]); + long limit = atol(parts[3]); + long secs = atol(parts[4]); + long soft = (n == 6) ? atol(parts[5]) : 0; // omitted -> hard cutoff if (type < 0 || type >= PAYLOAD_TYPE_COUNT) { strcpy(reply, "> Filter: error range is 0-11"); + } else if (limit < 0 || limit > 65535 || soft < 0 || soft > 65535) { + strcpy(reply, "> Filter: error and range is 0-65535"); + } else if (secs < 0) { + strcpy(reply, "> Filter: error must not be negative"); } else if (soft != 0 && soft >= limit) { strcpy(reply, "> Filter: error must be less than "); } else { - _prefs.payload_prefs[type].rate_limit = limit; - _prefs.payload_prefs[type].rate_secs = secs; - _prefs.soft_limit[type] = soft; - _limiters[type].init(limit, secs, soft); + _prefs.payload_prefs[type].rate_limit = (uint16_t)limit; + _prefs.payload_prefs[type].rate_secs = (uint32_t)secs; + _prefs.soft_limit[type] = (uint16_t)soft; + _limiters[type].init((uint16_t)limit, (uint32_t)secs, (uint16_t)soft); save(fs); strcpy(reply, "> Filter: OK"); } @@ -388,11 +404,11 @@ void Filter::handleCommand(FILESYSTEM* fs, char* command, char* reply) { // hash } else if (strcmp(parts[1], "hash") == 0) { - uint8_t count = atoi(parts[2]); + long count = atol(parts[2]); if (count < 1 || count > 3) { strcpy(reply, "> Filter: error hash bytes range is 1-3"); } else { - _prefs.minimal_hash_bytes = count; + _prefs.minimal_hash_bytes = (uint8_t)count; save(fs); strcpy(reply, "> Filter: OK"); } @@ -407,6 +423,8 @@ void Filter::handleCommand(FILESYSTEM* fs, char* command, char* reply) { _prefs.filter_malformed = false; strcpy(reply, "> Filter: malformed scan off"); save(fs); + } else { + strcpy(reply, "> Filter: syntax error 'filter malformed '"); } // dryrun @@ -573,7 +591,7 @@ bool Filter::hasContentRules(void) const { const uint8_t* Filter::watchedSecret(uint8_t channel_hash) const { if (channel_hash == PUBLIC_CHANNEL_HASH) return PUBLIC_CHANNEL_SECRET; for (int i = 0; i < FILTER_WATCH_COUNT; i++) { - const ChannelDetails& ch = _prefs.watch_channels[i]; + const FilterChannel& ch = _prefs.watch_channels[i]; if (ch.name[0] == '\0') continue; if (ch.channel.hash[0] == channel_hash) return ch.channel.secret; } @@ -581,12 +599,12 @@ const uint8_t* Filter::watchedSecret(uint8_t channel_hash) const { } bool Filter::addWatch(const char* name) { - if (name == nullptr || name[0] == '\0' || strlen(name) >= sizeof(ChannelDetails::name)) return false; + if (name == nullptr || name[0] == '\0' || strlen(name) >= sizeof(FilterChannel::name)) return false; if (strcmp(name, "Public") == 0) return false; // always watched int free_slot = -1; for (int i = 0; i < FILTER_WATCH_COUNT; i++) { - ChannelDetails& ch = _prefs.watch_channels[i]; + FilterChannel& ch = _prefs.watch_channels[i]; if (ch.name[0] == '\0') { if (free_slot < 0) free_slot = i; } else if (strcmp(ch.name, name) == 0) { @@ -595,7 +613,7 @@ bool Filter::addWatch(const char* name) { } if (free_slot < 0) return false; - ChannelDetails& ch = _prefs.watch_channels[free_slot]; + FilterChannel& ch = _prefs.watch_channels[free_slot]; strncpy(ch.name, name, sizeof(ch.name) - 1); ch.name[sizeof(ch.name) - 1] = '\0'; getChannelHash(name, &ch.channel); @@ -605,7 +623,7 @@ bool Filter::addWatch(const char* name) { bool Filter::removeWatch(const char* name) { if (name == nullptr || name[0] == '\0') return false; for (int i = 0; i < FILTER_WATCH_COUNT; i++) { - ChannelDetails& ch = _prefs.watch_channels[i]; + FilterChannel& ch = _prefs.watch_channels[i]; if (strcmp(ch.name, name) == 0) { ch.name[0] = '\0'; return true; @@ -624,7 +642,7 @@ void Filter::listWatchNames(char* out_buf, size_t out_size) { b.add("Public (11)"); listed++; for (int i = 0; i < FILTER_WATCH_COUNT; i++) { - const ChannelDetails& ch = _prefs.watch_channels[i]; + const FilterChannel& ch = _prefs.watch_channels[i]; if (ch.name[0] == '\0') continue; mesh::Utils::toHex(channel_hex, ch.channel.hash, 1); b.add(",%s (%s)", ch.name, channel_hex); @@ -652,13 +670,15 @@ void Filter::formatResponse(char *reply, ResponseType rtype) { b.markTruncated(".."); } -// Adding a channel that is already on the list switches its match mode. +// Adding a channel that is already on the list switches its match mode. A name +// that does not fit the slot is refused: load() derives the key from the stored +// name, so a cut-off name would block another channel after a reboot. bool Filter::addChannel(const char* name, bool hash_only) { - if (name == nullptr || name[0] == '\0') return false; + if (name == nullptr || name[0] == '\0' || strlen(name) >= sizeof(FilterChannel::name)) return false; int free_slot = -1; for (int i=0; i 100) tr.prob = 100; } for (int i = 0; i < FILTER_CHANNEL_COUNT; i++) { - ChannelDetails& ch = _prefs.filter_channels[i]; + FilterChannel& ch = _prefs.filter_channels[i]; ch.name[sizeof(ch.name) - 1] = '\0'; if (ch.name[0] != '\0') getChannelHash(ch.name, &ch.channel); // the MAC check needs the right key _prefs.channel_hash_only[i] = constrain(_prefs.channel_hash_only[i], 0, 1); } for (int i = 0; i < FILTER_WATCH_COUNT; i++) { - ChannelDetails& ch = _prefs.watch_channels[i]; + FilterChannel& ch = _prefs.watch_channels[i]; ch.name[sizeof(ch.name) - 1] = '\0'; if (ch.name[0] != '\0') getChannelHash(ch.name, &ch.channel); // never trust a stored key } diff --git a/examples/simple_repeater/Filter.h b/examples/simple_repeater/Filter.h index e52d9fad85..77c4b647db 100644 --- a/examples/simple_repeater/Filter.h +++ b/examples/simple_repeater/Filter.h @@ -26,11 +26,11 @@ static const uint8_t PUBLIC_CHANNEL_SECRET[PUB_KEY_SIZE] = { 0x8B, 0x33, 0x87, 0 0, 0, 0, 0, 0, 0, 0, 0 }; static const uint8_t PUBLIC_CHANNEL_HASH = 0x11; -struct ChannelDetails { +struct FilterChannel { mesh::GroupChannel channel; char name[32]; - ChannelDetails() { + FilterChannel() { name[0] = '\0'; memset(channel.hash, 0, sizeof(channel.hash)); memset(channel.secret, 0, sizeof(channel.secret)); @@ -53,7 +53,7 @@ struct FilterPrefs { [PAYLOAD_TYPE_MULTIPART] = { .hops_max = 8, .rate_limit = 5, .rate_secs = 60 }, [PAYLOAD_TYPE_CONTROL] = { .hops_max = 8, .rate_limit = 5, .rate_secs = 60 }, }; - ChannelDetails filter_channels[FILTER_CHANNEL_COUNT]; + FilterChannel filter_channels[FILTER_CHANNEL_COUNT]; uint8_t minimal_hash_bytes = 1; uint8_t filter_malformed = false; // Appended at the end of the struct so older /filter_prefs files (which lack @@ -66,7 +66,7 @@ struct FilterPrefs { PathPrefix path_block[FILTER_PATH_COUNT] = {}; // blocked path-ID prefixes SenderRule sender_rules[FILTER_RULE_COUNT] = {}; // group-text sender rules (ordered) TextRule text_rules[FILTER_RULE_COUNT] = {}; // group-text text rules (ordered) - ChannelDetails watch_channels[FILTER_WATCH_COUNT]; // channels decrypted for the rules, besides Public + FilterChannel watch_channels[FILTER_WATCH_COUNT]; // channels decrypted for the rules, besides Public uint16_t age_mins = 0; // drop group text older than this, 0 = off // Per filter_channels slot: 1 = match on the channel hash byte alone, 0 = the // MAC must also check out under the channel's key. Files without this field @@ -91,6 +91,9 @@ class Filter { // to every reason alike. Returns the forwarding verdict. bool drop(const mesh::Packet *packet); + // Consumes one slot of this payload type's rate budget; true when over it. + bool overRateLimit(uint8_t type); + // Rebuild the per-type rate limiters from _prefs. Every path that replaces // the prefs (defaults, reset, load) must end here, or the limiters keep // enforcing whatever they held before (all-zero = no limit at all). diff --git a/test/test_filter_behaviour/test_filter_behaviour.cpp b/test/test_filter_behaviour/test_filter_behaviour.cpp new file mode 100644 index 0000000000..3c6071837e --- /dev/null +++ b/test/test_filter_behaviour/test_filter_behaviour.cpp @@ -0,0 +1,162 @@ +#include + +#include + +// Both headers in one translation unit: the filter must not redefine a type +// the shared helpers already own. +#include +#include "../../examples/simple_repeater/Filter.h" + +// src/Identity.cpp needs the ed25519 library, which the native env does not +// build. ClientACL only needs the default constructor. +mesh::Identity::Identity() { memset(pub_key, 0, sizeof(pub_key)); } + +namespace { + +class FixedClock : public mesh::RTCClock { + uint32_t _now = 1700000000; +public: + uint32_t getCurrentTime() override { return _now; } + void setCurrentTime(uint32_t time) override { _now = time; } +}; + +class FilterTest : public ::testing::Test { +protected: + ClientACL acl; + FixedClock clock; + FsMock fs; + Filter filter{acl, clock}; + + void SetUp() override { + ASSERT_TRUE(filter.load(&fs)); + run("filter on"); + } + + std::string run(const char* cmd) { + char buf[96]; + char reply[FILTER_REPLY_SIZE] = ""; + strncpy(buf, cmd, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; + filter.handleCommand(&fs, buf, reply); + return reply; + } +}; + +mesh::Packet flood(uint8_t type, uint8_t hops = 0) { + mesh::Packet p; + p.header = ROUTE_TYPE_FLOOD | (type << PH_TYPE_SHIFT); + p.setPathHashSizeAndCount(1, hops); + memset(p.path, 0, sizeof(p.path)); + memset(p.payload, 0, sizeof(p.payload)); + p.payload_len = 4; + return p; +} + +// A group text for the channel with this 1-byte hash. 17 bytes of ciphertext +// after the MAC is not block-aligned, so MACThenDecrypt returns 0 for any key: +// the same outcome as a real MAC failure, without depending on the (inert) +// native crypto mocks. +mesh::Packet groupText(uint8_t channel_hash) { + mesh::Packet p = flood(PAYLOAD_TYPE_GRP_TXT); + p.payload[0] = channel_hash; + p.payload_len = PATH_HASH_SIZE + CIPHER_MAC_SIZE + 17; + return p; +} + +} // namespace + +// A private channel whose 1-byte hash collides with Public (0x11) cannot be +// decrypted with the Public key. That says nothing about its content, so the +// malformed scan must let it through instead of dropping it as too short. +TEST_F(FilterTest, MalformedScanKeepsUndecryptableHashCollision) { + run("filter malformed on"); + mesh::Packet p = groupText(PUBLIC_CHANNEL_HASH); + EXPECT_TRUE(filter.allowPacketForward(&p)); +} + +TEST_F(FilterTest, MalformedWithBadArgumentReplies) { + std::string reply = run("filter malformed maybe"); + EXPECT_NE(reply.find("syntax error"), std::string::npos) << reply; +} + +// Group text from a blocked channel is dropped by the block list; it must not +// also use up the group-text rate budget that legitimate channels share. +TEST_F(FilterTest, BlockedChannelDoesNotUseGroupTextBudget) { + ASSERT_EQ(run("filter rate 5 2 60"), "> Filter: OK"); // GRP_TXT: 2 per 60 s + run("filter channel add hash #spam"); // hash only: no MAC needed to match + mesh::GroupChannel spam; + ASSERT_TRUE(Filter::getChannelHash("#spam", &spam)); + + uint8_t other = 0x20; + while (other == spam.hash[0] || other == PUBLIC_CHANNEL_HASH) other++; + + mesh::Packet blocked = groupText(spam.hash[0]); + for (int i = 0; i < 3; i++) EXPECT_FALSE(filter.allowPacketForward(&blocked)); + + mesh::Packet ok = groupText(other); + EXPECT_TRUE(filter.allowPacketForward(&ok)); + EXPECT_TRUE(filter.allowPacketForward(&ok)); + EXPECT_FALSE(filter.allowPacketForward(&ok)); // the budget itself still applies +} + +// 300 used to wrap to 44 in a uint8_t and was stored as the hop limit. +TEST_F(FilterTest, HopsOutOfRangeIsRejected) { + std::string reply = run("filter hops 3 300"); + EXPECT_NE(reply.find("error"), std::string::npos) << reply; + + mesh::Packet p = flood(PAYLOAD_TYPE_ACK, 8); // default ACK hop limit is 8 + EXPECT_FALSE(filter.allowPacketForward(&p)); +} + +TEST_F(FilterTest, TypeOutOfRangeIsRejected) { + EXPECT_NE(run("filter hops 256 4").find("error"), std::string::npos); // wrapped to type 0 + EXPECT_NE(run("filter rate 259 5 60").find("error"), std::string::npos); // wrapped to type 3 +} + +TEST_F(FilterTest, RateOutOfRangeIsRejected) { + std::string reply = run("filter rate 3 70000 60"); // 70000 wrapped to 4464 + EXPECT_NE(reply.find("error"), std::string::npos) << reply; +} + +// Same rule for an entry matched by key, with a packet that really is on it. +TEST_F(FilterTest, KeyBlockedChannelDoesNotUseGroupTextBudget) { + ASSERT_EQ(run("filter rate 5 1 60"), "> Filter: OK"); + run("filter channel add #spam"); + mesh::GroupChannel spam; + ASSERT_TRUE(Filter::getChannelHash("#spam", &spam)); + + mesh::Packet blocked = flood(PAYLOAD_TYPE_GRP_TXT); + uint8_t plain[16] = { 0x00, 0xF1, 0x53, 0x65, 0x00, 'a', ':', ' ', 'h', 'i' }; + blocked.payload[0] = spam.hash[0]; + blocked.payload_len = PATH_HASH_SIZE + + mesh::Utils::encryptThenMAC(spam.secret, &blocked.payload[PATH_HASH_SIZE], plain, sizeof(plain)); + for (int i = 0; i < 3; i++) EXPECT_FALSE(filter.allowPacketForward(&blocked)); + + mesh::Packet ok = groupText((uint8_t)(spam.hash[0] + 1)); + EXPECT_TRUE(filter.allowPacketForward(&ok)); +} + +TEST_F(FilterTest, HashBytesOutOfRangeIsRejected) { + EXPECT_NE(run("filter hash 257").find("error"), std::string::npos); // wrapped to 1 +} + +TEST_F(FilterTest, RateNegativeIsRejected) { + EXPECT_NE(run("filter rate 3 -1 60").find("error"), std::string::npos); + EXPECT_NE(run("filter rate 3 5 -1").find("error"), std::string::npos); +} + +// load() derives the key from the stored name, so a name cut to 31 characters +// would block another channel after a reboot. It is refused in both modes; a +// name that just fits (31 characters) is still accepted. +TEST_F(FilterTest, OverlongChannelNameIsRejected) { + EXPECT_EQ(run("filter channel add #a-channel-name-that-is-far-too-long-to-fit"), "Failed"); + EXPECT_EQ(run("filter channel add hash #a-channel-name-that-is-far-too-long-to-fit"), "Failed"); + EXPECT_EQ(run("filter channel add #23456789012345678901234567890123"), "Failed"); // 33 + EXPECT_EQ(run("filter channel add #2345678901234567890123456789012"), "Failed"); // 32 + EXPECT_NE(run("filter channel add #234567890123456789012345678901"), "Failed"); // 31 +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}