Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nftables improvements #3517

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions runtime/syntax/nftables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ detect:

rules:
- type: "\\b(chain|counter|map|rule|ruleset|set|table)\\b"
- type: "\\b(ether|icmp|icmpv6|icmpx|inet|ip|ip6|ipv4|ipv6|tcp|udp)\\b"
- type: "\\b(ether|inet|i(cm)?p(x|(v?(4|6))?)|tcp|udp)\\b"
- special: "\\b(elements|hook|policy|priority|type)\\b"
- identifier: "\\b(ct|iif|iifname|meta|oif|oifname|th)\\b"
- statement: "\\b(accept|drop|goto|jump|log|masquerade|reject)\\b"
- preproc: "\\b(add|define|flush|include|delete)\\b"
- symbol: "[-=/:;,@]"
- symbol: "([-=/:;,@]|[!=])"
- symbol.operator: "[<>.&|^!]|\\b(and|ge|gt|le|lt|or|xor)\\b"
Comment on lines -14 to 15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== and != are comparison operators, so why not adding them to symbol.operator? I even suggest to do the same with - and =.

Example (from C):

- symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(offsetof|sizeof)\\b"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a Suggestion on the old PR. I will change it later. It will make more sense to add it to the operators

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only gave examples. Never mind...
We should add all operators from symbol to symbol.operator, like -, +, *, /, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working right now on it, should i move the symbols =, :, ;, , and @ also to symbol.operator? I have now added -, +, *, /.

- constant.string: '([\"]{1})(.*)([\"]{1})'
- constant.string:
start: "(['\"])"
end: "(['\"])"
theredcmdcraft marked this conversation as resolved.
Show resolved Hide resolved
# Integer Constants
- constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
# Decimal Floating Constants
- constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)"
theredcmdcraft marked this conversation as resolved.
Show resolved Hide resolved
# Hexadecimal Floating Constants
- constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
- identifier.var: "[$@][a-zA-Z_.][a-zA-Z0-9_/.-]*"
- comment: "(^|[[:space:]])#([^{].*)?$"
- indent-char.whitespace: "[[:space:]]+$"
Expand Down