[Forensics-changes] [yara] 28/407: Implement "matches" for strings.

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.3.0
in repository yara.

commit 430b94142aaa24bc098cd4dd88166589d302ca3e
Author: Wesley Shields <wxs at atarininja.org>
Date:   Wed Sep 17 15:14:23 2014 -0400

    Implement "matches" for strings.
---
 libyara/exec.c              |  27 +-
 libyara/grammar.c           | 663 ++++++++++++++++++++++----------------------
 libyara/grammar.y           |  16 ++
 libyara/include/yara/exec.h |   1 +
 4 files changed, 381 insertions(+), 326 deletions(-)

diff --git a/libyara/exec.c b/libyara/exec.c
index 8bfc1cc..8e4a7c5 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -87,6 +87,8 @@ int yr_execute_code(
   YR_MATCH* match;
   YR_OBJECT* object;
   YR_OBJECT_FUNCTION* function;
+  SIZED_STRING *big;
+  YR_STRING *little;
 
   char* identifier;
 
@@ -720,8 +722,8 @@ int yr_execute_code(
       case OP_CONTAINS_STR:
         pop(r2);
         pop(r1);
-        SIZED_STRING *big = UINT64_TO_PTR(SIZED_STRING*, r1);
-        YR_STRING *little = UINT64_TO_PTR(YR_STRING*, r2);
+        big = UINT64_TO_PTR(SIZED_STRING*, r1);
+        little = UINT64_TO_PTR(YR_STRING*, r2);
 
         if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
         {
@@ -732,6 +734,27 @@ int yr_execute_code(
         push(memmem(big->c_string, big->length, little->string, little->length) != NULL);
         break;
 
+      case OP_MATCHES_STR:
+        pop(r2);
+        pop(r1);
+        big = UINT64_TO_PTR(SIZED_STRING*, r1);
+        little = UINT64_TO_PTR(YR_STRING*, r2);
+
+        if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+        {
+          push(UNDEFINED);
+          break;
+        }
+
+        if (big->length != little->length)
+        {
+          push(FALSE);
+          break;
+        }
+
+        push(memcmp(big->c_string, little->string, big->length) == 0);
+        break;
+
       default:
         // Unknown instruction, this shouldn't happen.
         assert(FALSE);
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 0428881..234cfaa 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -514,16 +514,16 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  2
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   490
+#define YYLAST   476
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  74
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  35
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  116
+#define YYNRULES  117
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  217
+#define YYNSTATES  218
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -578,13 +578,13 @@ static const yytype_uint16 yyprhs[] =
       57,    59,    62,    64,    67,    71,    75,    79,    83,    85,
       88,    93,    94,   100,   104,   105,   108,   110,   112,   114,
      116,   118,   122,   127,   132,   133,   135,   139,   141,   143,
-     145,   147,   151,   155,   159,   161,   165,   169,   170,   171,
-     183,   184,   194,   198,   201,   205,   209,   213,   217,   221,
-     225,   229,   233,   237,   239,   243,   247,   249,   256,   258,
-     262,   263,   268,   270,   272,   276,   278,   280,   282,   284,
-     286,   290,   292,   294,   299,   304,   309,   314,   319,   324,
-     326,   328,   330,   335,   337,   339,   343,   347,   351,   355,
-     359,   363,   367,   371,   374,   378,   382
+     145,   147,   151,   155,   159,   163,   165,   169,   173,   174,
+     175,   187,   188,   198,   202,   205,   209,   213,   217,   221,
+     225,   229,   233,   237,   241,   243,   247,   251,   253,   260,
+     262,   266,   267,   272,   274,   276,   280,   282,   284,   286,
+     288,   290,   294,   296,   298,   303,   308,   313,   318,   323,
+     328,   330,   332,   334,   339,   341,   343,   347,   351,   355,
+     359,   363,   367,   371,   375,   378,   382,   386
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
@@ -605,30 +605,30 @@ static const yytype_int8 yyrhs[] =
        9,    -1,    92,    69,   108,    70,    -1,    92,    71,    93,
       72,    -1,    -1,    96,    -1,    93,    73,    96,    -1,    17,
       -1,    96,    -1,    40,    -1,    41,    -1,   108,    37,    94,
-      -1,   108,    38,   108,    -1,   108,    38,    10,    -1,    10,
-      -1,    10,    22,   108,    -1,    10,    27,   101,    -1,    -1,
-      -1,    29,   107,     9,    27,    97,   100,    66,    98,    71,
-      95,    72,    -1,    -1,    29,   107,    28,   103,    66,    99,
-      71,    95,    72,    -1,   107,    28,   103,    -1,    61,    95,
-      -1,    95,    43,    95,    -1,    95,    42,    95,    -1,   108,
-      53,   108,    -1,   108,    51,   108,    -1,   108,    52,   108,
-      -1,   108,    50,   108,    -1,   108,    49,   108,    -1,   108,
-      47,   108,    -1,   108,    48,   108,    -1,   108,    -1,    71,
-      96,    72,    -1,    71,   102,    72,    -1,   101,    -1,    71,
-     108,    68,    68,   108,    72,    -1,   108,    -1,   102,    73,
-     108,    -1,    -1,    71,   104,   105,    72,    -1,    30,    -1,
-     106,    -1,   105,    73,   106,    -1,    10,    -1,    13,    -1,
-     108,    -1,    25,    -1,    26,    -1,    71,   108,    72,    -1,
-      23,    -1,    24,    -1,    31,    71,   108,    72,    -1,    32,
-      71,   108,    72,    -1,    33,    71,   108,    72,    -1,    34,
-      71,   108,    72,    -1,    35,    71,   108,    72,    -1,    36,
-      71,   108,    72,    -1,    14,    -1,    15,    -1,    11,    -1,
-      12,    69,   108,    70,    -1,    12,    -1,    92,    -1,   108,
-      56,   108,    -1,   108,    57,   108,    -1,   108,    58,   108,
-      -1,   108,    59,   108,    -1,   108,    60,   108,    -1,   108,
-      46,   108,    -1,   108,    44,   108,    -1,   108,    45,   108,
-      -1,    62,   108,    -1,   108,    55,   108,    -1,   108,    54,
-     108,    -1,    94,    -1
+      -1,   108,    38,   108,    -1,   108,    38,    10,    -1,   108,
+      37,    10,    -1,    10,    -1,    10,    22,   108,    -1,    10,
+      27,   101,    -1,    -1,    -1,    29,   107,     9,    27,    97,
+     100,    66,    98,    71,    95,    72,    -1,    -1,    29,   107,
+      28,   103,    66,    99,    71,    95,    72,    -1,   107,    28,
+     103,    -1,    61,    95,    -1,    95,    43,    95,    -1,    95,
+      42,    95,    -1,   108,    53,   108,    -1,   108,    51,   108,
+      -1,   108,    52,   108,    -1,   108,    50,   108,    -1,   108,
+      49,   108,    -1,   108,    47,   108,    -1,   108,    48,   108,
+      -1,   108,    -1,    71,    96,    72,    -1,    71,   102,    72,
+      -1,   101,    -1,    71,   108,    68,    68,   108,    72,    -1,
+     108,    -1,   102,    73,   108,    -1,    -1,    71,   104,   105,
+      72,    -1,    30,    -1,   106,    -1,   105,    73,   106,    -1,
+      10,    -1,    13,    -1,   108,    -1,    25,    -1,    26,    -1,
+      71,   108,    72,    -1,    23,    -1,    24,    -1,    31,    71,
+     108,    72,    -1,    32,    71,   108,    72,    -1,    33,    71,
+     108,    72,    -1,    34,    71,   108,    72,    -1,    35,    71,
+     108,    72,    -1,    36,    71,   108,    72,    -1,    14,    -1,
+      15,    -1,    11,    -1,    12,    69,   108,    70,    -1,    12,
+      -1,    92,    -1,   108,    56,   108,    -1,   108,    57,   108,
+      -1,   108,    58,   108,    -1,   108,    59,   108,    -1,   108,
+      60,   108,    -1,   108,    46,   108,    -1,   108,    44,   108,
+      -1,   108,    45,   108,    -1,    62,   108,    -1,   108,    55,
+     108,    -1,   108,    54,   108,    -1,    94,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
@@ -639,13 +639,13 @@ static const yytype_uint16 yyrline[] =
      343,   356,   393,   394,   399,   415,   428,   441,   458,   459,
      464,   478,   477,   494,   511,   512,   517,   518,   519,   520,
      525,   613,   662,   712,   752,   755,   777,   810,   855,   872,
-     881,   890,   905,   919,   935,   949,   965,   980,  1015,   979,
-    1126,  1125,  1202,  1208,  1214,  1220,  1228,  1237,  1246,  1255,
-    1264,  1291,  1318,  1345,  1349,  1357,  1358,  1363,  1385,  1397,
-    1413,  1412,  1418,  1427,  1428,  1433,  1438,  1447,  1448,  1452,
-    1460,  1464,  1474,  1487,  1499,  1511,  1523,  1535,  1547,  1559,
-    1569,  1592,  1607,  1622,  1644,  1681,  1691,  1701,  1711,  1721,
-    1731,  1741,  1751,  1761,  1771,  1781,  1791
+     881,   890,   905,   919,   935,   951,   965,   981,   996,  1031,
+     995,  1142,  1141,  1218,  1224,  1230,  1236,  1244,  1253,  1262,
+    1271,  1280,  1307,  1334,  1361,  1365,  1373,  1374,  1379,  1401,
+    1413,  1429,  1428,  1434,  1443,  1444,  1449,  1454,  1463,  1464,
+    1468,  1476,  1480,  1490,  1503,  1515,  1527,  1539,  1551,  1563,
+    1575,  1585,  1608,  1623,  1638,  1660,  1697,  1707,  1717,  1727,
+    1737,  1747,  1757,  1767,  1777,  1787,  1797,  1807
 };
 #endif
 
@@ -701,13 +701,13 @@ static const yytype_uint8 yyr1[] =
       84,    84,    85,    85,    86,    86,    86,    86,    87,    87,
       88,    89,    88,    88,    90,    90,    91,    91,    91,    91,
       92,    92,    92,    92,    93,    93,    93,    94,    95,    96,
-      96,    96,    96,    96,    96,    96,    96,    97,    98,    96,
-      99,    96,    96,    96,    96,    96,    96,    96,    96,    96,
-      96,    96,    96,    96,    96,   100,   100,   101,   102,   102,
-     104,   103,   103,   105,   105,   106,   106,   107,   107,   107,
+      96,    96,    96,    96,    96,    96,    96,    96,    97,    98,
+      96,    99,    96,    96,    96,    96,    96,    96,    96,    96,
+      96,    96,    96,    96,    96,    96,   100,   100,   101,   102,
+     102,   104,   103,   103,   105,   105,   106,   106,   107,   107,
+     107,   108,   108,   108,   108,   108,   108,   108,   108,   108,
      108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
-     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
-     108,   108,   108,   108,   108,   108,   108
+     108,   108,   108,   108,   108,   108,   108,   108
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -718,13 +718,13 @@ static const yytype_uint8 yyr2[] =
        1,     2,     1,     2,     3,     3,     3,     3,     1,     2,
        4,     0,     5,     3,     0,     2,     1,     1,     1,     1,
        1,     3,     4,     4,     0,     1,     3,     1,     1,     1,
-       1,     3,     3,     3,     1,     3,     3,     0,     0,    11,
-       0,     9,     3,     2,     3,     3,     3,     3,     3,     3,
-       3,     3,     3,     1,     3,     3,     1,     6,     1,     3,
-       0,     4,     1,     1,     3,     1,     1,     1,     1,     1,
-       3,     1,     1,     4,     4,     4,     4,     4,     4,     1,
-       1,     1,     4,     1,     1,     3,     3,     3,     3,     3,
-       3,     3,     3,     2,     3,     3,     1
+       1,     3,     3,     3,     3,     1,     3,     3,     0,     0,
+      11,     0,     9,     3,     2,     3,     3,     3,     3,     3,
+       3,     3,     3,     3,     1,     3,     3,     1,     6,     1,
+       3,     0,     4,     1,     1,     3,     1,     1,     1,     1,
+       1,     3,     1,     1,     4,     4,     4,     4,     4,     4,
+       1,     1,     1,     4,     1,     1,     3,     3,     3,     3,
+       3,     3,     3,     3,     2,     3,     3,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -736,33 +736,33 @@ static const yytype_uint8 yydefact[] =
        7,     0,    16,    17,    15,    18,     0,     0,    20,    19,
        9,    21,     0,    11,     0,     0,     0,     0,    10,    22,
        0,     0,     0,     0,    23,     0,    12,    28,     0,     8,
-      25,    24,    26,    27,    31,    29,    40,    54,   101,   103,
-      99,   100,    47,    91,    92,    88,    89,     0,     0,     0,
-       0,     0,     0,     0,    49,    50,     0,     0,     0,   104,
-     116,    13,    48,     0,    73,    34,    33,     0,     0,     0,
-       0,     0,     0,    87,     0,     0,     0,     0,     0,     0,
-      63,   113,     0,    48,    73,     0,     0,    44,     0,     0,
+      25,    24,    26,    27,    31,    29,    40,    55,   102,   104,
+     100,   101,    47,    92,    93,    89,    90,     0,     0,     0,
+       0,     0,     0,     0,    49,    50,     0,     0,     0,   105,
+     117,    13,    48,     0,    74,    34,    33,     0,     0,     0,
+       0,     0,     0,    88,     0,     0,     0,     0,     0,     0,
+      64,   114,     0,    48,    74,     0,     0,    44,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      30,    34,    55,     0,    56,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    74,    90,    41,     0,     0,
-      45,    65,    64,    82,    80,    62,    51,    53,    52,   111,
-     112,   110,    71,    72,    70,    69,    67,    68,    66,   115,
-     114,   105,   106,   107,   108,   109,    37,    36,    38,    39,
-      35,    32,     0,   102,    57,     0,    93,    94,    95,    96,
-      97,    98,    42,    43,     0,     0,     0,     0,    60,    46,
-      85,    86,     0,    83,     0,     0,     0,    76,     0,    81,
-       0,     0,     0,    78,    58,     0,    84,    77,    75,     0,
-       0,     0,    79,     0,    61,     0,    59
+      30,    34,    56,     0,    57,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    75,    91,    41,     0,     0,
+      45,    66,    65,    83,    81,    63,    54,    51,    53,    52,
+     112,   113,   111,    72,    73,    71,    70,    68,    69,    67,
+     116,   115,   106,   107,   108,   109,   110,    37,    36,    38,
+      39,    35,    32,     0,   103,    58,     0,    94,    95,    96,
+      97,    98,    99,    42,    43,     0,     0,     0,     0,    61,
+      46,    86,    87,     0,    84,     0,     0,     0,    77,     0,
+      82,     0,     0,     0,    79,    59,     0,    85,    78,    76,
+       0,     0,     0,    80,     0,    62,     0,    60
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,     1,     5,     6,    23,    26,    32,     7,    14,    17,
-      19,    28,    29,    36,    37,    77,   120,   170,    69,   139,
-      70,    92,    72,   187,   210,   198,   196,   124,   202,   145,
-     185,   192,   193,    73,    74
+      19,    28,    29,    36,    37,    77,   120,   171,    69,   139,
+      70,    92,    72,   188,   211,   199,   197,   124,   203,   145,
+     186,   193,   194,    73,    74
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
@@ -770,150 +770,146 @@ static const yytype_int16 yydefgoto[] =
 #define YYPACT_NINF -66
 static const yytype_int16 yypact[] =
 {
-     -66,     6,   -66,   -59,     0,   -66,   -66,    59,   -66,   -66,
-     -66,     9,   -66,   -66,   -66,   -44,    16,   -24,   -66,    49,
-      87,   -66,    30,    95,   101,    58,   119,    55,   101,   -66,
-     120,    68,    70,    -2,   -66,    69,   120,   -66,    80,   -66,
-     -66,   -66,   -66,   -66,    72,   -66,   -66,    -8,   -66,    74,
-     -66,   -66,   -66,   -66,   -66,   -66,   -66,   114,    73,    81,
-      82,    83,    84,    85,   -66,   -66,    80,   201,    80,   -42,
-     -66,    56,   -66,   138,   262,   -66,   -66,   151,   201,    98,
-     201,   201,    -7,   429,   201,   201,   201,   201,   201,   201,
-     -66,   -66,    56,    99,   229,   161,   201,    80,    80,    80,
-     -29,   156,   169,   201,   201,   201,   201,   201,   201,   201,
-     201,   201,   201,   201,   201,   201,   201,   201,   201,   201,
-      36,   -66,   429,   201,   -66,   395,   279,   147,   -29,   286,
-     308,   315,   337,   344,   366,   -66,   -66,   -66,   402,    28,
-      65,   134,   -66,   -66,   -66,   -66,   -66,   -66,   429,   105,
-     105,   105,   429,   429,   429,   429,   429,   429,   429,   -23,
-     -23,    25,    25,   -66,   -66,   -66,   -66,   -66,   -66,   -66,
-     -66,    36,   422,   -66,   -66,   116,   -66,   -66,   -66,   -66,
-     -66,   -66,   -66,   -66,    80,    -5,   121,   117,   -66,    65,
-     -66,   -66,    45,   -66,   201,   201,   124,   -66,   123,   -66,
-      -5,   373,    60,   422,   -66,    80,   -66,   -66,   -66,   201,
-     125,   -26,   429,    80,   -66,   -19,   -66
+     -66,     6,   -66,   -59,     3,   -66,   -66,    59,   -66,   -66,
+     -66,    16,   -66,   -66,   -66,    28,    31,    -6,   -66,    82,
+      94,   -66,    42,   110,   113,    62,   117,    67,   113,   -66,
+     131,    76,    92,    -2,   -66,    93,   131,   -66,    78,   -66,
+     -66,   -66,   -66,   -66,    81,   -66,   -66,    -8,   -66,   102,
+     -66,   -66,   -66,   -66,   -66,   -66,   -66,   112,    90,    91,
+     104,   106,   109,   111,   -66,   -66,    78,   187,    78,   -42,
+     -66,    56,   -66,   135,   248,   -66,   -66,   164,   187,   114,
+     187,   187,    -7,   415,   187,   187,   187,   187,   187,   187,
+     -66,   -66,    56,   120,   215,   175,   187,    78,    78,    78,
+     -29,     5,   155,   187,   187,   187,   187,   187,   187,   187,
+     187,   187,   187,   187,   187,   187,   187,   187,   187,   187,
+      36,   -66,   415,   187,   -66,   381,   265,   166,   -29,   272,
+     294,   301,   323,   330,   352,   -66,   -66,   -66,   388,    33,
+      73,   151,   -66,   -66,   -66,   -66,   -66,   -66,   -66,   415,
+      96,    96,    96,   415,   415,   415,   415,   415,   415,   415,
+     -23,   -23,    25,    25,   -66,   -66,   -66,   -66,   -66,   -66,
+     -66,   -66,    36,   408,   -66,   -66,   129,   -66,   -66,   -66,
+     -66,   -66,   -66,   -66,   -66,    78,    -5,   132,   126,   -66,
+      73,   -66,   -66,    58,   -66,   187,   187,   137,   -66,   134,
+     -66,    -5,   359,    60,   408,   -66,    78,   -66,   -66,   -66,
+     187,   136,   -26,   415,    78,   -66,   -19,   -66
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-     -66,   -66,   -66,   184,   -66,   -66,   -66,   -66,   -66,   -66,
-     -66,   -66,   163,   -66,   159,   -66,    76,   -66,   -66,   -66,
-      97,   -38,   -65,   -66,   -66,   -66,   -66,    12,   -66,    78,
-     -66,   -66,     7,   152,   -37
+     -66,   -66,   -66,   203,   -66,   -66,   -66,   -66,   -66,   -66,
+     -66,   -66,   180,   -66,   173,   -66,    95,   -66,   -66,   -66,
+     123,   -38,   -65,   -66,   -66,   -66,   -66,    24,   -66,    85,
+     -66,   -66,    13,   158,   -37
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -88
+#define YYTABLE_NINF -89
 static const yytype_int16 yytable[] =
 {
-      71,   143,   127,    93,     8,   190,     2,     3,   191,   -14,
-     -14,   -14,    40,    41,    78,    10,    98,    99,    15,    79,
-      83,   128,    16,    98,    99,    18,    95,    96,    90,    97,
+      71,   143,   127,    93,     8,   191,     2,     3,   192,   -14,
+     -14,   -14,    40,    41,    78,   146,    98,    99,    10,    79,
+      83,   128,    52,    98,    99,    15,    95,    96,    90,    97,
       91,    94,   140,   115,   116,   117,   118,   119,    42,    43,
-      20,   122,   144,   125,   126,     4,   214,   129,   130,   131,
-     132,   133,   134,   216,   166,   167,   168,   169,    21,   138,
-     141,   142,    11,    12,    13,   148,   149,   150,   151,   152,
-     153,   154,   155,   156,   157,   158,   159,   160,   161,   162,
-     163,   164,   165,   117,   118,   119,   172,    75,    76,    46,
-      47,    48,    49,    22,    50,    51,    24,    52,    98,    99,
-     183,   184,    25,    53,    54,    55,    56,   -48,   -48,    57,
-      27,    58,    59,    60,    61,    62,    63,   199,   200,   189,
-      64,    65,    33,    46,    30,    48,    49,    31,    50,    51,
-      35,    52,   208,   209,    38,    39,    44,    53,    54,    55,
-      56,    66,    67,    80,    84,    58,    59,    60,    61,    62,
-      63,    68,    85,    86,    87,    88,    89,   201,   203,   113,
-     114,   115,   116,   117,   118,   119,   100,   211,   121,   123,
-     137,   135,   212,    52,   174,   215,    67,    99,    46,   147,
-      48,    49,   188,    50,    51,    81,    52,     9,   195,   194,
-     204,    34,    53,    54,   205,    45,   213,   171,   146,   197,
-      58,    59,    60,    61,    62,    63,   175,   206,     0,    82,
-      46,     0,    48,    49,     0,    50,    51,     0,    52,     0,
-       0,     0,     0,     0,    53,    54,     0,     0,     0,     0,
-       0,    67,    58,    59,    60,    61,    62,    63,     0,     0,
-      81,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   -87,     0,     0,
-       0,     0,     0,    67,     0,     0,   101,   102,     0,     0,
-       0,     0,    81,   103,   104,   105,   106,   107,   108,   109,
-     110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
-     -87,     0,     0,     0,     0,     0,     0,     0,     0,   101,
-     102,   136,     0,     0,     0,     0,   103,   104,   105,   106,
-     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
-     117,   118,   119,   103,   104,   105,     0,     0,     0,     0,
-     103,   104,   105,   113,   114,   115,   116,   117,   118,   119,
-     113,   114,   115,   116,   117,   118,   119,     0,     0,     0,
-       0,   136,   103,   104,   105,     0,     0,     0,   176,   103,
-     104,   105,   113,   114,   115,   116,   117,   118,   119,   113,
-     114,   115,   116,   117,   118,   119,     0,     0,     0,     0,
-     177,   103,   104,   105,     0,     0,     0,   178,   103,   104,
-     105,   113,   114,   115,   116,   117,   118,   119,   113,   114,
-     115,   116,   117,   118,   119,     0,     0,     0,     0,   179,
-     103,   104,   105,     0,     0,     0,   180,   103,   104,   105,
-     113,   114,   115,   116,   117,   118,   119,   113,   114,   115,
-     116,   117,   118,   119,     0,     0,     0,     0,   181,   103,
-     104,   105,     0,     0,     0,   207,   103,   104,   105,   113,
+      18,   122,   144,   125,   126,     4,   215,   129,   130,   131,
+     132,   133,   134,   217,   167,   168,   169,   170,    20,   138,
+     141,   142,    11,    12,    13,   149,   150,   151,   152,   153,
+     154,   155,   156,   157,   158,   159,   160,   161,   162,   163,
+     164,   165,   166,   117,   118,   119,   173,    46,    47,    48,
+      49,    21,    50,    51,    16,    52,    75,    76,    98,    99,
+      22,    53,    54,    55,    56,   184,   185,    57,    24,    58,
+      59,    60,    61,    62,    63,   -48,   -48,    25,    64,    65,
+     190,    46,    27,    48,    49,    31,    50,    51,    30,    52,
+     200,   201,   209,   210,    33,    53,    54,    55,    56,    66,
+      67,    35,    38,    58,    59,    60,    61,    62,    63,    68,
+     113,   114,   115,   116,   117,   118,   119,    39,   202,   204,
+      44,    84,    85,   100,    46,   148,    48,    49,   212,    50,
+      51,    80,    52,   213,    67,    86,   216,    87,    53,    54,
+      88,   121,    89,    81,   137,   123,    58,    59,    60,    61,
+      62,    63,   135,   175,    99,   189,    46,   196,    48,    49,
+     195,    50,    51,   205,    52,   206,     9,   214,    34,    45,
+      53,    54,   198,   176,   207,    82,   172,    67,    58,    59,
+      60,    61,    62,    63,   147,     0,    81,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,   -88,     0,     0,     0,     0,     0,    67,
+       0,     0,   101,   102,     0,     0,     0,     0,    81,   103,
+     104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
+     114,   115,   116,   117,   118,   119,   -88,     0,     0,     0,
+       0,     0,     0,     0,     0,   101,   102,   136,     0,     0,
+       0,     0,   103,   104,   105,   106,   107,   108,   109,   110,
+     111,   112,   113,   114,   115,   116,   117,   118,   119,   103,
+     104,   105,     0,     0,     0,     0,   103,   104,   105,   113,
      114,   115,   116,   117,   118,   119,   113,   114,   115,   116,
-     117,   118,   119,     0,     0,   173,   103,   104,   105,     0,
-       0,     0,   182,   103,   104,   105,   113,   114,   115,   116,
+     117,   118,   119,     0,     0,     0,     0,   136,   103,   104,
+     105,     0,     0,     0,   177,   103,   104,   105,   113,   114,
+     115,   116,   117,   118,   119,   113,   114,   115,   116,   117,
+     118,   119,     0,     0,     0,     0,   178,   103,   104,   105,
+       0,     0,     0,   179,   103,   104,   105,   113,   114,   115,
+     116,   117,   118,   119,   113,   114,   115,   116,   117,   118,
+     119,     0,     0,     0,     0,   180,   103,   104,   105,     0,
+       0,     0,   181,   103,   104,   105,   113,   114,   115,   116,
      117,   118,   119,   113,   114,   115,   116,   117,   118,   119,
-     186
+       0,     0,     0,     0,   182,   103,   104,   105,     0,     0,
+       0,   208,   103,   104,   105,   113,   114,   115,   116,   117,
+     118,   119,   113,   114,   115,   116,   117,   118,   119,     0,
+       0,   174,   103,   104,   105,     0,     0,     0,   183,   103,
+     104,   105,   113,   114,   115,   116,   117,   118,   119,   113,
+     114,   115,   116,   117,   118,   119,   187
 };
 
 static const yytype_int16 yycheck[] =
 {
       38,    30,     9,    68,    63,    10,     0,     1,    13,     3,
-       4,     5,    14,    15,    22,    15,    42,    43,     9,    27,
-      57,    28,    66,    42,    43,     9,    68,    69,    66,    71,
+       4,     5,    14,    15,    22,    10,    42,    43,    15,    27,
+      57,    28,    17,    42,    43,     9,    68,    69,    66,    71,
       67,    68,    97,    56,    57,    58,    59,    60,    40,    41,
-      64,    78,    71,    80,    81,    39,    72,    84,    85,    86,
-      87,    88,    89,    72,    18,    19,    20,    21,     9,    96,
+       9,    78,    71,    80,    81,    39,    72,    84,    85,    86,
+      87,    88,    89,    72,    18,    19,    20,    21,    64,    96,
       98,    99,     3,     4,     5,   102,   103,   104,   105,   106,
      107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
-     117,   118,   119,    58,    59,    60,   123,    15,    16,     9,
-      10,    11,    12,     6,    14,    15,    66,    17,    42,    43,
-      72,    73,     7,    23,    24,    25,    26,    42,    43,    29,
-       9,    31,    32,    33,    34,    35,    36,    72,    73,   184,
-      40,    41,    67,     9,    66,    11,    12,     8,    14,    15,
-      10,    17,    72,    73,    66,    65,    67,    23,    24,    25,
-      26,    61,    62,    69,    71,    31,    32,    33,    34,    35,
-      36,    71,    71,    71,    71,    71,    71,   194,   195,    54,
-      55,    56,    57,    58,    59,    60,    28,   205,    17,    71,
-       9,    72,   209,    17,    27,   213,    62,    43,     9,    10,
-      11,    12,    66,    14,    15,    71,    17,     3,    71,    68,
-      66,    28,    23,    24,    71,    36,    71,   121,   101,   187,
-      31,    32,    33,    34,    35,    36,   128,   200,    -1,    57,
-       9,    -1,    11,    12,    -1,    14,    15,    -1,    17,    -1,
-      -1,    -1,    -1,    -1,    23,    24,    -1,    -1,    -1,    -1,
-      -1,    62,    31,    32,    33,    34,    35,    36,    -1,    -1,
-      71,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    28,    -1,    -1,
-      -1,    -1,    -1,    62,    -1,    -1,    37,    38,    -1,    -1,
-      -1,    -1,    71,    44,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
-      28,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,
-      38,    72,    -1,    -1,    -1,    -1,    44,    45,    46,    47,
-      48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
-      58,    59,    60,    44,    45,    46,    -1,    -1,    -1,    -1,
-      44,    45,    46,    54,    55,    56,    57,    58,    59,    60,
-      54,    55,    56,    57,    58,    59,    60,    -1,    -1,    -1,
-      -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,    44,
-      45,    46,    54,    55,    56,    57,    58,    59,    60,    54,
-      55,    56,    57,    58,    59,    60,    -1,    -1,    -1,    -1,
-      72,    44,    45,    46,    -1,    -1,    -1,    72,    44,    45,
-      46,    54,    55,    56,    57,    58,    59,    60,    54,    55,
-      56,    57,    58,    59,    60,    -1,    -1,    -1,    -1,    72,
-      44,    45,    46,    -1,    -1,    -1,    72,    44,    45,    46,
-      54,    55,    56,    57,    58,    59,    60,    54,    55,    56,
-      57,    58,    59,    60,    -1,    -1,    -1,    -1,    72,    44,
-      45,    46,    -1,    -1,    -1,    72,    44,    45,    46,    54,
+     117,   118,   119,    58,    59,    60,   123,     9,    10,    11,
+      12,     9,    14,    15,    66,    17,    15,    16,    42,    43,
+       6,    23,    24,    25,    26,    72,    73,    29,    66,    31,
+      32,    33,    34,    35,    36,    42,    43,     7,    40,    41,
+     185,     9,     9,    11,    12,     8,    14,    15,    66,    17,
+      72,    73,    72,    73,    67,    23,    24,    25,    26,    61,
+      62,    10,    66,    31,    32,    33,    34,    35,    36,    71,
+      54,    55,    56,    57,    58,    59,    60,    65,   195,   196,
+      67,    71,    71,    28,     9,    10,    11,    12,   206,    14,
+      15,    69,    17,   210,    62,    71,   214,    71,    23,    24,
+      71,    17,    71,    71,     9,    71,    31,    32,    33,    34,
+      35,    36,    72,    27,    43,    66,     9,    71,    11,    12,
+      68,    14,    15,    66,    17,    71,     3,    71,    28,    36,
+      23,    24,   188,   128,   201,    57,   121,    62,    31,    32,
+      33,    34,    35,    36,   101,    -1,    71,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    28,    -1,    -1,    -1,    -1,    -1,    62,
+      -1,    -1,    37,    38,    -1,    -1,    -1,    -1,    71,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    56,    57,    58,    59,    60,    28,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    37,    38,    72,    -1,    -1,
+      -1,    -1,    44,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,    55,    56,    57,    58,    59,    60,    44,
+      45,    46,    -1,    -1,    -1,    -1,    44,    45,    46,    54,
       55,    56,    57,    58,    59,    60,    54,    55,    56,    57,
-      58,    59,    60,    -1,    -1,    70,    44,    45,    46,    -1,
-      -1,    -1,    70,    44,    45,    46,    54,    55,    56,    57,
+      58,    59,    60,    -1,    -1,    -1,    -1,    72,    44,    45,
+      46,    -1,    -1,    -1,    72,    44,    45,    46,    54,    55,
+      56,    57,    58,    59,    60,    54,    55,    56,    57,    58,
+      59,    60,    -1,    -1,    -1,    -1,    72,    44,    45,    46,
+      -1,    -1,    -1,    72,    44,    45,    46,    54,    55,    56,
+      57,    58,    59,    60,    54,    55,    56,    57,    58,    59,
+      60,    -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,
+      -1,    -1,    72,    44,    45,    46,    54,    55,    56,    57,
       58,    59,    60,    54,    55,    56,    57,    58,    59,    60,
-      68
+      -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,
+      -1,    72,    44,    45,    46,    54,    55,    56,    57,    58,
+      59,    60,    54,    55,    56,    57,    58,    59,    60,    -1,
+      -1,    70,    44,    45,    46,    -1,    -1,    -1,    70,    44,
+      45,    46,    54,    55,    56,    57,    58,    59,    60,    54,
+      55,    56,    57,    58,    59,    60,    68
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -934,14 +930,14 @@ static const yytype_uint8 yystos[] =
       51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
       90,    17,   108,    71,   101,   108,   108,     9,    28,   108,
      108,   108,   108,   108,   108,    72,    72,     9,   108,    93,
-      96,    95,    95,    30,    71,   103,    94,    10,   108,   108,
+      96,    95,    95,    30,    71,   103,    10,    94,    10,   108,
      108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
-     108,   108,   108,   108,   108,   108,    18,    19,    20,    21,
-      91,    90,   108,    70,    27,   103,    72,    72,    72,    72,
-      72,    72,    70,    72,    73,   104,    68,    97,    66,    96,
-      10,    13,   105,   106,    68,    71,   100,   101,    99,    72,
-      73,   108,   102,   108,    66,    71,   106,    72,    72,    73,
-      98,    95,   108,    71,    72,    95,    72
+     108,   108,   108,   108,   108,   108,   108,    18,    19,    20,
+      21,    91,    90,   108,    70,    27,   103,    72,    72,    72,
+      72,    72,    72,    70,    72,    73,   104,    68,    97,    66,
+      96,    10,    13,   105,   106,    68,    71,   100,   101,    99,
+      72,    73,   108,   102,   108,    66,    71,   106,    72,    72,
+      73,    98,    95,   108,    71,    72,    95,    72
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -1464,42 +1460,42 @@ yydestruct (yymsg, yytype, yyvaluep, yyscanner, compiler)
       case 9: /* "_IDENTIFIER_" */
 #line 178 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1468 "grammar.c"
+#line 1464 "grammar.c"
 	break;
       case 10: /* "_STRING_IDENTIFIER_" */
 #line 179 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1473 "grammar.c"
+#line 1469 "grammar.c"
 	break;
       case 11: /* "_STRING_COUNT_" */
 #line 180 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1478 "grammar.c"
+#line 1474 "grammar.c"
 	break;
       case 12: /* "_STRING_OFFSET_" */
 #line 181 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1483 "grammar.c"
+#line 1479 "grammar.c"
 	break;
       case 13: /* "_STRING_IDENTIFIER_WITH_WILDCARD_" */
 #line 182 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1488 "grammar.c"
+#line 1484 "grammar.c"
 	break;
       case 15: /* "_TEXT_STRING_" */
 #line 183 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1493 "grammar.c"
+#line 1489 "grammar.c"
 	break;
       case 16: /* "_HEX_STRING_" */
 #line 184 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1498 "grammar.c"
+#line 1494 "grammar.c"
 	break;
       case 17: /* "_REGEXP_" */
 #line 185 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1503 "grammar.c"
+#line 1499 "grammar.c"
 	break;
 
       default:
@@ -2610,6 +2606,25 @@ yyreduce:
   case 54:
 #line 936 "grammar.y"
     {
+        CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_STRING, "contains");
+
+        int result = yr_parser_reduce_string_identifier(
+            yyscanner,
+            (yyvsp[(3) - (3)].c_string),
+            OP_MATCHES_STR,
+            UNDEFINED); // XXX: UNDEFINED?
+
+        yr_free((yyvsp[(3) - (3)].c_string));
+
+        ERROR_IF(result != ERROR_SUCCESS);
+
+        (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
+      }
+    break;
+
+  case 55:
+#line 952 "grammar.y"
+    {
         int result = yr_parser_reduce_string_identifier(
             yyscanner,
             (yyvsp[(1) - (1)].c_string),
@@ -2624,8 +2639,8 @@ yyreduce:
       }
     break;
 
-  case 55:
-#line 950 "grammar.y"
+  case 56:
+#line 966 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "at");
 
@@ -2643,8 +2658,8 @@ yyreduce:
       }
     break;
 
-  case 56:
-#line 966 "grammar.y"
+  case 57:
+#line 982 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
@@ -2660,8 +2675,8 @@ yyreduce:
       }
     break;
 
-  case 57:
-#line 980 "grammar.y"
+  case 58:
+#line 996 "grammar.y"
     {
         int var_index;
 
@@ -2698,8 +2713,8 @@ yyreduce:
       }
     break;
 
-  case 58:
-#line 1015 "grammar.y"
+  case 59:
+#line 1031 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         int8_t* addr;
@@ -2736,8 +2751,8 @@ yyreduce:
       }
     break;
 
-  case 59:
-#line 1050 "grammar.y"
+  case 60:
+#line 1066 "grammar.y"
     {
         int mem_offset;
 
@@ -2815,8 +2830,8 @@ yyreduce:
       }
     break;
 
-  case 60:
-#line 1126 "grammar.y"
+  case 61:
+#line 1142 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         int8_t* addr;
@@ -2848,8 +2863,8 @@ yyreduce:
       }
     break;
 
-  case 61:
-#line 1156 "grammar.y"
+  case 62:
+#line 1172 "grammar.y"
     {
         int mem_offset;
 
@@ -2898,8 +2913,8 @@ yyreduce:
       }
     break;
 
-  case 62:
-#line 1203 "grammar.y"
+  case 63:
+#line 1219 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_OF, NULL);
 
@@ -2907,8 +2922,8 @@ yyreduce:
       }
     break;
 
-  case 63:
-#line 1209 "grammar.y"
+  case 64:
+#line 1225 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_NOT, NULL);
 
@@ -2916,8 +2931,8 @@ yyreduce:
       }
     break;
 
-  case 64:
-#line 1215 "grammar.y"
+  case 65:
+#line 1231 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_AND, NULL);
 
@@ -2925,8 +2940,8 @@ yyreduce:
       }
     break;
 
-  case 65:
-#line 1221 "grammar.y"
+  case 66:
+#line 1237 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_BOOLEAN, "or");
 
@@ -2936,8 +2951,8 @@ yyreduce:
       }
     break;
 
-  case 66:
-#line 1229 "grammar.y"
+  case 67:
+#line 1245 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<");
@@ -2948,8 +2963,8 @@ yyreduce:
       }
     break;
 
-  case 67:
-#line 1238 "grammar.y"
+  case 68:
+#line 1254 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">");
@@ -2960,8 +2975,8 @@ yyreduce:
       }
     break;
 
-  case 68:
-#line 1247 "grammar.y"
+  case 69:
+#line 1263 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<=");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<=");
@@ -2972,8 +2987,8 @@ yyreduce:
       }
     break;
 
-  case 69:
-#line 1256 "grammar.y"
+  case 70:
+#line 1272 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">=");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">=");
@@ -2984,8 +2999,8 @@ yyreduce:
       }
     break;
 
-  case 70:
-#line 1265 "grammar.y"
+  case 71:
+#line 1281 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3014,8 +3029,8 @@ yyreduce:
       }
     break;
 
-  case 71:
-#line 1292 "grammar.y"
+  case 72:
+#line 1308 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3044,8 +3059,8 @@ yyreduce:
       }
     break;
 
-  case 72:
-#line 1319 "grammar.y"
+  case 73:
+#line 1335 "grammar.y"
     {
         if ((yyvsp[(1) - (3)].expression).type != (yyvsp[(3) - (3)].expression).type)
         {
@@ -3074,32 +3089,32 @@ yyreduce:
       }
     break;
 
-  case 73:
-#line 1346 "grammar.y"
+  case 74:
+#line 1362 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
     break;
 
-  case 74:
-#line 1350 "grammar.y"
+  case 75:
+#line 1366 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
-  case 75:
-#line 1357 "grammar.y"
+  case 76:
+#line 1373 "grammar.y"
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
     break;
 
-  case 76:
-#line 1358 "grammar.y"
+  case 77:
+#line 1374 "grammar.y"
     { (yyval.integer) = INTEGER_SET_RANGE; }
     break;
 
-  case 77:
-#line 1364 "grammar.y"
+  case 78:
+#line 1380 "grammar.y"
     {
         if ((yyvsp[(2) - (6)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3119,8 +3134,8 @@ yyreduce:
       }
     break;
 
-  case 78:
-#line 1386 "grammar.y"
+  case 79:
+#line 1402 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3134,8 +3149,8 @@ yyreduce:
       }
     break;
 
-  case 79:
-#line 1398 "grammar.y"
+  case 80:
+#line 1414 "grammar.y"
     {
         if ((yyvsp[(3) - (3)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3148,61 +3163,61 @@ yyreduce:
       }
     break;
 
-  case 80:
-#line 1413 "grammar.y"
+  case 81:
+#line 1429 "grammar.y"
     {
         // Push end-of-list marker
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
       }
     break;
 
-  case 82:
-#line 1419 "grammar.y"
+  case 83:
+#line 1435 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
         yr_parser_emit_pushes_for_strings(yyscanner, "$*");
       }
     break;
 
-  case 85:
-#line 1434 "grammar.y"
+  case 86:
+#line 1450 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
       }
     break;
 
-  case 86:
-#line 1439 "grammar.y"
+  case 87:
+#line 1455 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
       }
     break;
 
-  case 88:
-#line 1449 "grammar.y"
+  case 89:
+#line 1465 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
       }
     break;
 
-  case 89:
-#line 1453 "grammar.y"
+  case 90:
+#line 1469 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL);
       }
     break;
 
-  case 90:
-#line 1461 "grammar.y"
+  case 91:
+#line 1477 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
-  case 91:
-#line 1465 "grammar.y"
+  case 92:
+#line 1481 "grammar.y"
     {
         compiler->last_result = yr_parser_emit(
             yyscanner, OP_FILESIZE, NULL);
@@ -3214,8 +3229,8 @@ yyreduce:
       }
     break;
 
-  case 92:
-#line 1475 "grammar.y"
+  case 93:
+#line 1491 "grammar.y"
     {
         yywarning(yyscanner,
             "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
@@ -3230,8 +3245,8 @@ yyreduce:
       }
     break;
 
-  case 93:
-#line 1488 "grammar.y"
+  case 94:
+#line 1504 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int8");
 
@@ -3245,8 +3260,8 @@ yyreduce:
       }
     break;
 
-  case 94:
-#line 1500 "grammar.y"
+  case 95:
+#line 1516 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int16");
 
@@ -3260,8 +3275,8 @@ yyreduce:
       }
     break;
 
-  case 95:
-#line 1512 "grammar.y"
+  case 96:
+#line 1528 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "int32");
 
@@ -3275,8 +3290,8 @@ yyreduce:
       }
     break;
 
-  case 96:
-#line 1524 "grammar.y"
+  case 97:
+#line 1540 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint8");
 
@@ -3290,8 +3305,8 @@ yyreduce:
       }
     break;
 
-  case 97:
-#line 1536 "grammar.y"
+  case 98:
+#line 1552 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint16");
 
@@ -3305,8 +3320,8 @@ yyreduce:
       }
     break;
 
-  case 98:
-#line 1548 "grammar.y"
+  case 99:
+#line 1564 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "uint32");
 
@@ -3320,8 +3335,8 @@ yyreduce:
       }
     break;
 
-  case 99:
-#line 1560 "grammar.y"
+  case 100:
+#line 1576 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL);
@@ -3333,8 +3348,8 @@ yyreduce:
       }
     break;
 
-  case 100:
-#line 1570 "grammar.y"
+  case 101:
+#line 1586 "grammar.y"
     {
         SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
         char* string;
@@ -3359,8 +3374,8 @@ yyreduce:
       }
     break;
 
-  case 101:
-#line 1593 "grammar.y"
+  case 102:
+#line 1609 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
@@ -3377,8 +3392,8 @@ yyreduce:
       }
     break;
 
-  case 102:
-#line 1608 "grammar.y"
+  case 103:
+#line 1624 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
             yyscanner,
@@ -3395,8 +3410,8 @@ yyreduce:
       }
     break;
 
-  case 103:
-#line 1623 "grammar.y"
+  case 104:
+#line 1639 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner,
@@ -3420,8 +3435,8 @@ yyreduce:
       }
     break;
 
-  case 104:
-#line 1645 "grammar.y"
+  case 105:
+#line 1661 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1)  // loop identifier
         {
@@ -3460,8 +3475,8 @@ yyreduce:
       }
     break;
 
-  case 105:
-#line 1682 "grammar.y"
+  case 106:
+#line 1698 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "+");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "+");
@@ -3473,8 +3488,8 @@ yyreduce:
       }
     break;
 
-  case 106:
-#line 1692 "grammar.y"
+  case 107:
+#line 1708 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "-");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "-");
@@ -3486,8 +3501,8 @@ yyreduce:
       }
     break;
 
-  case 107:
-#line 1702 "grammar.y"
+  case 108:
+#line 1718 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "*");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "*");
@@ -3499,8 +3514,8 @@ yyreduce:
       }
     break;
 
-  case 108:
-#line 1712 "grammar.y"
+  case 109:
+#line 1728 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "\\");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "\\");
@@ -3512,8 +3527,8 @@ yyreduce:
       }
     break;
 
-  case 109:
-#line 1722 "grammar.y"
+  case 110:
+#line 1738 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
@@ -3525,8 +3540,8 @@ yyreduce:
       }
     break;
 
-  case 110:
-#line 1732 "grammar.y"
+  case 111:
+#line 1748 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3538,8 +3553,8 @@ yyreduce:
       }
     break;
 
-  case 111:
-#line 1742 "grammar.y"
+  case 112:
+#line 1758 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3551,8 +3566,8 @@ yyreduce:
       }
     break;
 
-  case 112:
-#line 1752 "grammar.y"
+  case 113:
+#line 1768 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
@@ -3564,8 +3579,8 @@ yyreduce:
       }
     break;
 
-  case 113:
-#line 1762 "grammar.y"
+  case 114:
+#line 1778 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(2) - (2)].expression), EXPRESSION_TYPE_INTEGER, "~");
 
@@ -3577,8 +3592,8 @@ yyreduce:
       }
     break;
 
-  case 114:
-#line 1772 "grammar.y"
+  case 115:
+#line 1788 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
@@ -3590,8 +3605,8 @@ yyreduce:
       }
     break;
 
-  case 115:
-#line 1782 "grammar.y"
+  case 116:
+#line 1798 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
@@ -3603,8 +3618,8 @@ yyreduce:
       }
     break;
 
-  case 116:
-#line 1792 "grammar.y"
+  case 117:
+#line 1808 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
@@ -3612,7 +3627,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 3616 "grammar.c"
+#line 3631 "grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3826,6 +3841,6 @@ yyreturn:
 }
 
 
-#line 1797 "grammar.y"
+#line 1813 "grammar.y"
 
 
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 6b613bd..5e114c3 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -932,6 +932,22 @@ expression
 
         $$.type = EXPRESSION_TYPE_BOOLEAN;
       }
+    | primary_expression _MATCHES_ _STRING_IDENTIFIER_
+      {
+        CHECK_TYPE($1, EXPRESSION_TYPE_STRING, "contains");
+
+        int result = yr_parser_reduce_string_identifier(
+            yyscanner,
+            $3,
+            OP_MATCHES_STR,
+            UNDEFINED); // XXX: UNDEFINED?
+
+        yr_free($3);
+
+        ERROR_IF(result != ERROR_SUCCESS);
+
+        $$.type = EXPRESSION_TYPE_BOOLEAN;
+      }
     | _STRING_IDENTIFIER_
       {
         int result = yr_parser_reduce_string_identifier(
diff --git a/libyara/include/yara/exec.h b/libyara/include/yara/exec.h
index 2d9cef4..9dfea1b 100644
--- a/libyara/include/yara/exec.h
+++ b/libyara/include/yara/exec.h
@@ -85,6 +85,7 @@ limitations under the License.
 #define OP_IMPORT         55
 #define OP_LOOKUP_DICT    56
 #define OP_CONTAINS_STR   57
+#define OP_MATCHES_STR    58
 
 
 #define OPERATION(operator, op1, op2) \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list