Skip to content

SELinux Policies Syntax Highlighting Definition for Kate (KSyntaxHighlighting Framework)

License

Notifications You must be signed in to change notification settings

nibags/selinux-ksyntaxhighlighting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SELinux Policies Syntax Highlighting Definition for Kate (KSyntaxHighlighting Framework)

Example of SELinux policies (CIL policy & TE module) syntax highlighting

Author: Nibaldo González ([email protected])

Last Change: February 2021

Requirements: KDE Frameworks 5.80.0 or higher

These files are part of the KDE's KSyntaxHighlighting Framework.

Description:

Add syntax highlighting to KDE text editors (such as Kate, KWrite, KDevelop or any application that uses the KSyntaxHighlighting or KTextEditor Framework) for:

  • SELinux Kernel Policy Language (selinux.xml).
  • SELinux CIL Policies (selinux-cil.xml).
  • SELinux File Contexts (selinux-fc.xml).

NOTE: selinux-cil.xml and selinux-fc.xml depend on selinux.xml.

For details on the syntax of SELinux policies, visit:

About XML Files of Syntax Highlighting Definition:

The syntax highlighting definition files, of the KSyntaxHighlighting Framework, consist of XML files that are compiled in the KDE Frameworks libraries.

However, these XML files can also be stored in:

For local user $HOME/.local/share/org.kde.syntax-highlighting/syntax/
For all users /usr/share/org.kde.syntax-highlighting/syntax/
For Flatpak packages $HOME/.var/app/package-name/data/org.kde.syntax-highlighting/syntax/
For Snap packages $HOME/snap/package-name/current/.local/share/org.kde.syntax-highlighting/syntax/
On Windows %USERPROFILE%\AppData\Local\org.kde.syntax-highlighting\syntax\
On macOS $HOME/Library/Application Support/org.kde.syntax-highlighting/syntax/

For more details of KSyntaxHighlighting Framework, visit:

Installation:

Important: selinux-cil.xml & selinux-fc.xml depend on selinux.xml. To avoid problems, do not install the files separately, but the 3 together.

If you do not have the latest version of KDE Frameworks, you can manually install the latest .xml files.

Copy the .xml files to the directory of the XML syntax definition files, mentioned in the previous section.

Ex.: For local user:

mkdir -p $HOME/.local/share/org.kde.syntax-highlighting/syntax/
cp ./selinux{,-cil,-fc}.xml $HOME/.local/share/org.kde.syntax-highlighting/syntax/

For all users:

sudo mkdir -p /usr/share/org.kde.syntax-highlighting/syntax/
sudo cp ./selinux{,-cil,-fc}.xml /usr/share/org.kde.syntax-highlighting/syntax/

Usage:

Syntax highlighting of SELinux policies (selinux.xml) is automatically applied to named files: *.te, *.if, *.spt, policy.conf, access_vectors, mls, mcs, mls_macros, te_macros, policy_capabilities, seapp_contexts & port_contexts.

Syntax highlighting of SELinux file contexts is applied to named files: *.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.

Syntax highlighting of SELinux CIL policies is applied to files with .cil extension.

You can also force the syntax highlighting by writing a comment with:

kate: syntax SELinux Policy;
kate: syntax SELinux CIL Policy;
kate: syntax SELinux File Contexts;

List of Versions:

selinux.xml
Version
selinux-fc.xml
Version
Date KDE
Frameworks
SELinux
Support
(checkpolicy)
Relevant Changes
9 9 Feb. 24, 2021 5.80.0 3.0 Improve colors and performance of RegExpr rules.
5 7 Sep. 30, 2020 5.75.0 3.0 Use include keywords.
3 - Dec. 10, 2019 5.66.0 3.0
  • Add "glblub" keyword (default_range).
  • Update permissions list.
- 4 Apr. 02, 2019 5.57.0 2.8 / 2.9 No changes, only one indentation is removed.
2 3 Sep. 09, 2018 5.51.0 2.8 Update itemData's style for the new Solarized color schemes of Kate.
1 2 Aug. 28, 2018 5.50.0 2.8 Implement "selinux.xml": some rules and keywords of "selinux-fc.xml" are moved there.
- 1 Jan. 26, 2018 5.44.0 -
selinux-cil.xml
Version
Date KDE
Frameworks
SELinux
Support
(secilc)
Relevant Changes
10 Feb. 19, 2021 5.80.0 3.0 Improve performance of RegExpr rules.
7 Sep. 30, 2020 5.75.0 3.0 Use include keywords and improve color brackets.
5 Dec. 10, 2019 5.66.0 3.0 Add "glblub" keyword (defaultrange).
3 Apr. 02, 2019 5.57.0 2.8 / 2.9 No changes, only one indentation is removed.
2 Aug. 28, 2018 5.50.0 2.8
  • Add keywords of Android and BPF permissions.
  • Implement "selinux.xml": some rules and keywords of "selinux-cil.xml" are moved there.
1 Jan. 26, 2018 5.44.0 2.7