diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-10-11 23:16:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-10-11 23:16:21 (GMT) |
commit | ab6b87b7309e2d00926615f6557016bee6ab0b71 (patch) | |
tree | bf69b93d2f0548fc845e68ae1e8519bd33d1da24 /tests | |
parent | 404097b7b07b336b427b3682ec2bc48d831cb2e9 (diff) |
Add two new functions to ROST grammar: modpath and maxcommon.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/analysis/scan/functions.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/analysis/scan/functions.py b/tests/analysis/scan/functions.py index e936263..983b8da 100644 --- a/tests/analysis/scan/functions.py +++ b/tests/analysis/scan/functions.py @@ -33,6 +33,32 @@ rule test { self.check_rule_success(rule, cnt) + def testMaxCommon(self): + """Count the largest quantity of same items in a set.""" + + cnt = MemoryContent(b'') + + cases = [ + [ '1', 1 ], + [ '1, 2, 3', 1 ], + [ '1, 2, 1, 3, 1', 3 ], + [ '1, "a", 2, 3, "a"', 2 ], + ] + + for c, q in cases: + + rule = ''' +rule test { + + condition: + maxcommon(%s) == %u + +} +''' % (c, q) + + self.check_rule_success(rule, cnt) + + # Modules # ======= |