Add syntax highlighting for SELinux kernel policy language
ClosedPublic

Authored by nibags on Aug 26 2018, 4:13 PM.

Details

Summary

This corresponds to the standard policy language of SELinux [1], used for example, by the SELinux Reference Policy [2] or the Android policies [3][4].

Extensions and files to highlight:

  • SELinux Type Enforcement (*.te)
  • SELinux Interface File (*.if)
  • M 4 Macros of Reference Policy (*.spt)
  • Some policy build files and policy config. files (access_vectors, mls, mcs, mls_macros, te_macros, policy_capabilities, seapp_contexts, port_contexts), and monolithic policy (policy.conf). NOTE: I added only relevant configuration files and policy building, since many have very generic names.

Also, this file contains common rules and keywords between selinux-fc.xml and selinux-cil.xml. For example, it contains the RegExp highlighting and the Permissions keywords. The idea is to avoid having repeated keywords and rules between the SELinux highlighting files.

References:
[1] SELinux Wiki. PolicyLanguage: https://selinuxproject.org/page/PolicyLanguage#Kernel_Policy_Language
[2] SELinux Reference Policy: https://github.com/SELinuxProject/refpolicy/wiki
[3] Security-Enhanced Linux in Android: https://source.android.com/security/selinux/
[4] SELinux policy configuration for AOSP: https://android.googlesource.com/platform/system/sepolicy/

Diff Detail

Repository
R216 Syntax Highlighting
Branch
add-selinux
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 2383
Build 2401: arc lint + arc unit
nibags created this revision.Aug 26 2018, 4:13 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptAug 26 2018, 4:13 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Aug 26 2018, 4:13 PM
nibags edited the summary of this revision. (Show Details)Aug 26 2018, 4:16 PM
cullmann accepted this revision.Aug 26 2018, 7:26 PM
This revision is now accepted and ready to land.Aug 26 2018, 7:26 PM
nibags updated this revision to Diff 40492.EditedAug 27 2018, 9:31 AM
  • Remove deprecated permissions (7 keywords)

I'll do the commit this week, because I want to do a last test...

nibags updated this revision to Diff 40763.EditedAug 31 2018, 12:38 PM
  • Update

I checked the highlight in several policies and made some changes:

  • I verify that SELinux does not support multi-line strings (neither line continuation escapes).
  • Small improvements in the detection of MLS/MCS Levels.
  • Added "#line" of m4 (appears in the parser and I forgot to add).

The file is OK. If there is no problem, I will do commit.

nibags updated this revision to Diff 40769.Aug 31 2018, 1:45 PM
  • Small correction in a comment
nibags closed this revision.Aug 31 2018, 4:37 PM