AppArmor: update syntax and various improvements/fixes
ClosedPublic

Authored by nibags on Jul 31 2018, 9:08 PM.

Details

Summary

I have updated and checked the syntax highlighting of AppArmor with various improvements.

Changes in AppArmor:

  • AppArmor 2.13: adds "if exists" in Include rules. Ex: #include if exists <path>. Previously, the text after "include" was highlighted as "Error", that is corrected.
  • Fix: allow spaces in relative paths, in Include rules.
  • Fix escape characters: add decimals (\dNNN) and only valid octales are highlighted (the maximum value is \400). Any character is also highlighted as escape (literal characters). Before, only special characters are highlighted.
  • Improves the detection of paths that start with a variable. For example, when writing a variable and then a non-ASCII character, it is highlighted as path (Ex: @{VAR}ñpath*).
  • Improve variable assignment lines:
    • Add line continuation escape.
    • Allow assignment (= or +=) in a new line.
    • Removes unnecessary rules in _variable_assignment_line_content context. Now the entire line is highlighted as path.
  • Improve the highlighting of Hats/Sub-profiles (name//HAT). Add hats in quoted paths and transition profile names (before it was only highlighted in paths). The itemData "SubProfile" changes to "SubProfile/Hat".
  • Improve comments: underlines URLs and e-mails.
  • Add extensions snap.*, snap-update-ns.* & snap-confine.* (these are the prefixes of the AppArmor profiles for the Snap packages. Some are located in "/var/lib/snapd/apparmor").
  • Add some filesystems, new abstractions and "xattrs" flag (keywords).
  • Add paths that start with namespaces: :namespace:/path.
  • Fixes globbing brackets in quoted text. Now the bracket content allows spaces and line breaks.
  • Fix the escape of "/" in profile name and transition profile name (before, it is highlighted as path).
  • Simplifies the closing of rules (comma of end of rules).
  • The code to detect variables & booleans is simplified.
  • Fix booleans: true & false keywords are insensitive; booleans will not be highlighted within rules.
  • The operators "in" & "to" are put in a different context (_operators_keywords). Now these are only highlighted within the AppArmor-rules.
  • Removes unnecessary RegExpr rules in the path detection. Now only the "/" character marks the beginning of a path.
  • The special character "^" is only highlighted at the beginning of the square bracket. Ex: [^ ...]
  • Improves the highlighting of numerical units in rlimit rules (a word boundary is added at the beginning if there is no number before).
  • Unnecessary attributes are deleted in ItemData's (Ex: underline=0, italic=0)
  • Some itemData have bad names ("Globbing Char 1", "Globbing Char 2", "Globbing Char 3"), so these change their name.
  • Globbing brackets change in style, from "dsSpecialString" to "dsVerbatimString", since in the "Normal" scheme the red color is more discreet than the orange color.
  • Removes unnecessary insensitive attributes in some rules.

In the file I also made some minor modifications to order the code and it is less chaotic, since the file is very large.
I have tested the file enough and I can say that it works well.

Any inconvenience (such as adding extensions) do not hesitate to notify!

Diff Detail

Repository
R216 Syntax Highlighting
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1751
Build 1769: arc lint + arc unit
nibags created this revision.Jul 31 2018, 9:08 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJul 31 2018, 9:08 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Jul 31 2018, 9:08 PM
cullmann accepted this revision.Aug 12 2018, 4:36 PM

Has tests, looks ok. Thanks!

This revision is now accepted and ready to land.Aug 12 2018, 4:36 PM
nibags updated this revision to Diff 39549.Aug 13 2018, 3:11 AM
  • Update references.

Regenerate file "autotest/reference/usr.bin.apparmor-profile-test.ref"

nibags updated this revision to Diff 39550.EditedAug 13 2018, 4:47 AM

Fix conflicts in references (I only changed the base with the last master)

nibags closed this revision.Aug 13 2018, 4:50 AM