Warning, /frameworks/syntax-highlighting/data/syntax/selinux-fc.xml is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="UTF-8"?> 0002 <!DOCTYPE language 0003 [ 0004 <!-- Identifier with M4 Arg. or variables --> 0005 <!ENTITY charIden "(?:\$[@#]|[\w\-\$\*\{\}%])"> 0006 <!ENTITY simpleIdentifier "(?:\$[@#]|[a-zA-Z\$%])&charIden;*"> 0007 <!ENTITY identifier "&simpleIdentifier;(?:\.?&charIden;)*"> 0008 <!ENTITY startIdentifier "(?:\b[a-zA-Z]|\$[@#]|[\$%])&charIden;*(?:\.?&charIden;)*"> 0009 <!ENTITY mlsLevel "&identifier;(?:\s*\:\s*&identifier;(?:\s*,\s*&identifier;)*)?"> 0010 ]> 0011 0012 <!-- 0013 SELinux File Contexts Syntax Highlighting Definition 0014 =========================================================================== 0015 0016 This file is part of the KDE's KSyntaxHighlighting framework. 0017 0018 SPDX-FileCopyrightText: 2018-2020 Nibaldo González S. <nibgonz@gmail.com> 0019 0020 SPDX-License-Identifier: MIT 0021 0022 =========================================================================== 0023 0024 SELinux policy files with definitions of file contexts: 0025 - Labeling Policy Files: *.fc 0026 - Policy Config. Files: file_contexts, file_contexts_*, file_contexts.local, 0027 file_contexts.homedirs, file_contexts.template, homedir_template 0028 - SE for Android Policy Config. Files: service_contexts, property_contexts, 0029 hwservice_contexts 0030 - Policy Build Files: initial_sid_contexts, genfs_contexts, fs_use 0031 0032 Change log: 0033 * Version 7 [30-Sep-2020]: Use include-keywods and other minor changes. 0034 * Version 5 [03-Oct-2019]: Replace unnecessary WordDetect rules. 0035 * Version 4 [02-Apr-2019]: Remove one indentation. 0036 * Version 3 [09-Sep-2018]: 0037 - Update itemData's style for the new Solarized color schemes. 0038 * Version 2 [28-Aug-2018]: 0039 - Some improvements. RegExp and some rules are moved to "selinux.xml". 0040 - Add statements keywords that use file contexts. 0041 * Version 1 [26-Jan-2018, by Nibaldo González]: 0042 - Initial version. 0043 --> 0044 0045 <language name="SELinux File Contexts" 0046 version="9" 0047 kateversion="5.53" 0048 section="Other" 0049 extensions="*.fc;file_contexts;file_contexts_*;file_contexts.local;file_contexts.homedirs;file_contexts.template;homedir_template;property_contexts;service_contexts;hwservice_contexts;initial_sid_contexts;genfs_contexts;fs_use" 0050 priority="3" 0051 mimetype="" 0052 author="Nibaldo González (nibgonz@gmail.com)" 0053 license="MIT"> 0054 0055 <highlighting> 0056 0057 <list name="statements_fc"> 0058 <include>statements_fc##SELinux Policy</include> 0059 </list> 0060 <list name="refpolicy_keywords"> 0061 <include>refpolicy_keywords##SELinux Policy</include> 0062 </list> 0063 0064 <contexts> 0065 0066 <context name="_normal" attribute="Normal Text" lineEndContext="#stay"> 0067 <IncludeRules context="_m4_preprocessor##SELinux Policy"/> 0068 <IncludeRules context="_find_comments##SELinux Policy"/> 0069 <RegExpr context="#stay" attribute="File Type" String="(?:\s|^)\-[bcdpls\-](?=\s|$)"/> 0070 0071 <DetectChar context="_path_content" attribute="Path" char="/"/> 0072 <DetectChar context="_quoted" attribute="Text Quoted" char="""/> 0073 0074 <!-- Content Quoted (M4). 0075 NOTE: The default quotes (`text') are highlighted, 0076 but another type of quotation mark can be used. --> 0077 <IncludeRules context="_m4_string_simple##SELinux Policy"/> <!-- `simple text' --> 0078 <IncludeRules context="_m4_quotes##SELinux Policy"/> 0079 0080 <!-- File Contexts: user:role:type:s0:c0 --> 0081 <RegExpr context="_fc_user" attribute="User" String="&startIdentifier;(?=(?:\s*\:\s*&identifier;){2}(?:\s*\:\s*&mlsLevel;(?:\s*\-\s*&mlsLevel;)?)?\b)"/> 0082 <StringDetect context="#stay" attribute="Other Keywords" String="<<none>>"/> 0083 0084 <!-- Java-Language-Style Package Name & other Names, for SE Android (this avoid highlighting keywords) --> 0085 <RegExpr context="#stay" attribute="Path" String="\.?[a-zA-Z]\w*(?:(?:\.|::)\w+)+(?=[^\(]|$)" firstNonSpace="true"/> 0086 0087 <!-- Functions --> 0088 <DetectChar context="_parentheses_content" attribute="Normal Text" char="(" beginRegion="ParenthesesBlock"/> 0089 <keyword context="#stay" attribute="Refpolicy Keywords" String="refpolicy_keywords"/> 0090 <IncludeRules context="_m4_builtin_keywords##SELinux Policy"/> 0091 <RegExpr context="#stay" attribute="Function" String="\b[a-zA-Z][\w\-]*(?=\()"/> 0092 0093 <IncludeRules context="_m4_special_arguments##SELinux Policy"/> 0094 <IncludeRules context="_common_special_char##SELinux Policy"/> 0095 <IncludeRules context="_line_continue_escape##SELinux Policy"/> 0096 0097 <!-- Default Variables --> 0098 <StringDetect context="_path_content" attribute="Variable" String="HOME_DIR"/> 0099 <StringDetect context="_path_content" attribute="Variable" String="HOME_ROOT"/> 0100 0101 <DetectChar context="_path_content" attribute="Path" char="[" lookAhead="true"/> 0102 <Detect2Chars context="_path_content" char="%" char1="{" lookAhead="true"/> 0103 <RegExpr context="_path_content" attribute="Path" String="\b[\w\[\]\.@\=\*\-\$%\+!\|&\^~\{\}<>\?\\,]+[/\\\*\?\[\{]" lookAhead="true" firstNonSpace="true"/> 0104 0105 <DetectChar context="#stay" attribute="Symbol" char="{" beginRegion="Bracket"/> 0106 <DetectChar context="#stay" attribute="Symbol" char="}" endRegion="Bracket"/> 0107 <AnyChar context="#stay" attribute="Symbol" String=",;~[]"/> 0108 0109 <!-- Highlight only the statements that contain definition of file contexts --> 0110 <keyword context="#stay" attribute="Statements" String="statements_fc"/> 0111 <RegExpr context="#stay" String="[a-zA-Z](?:\.?[\w\-]+)*"/> 0112 <HlCHex context="#pop" attribute="Number"/> 0113 <Int context="#pop" attribute="Number"/> 0114 </context> 0115 0116 <context name="_parentheses_content" attribute="Normal Text" lineEndContext="#stay"> 0117 <DetectChar context="#pop" attribute="Normal Text" char=")" endRegion="ParenthesesBlock"/> 0118 <!-- File Contexts: (user:role:type,s0) --> 0119 <RegExpr context="_gen_context_fc_user" attribute="User" String="&startIdentifier;(?:\s*\:\s*&identifier;){2}(?:\s*,\s*&identifier;)*\b" lookAhead="true"/> 0120 <IncludeRules context="_normal"/> 0121 </context> 0122 0123 <context name="_path_content" attribute="Path" lineEndContext="#pop"> 0124 <DetectSpaces context="#pop" lookAhead="true"/> 0125 <IncludeRules context="_regex##SELinux Policy"/> 0126 <IncludeRules context="_variable"/> 0127 </context> 0128 <context name="_quoted" attribute="Text Quoted" lineEndContext="#pop"> 0129 <DetectChar context="#pop" attribute="Text Quoted" char="""/> 0130 <IncludeRules context="_m4_special_arguments##SELinux Policy"/> 0131 <IncludeRules context="_other_variable"/> 0132 <IncludeRules context="_regex_quoted##SELinux Policy"/> 0133 <RegExpr context="#stay" attribute="Text Quoted Open" String="[^\s"\[\(\\](?=\s*$)"/> 0134 </context> 0135 0136 <!-- Variables of "file_contexts", M4 & Refpolicy --> 0137 <context name="_variable" attribute="Normal Text" lineEndContext="#stay"> 0138 <WordDetect context="#stay" attribute="Variable" String="HOME_DIR"/> 0139 <WordDetect context="#stay" attribute="Variable" String="HOME_ROOT"/> 0140 <StringDetect context="#stay" attribute="Variable" String="USER"/> 0141 <StringDetect context="#stay" attribute="Variable" String="ROLE"/> 0142 <IncludeRules context="_other_variable"/> 0143 </context> 0144 <context name="_other_variable" attribute="Normal Text" lineEndContext="#stay"> 0145 <RegExpr context="#stay" attribute="Variable" String="\%\{[a-zA-Z]\w*\}"/> 0146 </context> 0147 <context name="_fc_variable" attribute="Path" lineEndContext="#pop"> 0148 <IncludeRules context="_m4_special_arguments##SELinux Policy"/> 0149 <IncludeRules context="_other_variable"/> 0150 </context> 0151 0152 <!-- SELinux Security Contexts --> 0153 0154 <!-- User --> 0155 <context name="_fc_user" attribute="User" lineEndContext="#pop"> 0156 <DetectChar context="#pop!_fc_role" attribute="Normal Text" char=":"/> 0157 </context> 0158 <!-- Role --> 0159 <context name="_fc_role" attribute="Role" lineEndContext="#pop"> 0160 <DetectChar context="#pop!_fc_type" attribute="Normal Text" char=":"/> 0161 </context> 0162 <!-- Type Enforcement --> 0163 <context name="_fc_type" attribute="Type Enforcement" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0164 <RegExpr context="#pop!_fc_mls" attribute="Type Enforcement" String="\s*&identifier;(?=\s*:\s*&mlsLevel;)"/> <!-- Find MLS/MCS --> 0165 <RegExpr context="#pop" attribute="Type Enforcement" String="\s*&identifier;"/> 0166 </context> 0167 0168 <!-- Start MLS/MCS --> 0169 <context name="_fc_mls" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0170 <DetectChar context="#pop!_fc_find_level_range" attribute="Normal Text" char=":"/> 0171 <DetectSpaces context="#stay" attribute="Normal Text"/> 0172 </context> 0173 <context name="_fc_find_level_range" attribute="MLS/MCS Level" 0174 lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_fc_level_range"> 0175 <DetectSpaces context="#stay" attribute="Normal Text"/> 0176 </context> 0177 <!-- MLS/MCS Range (Sensitivity:Category - Sensitivity:Category) --> 0178 <!-- Sensitivity --> 0179 <context name="_fc_level_range" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0180 <RegExpr context="#pop!_fc_level_range_cat" attribute="Normal Text" String="\s*:\s*(?=&identifier;)"/> <!-- Find Category --> 0181 <RegExpr context="#pop!_fc_level" attribute="Normal Text" String="\s*\-\s*(?=&mlsLevel;)"/> <!-- Find Range --> 0182 <IncludeRules context="_default_level"/> 0183 </context> 0184 <!-- Category --> 0185 <context name="_fc_level_range_cat" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0186 <RegExpr context="#pop!_fc_level" attribute="Normal Text" String="\s*\-\s*(?=&mlsLevel;)"/> <!-- Find Range --> 0187 <RegExpr context="#stay" attribute="Normal Text" String="\s*,\s*(?=&simpleIdentifier;)"/> 0188 <IncludeRules context="_default_level"/> 0189 </context> 0190 <!-- MLS/MCS Level (Sensitivity:Category) --> 0191 <!-- Sensitivity --> 0192 <context name="_fc_level" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0193 <RegExpr context="#pop!_fc_level_cat" attribute="Normal Text" String="\s*:\s*(?=&identifier;)"/> <!-- Find Category --> 0194 <IncludeRules context="_default_level"/> 0195 </context> 0196 <!-- Category --> 0197 <context name="_fc_level_cat" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_after_fc"> 0198 <RegExpr context="#stay" attribute="Normal Text" String="\s*,\s*(?=&simpleIdentifier;)"/> 0199 <IncludeRules context="_default_level"/> 0200 </context> 0201 0202 <context name="_default_level" attribute="Normal Text" lineEndContext="#pop"> 0203 <RegExpr context="#stay" attribute="Normal Text" String="\s*\.\s*(?=&charIden;)"/> 0204 <DetectChar context="_default_level_arg" attribute="MLS/MCS Level" char="$"/> 0205 <DetectChar context="_default_level_var" attribute="MLS/MCS Level" char="%"/> 0206 <RegExpr context="#stay" attribute="MLS/MCS Level" String="\w+"/> 0207 <DetectChar context="#stay" attribute="MLS/MCS Level" char="-"/> 0208 </context> 0209 <context name="_default_level_arg" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> 0210 <!-- M4 Args. It is not exact --> 0211 <Int context="#pop" attribute="MLS/MCS Level"/> 0212 <AnyChar context="#pop" attribute="MLS/MCS Level" String="#*@"/> 0213 <RegExpr context="#pop" attribute="MLS/MCS Level" String="\{\d+\}"/> 0214 </context> 0215 <context name="_default_level_var" attribute="MLS/MCS Level" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> 0216 <RegExpr context="#pop" attribute="MLS/MCS Level" String="{[A-Za-z]\w*\}"/> 0217 </context> 0218 0219 <context name="_after_fc" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> 0220 <RegExpr context="#stay" attribute="Normal Text" String="\s*:\s*\w*|[:\.\w]+"/> 0221 </context> 0222 0223 <!-- Within function "gen_context" (highlight variables and M4 args.) --> 0224 <!-- User --> 0225 <context name="_gen_context_fc_user" attribute="User" lineEndContext="#pop"> 0226 <DetectChar context="#pop!_gen_context_role" attribute="Normal Text" char=":"/> 0227 <IncludeRules context="_fc_variable"/> 0228 </context> 0229 <!-- Role --> 0230 <context name="_gen_context_role" attribute="Role" lineEndContext="#pop"> 0231 <DetectChar context="#pop!_before_gen_context_type" attribute="Normal Text" char=":"/> 0232 <IncludeRules context="_fc_variable"/> 0233 </context> 0234 <!-- Type Enforcement --> 0235 <context name="_before_gen_context_type" attribute="Type Enforcement" 0236 lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!_gen_context_type"> 0237 <DetectSpaces context="#stay" attribute="Normal Text"/> 0238 </context> 0239 <context name="_gen_context_type" attribute="Type Enforcement" 0240 lineEndContext="#pop!_fc_find_comma" fallthrough="true" fallthroughContext="#pop!_fc_find_comma"> 0241 <RegExpr context="#pop!_fc_level_range" attribute="Normal Text" String="\s*:\s*(?=&identifier;)"/> <!-- Find MLS/MCS --> 0242 <IncludeRules context="_fc_variable"/> 0243 <RegExpr context="#stay" attribute="Type Enforcement" String="[\w\-]+"/> 0244 </context> 0245 <!-- Comma after file contexts --> 0246 <context name="_fc_find_comma" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> 0247 <DetectChar context="#pop!_fc_after_comma" attribute="Normal Text" char=","/> 0248 <RegExpr context="#pop" String="\s*[^,\s]" lookAhead="true"/> 0249 <DetectSpaces /> 0250 </context> 0251 <context name="_fc_after_comma" attribute="Normal Text" 0252 lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!_gen_context_level"> 0253 <DetectSpaces context="#stay"/> 0254 </context> 0255 <!-- MLS/MCS --> 0256 <context name="_gen_context_level" attribute="MLS/MCS Level" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> 0257 <RegExpr context="#stay" attribute="Normal Text" String="\-\s*(?=&simpleIdentifier;)"/> 0258 <IncludeRules context="_fc_variable"/> 0259 <RegExpr context="#stay" attribute="MLS/MCS Level" String="\w+"/> 0260 <DetectChar context="#stay" attribute="MLS/MCS Level" char="-"/> 0261 <AnyChar context="#stay" attribute="Normal Text" String=":.,"/> 0262 <DetectSpaces /> 0263 </context> 0264 0265 </contexts> 0266 0267 <itemDatas> 0268 <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/> 0269 <itemData name="Text Quoted" defStyleNum="dsString" spellChecking="false"/> 0270 <itemData name="Path" defStyleNum="dsNormal" spellChecking="false"/> 0271 <itemData name="Variable" defStyleNum="dsVariable" spellChecking="false"/> 0272 <itemData name="File Type" defStyleNum="dsKeyword" spellChecking="false"/> 0273 0274 <itemData name="User" defStyleNum="dsPreprocessor" bold="0" italic="0" underline="0" spellChecking="false"/> 0275 <itemData name="Role" defStyleNum="dsInformation" bold="0" italic="0" underline="0" spellChecking="false"/> 0276 <itemData name="Type Enforcement" defStyleNum="dsAttribute" bold="0" italic="0" underline="0" spellChecking="false"/> 0277 <itemData name="MLS/MCS Level" defStyleNum="dsVerbatimString" bold="0" italic="0" underline="0" spellChecking="false"/> 0278 0279 <itemData name="Other Keywords" defStyleNum="dsNormal" italic="1" spellChecking="false"/> 0280 <itemData name="Statements" defStyleNum="dsKeyword" bold="1" spellChecking="false"/> 0281 <itemData name="Refpolicy Keywords" defStyleNum="dsNormal" bold="1" spellChecking="false"/> 0282 <itemData name="Function" defStyleNum="dsNormal" bold="1" spellChecking="false"/> 0283 <itemData name="Symbol" defStyleNum="dsOperator" spellChecking="false"/> 0284 <itemData name="Number" defStyleNum="dsComment" bold="0" italic="0" underline="0" spellChecking="false"/> 0285 <itemData name="Text Quoted Open" defStyleNum="dsString" underline="1" spellChecking="false"/> 0286 </itemDatas> 0287 0288 </highlighting> 0289 0290 <general> 0291 <keywords casesensitive="true" additionalDeliminator=""'`" weakDeliminator="*?+.-"/> 0292 <comments> 0293 <comment name="singleLine" start="#"/> 0294 </comments> 0295 </general> 0296 0297 </language> 0298 <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; -->