File: yara.lang

package info (click to toggle)
gtksourceview4 4.8.4-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 12,376 kB
  • sloc: ansic: 50,318; xml: 1,432; javascript: 856; perl: 212; sh: 150; php: 48; yacc: 45; ruby: 38; sql: 30; cobol: 20; objc: 19; lisp: 19; fortran: 14; python: 13; makefile: 13; cpp: 8; ml: 3
file content (195 lines) | stat: -rw-r--r-- 6,463 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of GtkSourceView

 Author: Wes Hurd <13hurdw@gmail.com>
 Copyright (C) 2017, 2020

 GtkSourceView is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 GtkSourceView is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, see <http://www.gnu.org/licenses/>.

-->


<language id="yara" name="YARA" version="2.0" _section="Other">
  <metadata>
    <property name="mimetypes">text/yara;text/x-yara</property>
    <property name="globs">*.yara;*.yar</property>
    <property name="line-comment-start">//</property>
    <property name="block-comment-start">/*</property>
    <property name="block-comment-end">*/</property>
  </metadata>

  <styles>
    <style id="comment"           name="Comment"               map-to="def:comment"/>
    <style id="include"           name="Include"               map-to="def:preprocessor"/>
    <style id="keyword"           name="Keyword"               map-to="def:keyword"/>
    <style id="rule"              name="Rule"                  map-to="def:function"/>
    <style id="string"            name="String"                map-to="def:string"/>
    <style id="escaped-character" name="Escaped Character"     map-to="def:special-char"/>
    <style id="decimal"           name="Decimal number"        map-to="def:decimal"/>
    <style id="hexadecimal"       name="Hexadecimal number"    map-to="def:base-n-integer"/>
    <style id="boolean"           name="Boolean value"         map-to="def:boolean"/>

    <style id="error"             name="Error"                 map-to="def:error"/>
  </styles>

  <definitions>

    <context id="include" style-ref="include">
      <keyword>include</keyword>
      <!-- 'import' is currently in keywords-->
    </context>

    <define-regex id="escaped-character" extended="true">
      \\(                   # leading backslash
      [\\\"nt] |   # escaped character
      x[0-9A-Fa-f]{2}         # hex char
      )
    </define-regex>

    <context id="string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
      <start>"</start>
      <end>"</end>
      <include>
        <context id="escaped-character" style-ref="escaped-character">
          <match>\%{escaped-character}</match>
        </context>
        <context ref="def:line-continue"/>
      </include>
    </context>

    <!-- Match on YARA hex string chars -->
    <context id="hex-string" style-ref="hexadecimal">
      <match extended="true">
        (?&lt;![\w\.])
        ([a-fA-F0-9?]{2})+
        (?![\w\.])
      </match>
    </context>

    <context id="hexadecimal" style-ref="hexadecimal">
      <match extended="true">
        (?&lt;![\w\.])
        0[xX][a-fA-F0-9]+
        (?![\w\.])
      </match>
    </context>

    <context id="invalid-hexadecimal" style-ref="error">
      <match extended="true">
        (?&lt;![\w\.])
        0[xX][a-fA-F0-9]*[g-zG-Z][a-zA-Z0-9]*
        (?![\w\.])
      </match>
    </context>

    <context id="decimal" style-ref="decimal">
      <match extended="true">
        (?&lt;![\w\.])
        (0|[1-9][0-9]*)
        (?![\w\.])
      </match>
    </context>

    <!-- 'rule' is also present in the 'keywords' context, but has a lower
         priority, so 'rule' is highlighted even if the rule name doesn't match. -->
    <context id="rule">
      <match extended="true">
        (rule)
        \s+
        ([a-zA-Z_]\w{0,127})
      </match>
      <include>
        <context sub-pattern="1" style-ref="keyword"/>
        <context sub-pattern="2" style-ref="rule"/>
      </include>
    </context>

    <context id="keywords" style-ref="keyword">
      <keyword>all</keyword>
      <keyword>and</keyword>
      <keyword>any</keyword>
      <keyword>ascii</keyword>
      <keyword>at</keyword>
      <keyword>base64</keyword>
      <keyword>base64wide</keyword>
      <keyword>condition</keyword>
      <keyword>contains</keyword>
      <keyword>endswith</keyword>
      <keyword>entrypoint</keyword> <!-- being deprecated-->
      <keyword>filesize</keyword>
      <keyword>for</keyword>
      <keyword>fullword</keyword>
      <keyword>global</keyword>
      <keyword>icontains</keyword>
      <keyword>iendswith</keyword>
      <keyword>iequals</keyword>
      <keyword>istartswith</keyword>
      <keyword>import</keyword>
      <keyword>in</keyword>
      <keyword>int8</keyword>
      <keyword>int16</keyword>
      <keyword>int32</keyword>
      <keyword>int8be</keyword>
      <keyword>int16be</keyword>
      <keyword>int32be</keyword>
      <keyword>matches</keyword>
      <keyword>meta</keyword>
      <keyword>nocase</keyword>
      <keyword>none</keyword>
      <keyword>not</keyword>
      <keyword>or</keyword>
      <keyword>of</keyword>
      <keyword>private</keyword>
      <keyword>rule</keyword>
      <keyword>startswith</keyword>
      <keyword>strings</keyword>
      <keyword>them</keyword>
      <keyword>uint8</keyword>
      <keyword>uint16</keyword>
      <keyword>uint32</keyword>
      <keyword>uint8be</keyword>
      <keyword>uint16be</keyword>
      <keyword>uint32be</keyword>
      <keyword>wide</keyword>
      <keyword>xor</keyword>
    </context>

    <context id="boolean" style-ref="boolean">
      <keyword>true</keyword>
      <keyword>false</keyword>
    </context>

    <!--Main context-->
    <context id="yara" class="no-spell-check">
      <include>
        <context ref="def:c-like-comment" style-ref="comment"/>
        <context ref="def:c-like-comment-multiline" style-ref="comment"/>
        <context ref="def:c-like-close-comment-outside-comment" style-ref="comment"/>
        <context ref="include"/>
        <context ref="string"/>
        <context ref="hex-string"/>
        <context ref="hexadecimal"/>
        <context ref="invalid-hexadecimal"/>
        <context ref="decimal"/>
        <context ref="rule"/>
        <context ref="keywords"/>
        <context ref="boolean"/>
      </include>
    </context>

  </definitions>
</language>