usbguard
usbguard copied to clipboard
Feature Request: Enable comments in rules.conf
A way to add comments to the rules file syntax would be nice, eg: "any line beginning with a hash sign is treated as a comment".
Hi @ckastner,
It is already part of usbguard since 0.7.5 release.
Apologies, it appears that I tested this with Debian stable's 0.7.4 instead of 1.0.0 I had installed on another system.
May I suggest a short one-line modification to usbguard-rules.conf.5.adoc
? I'd propose a PR, but I'm not sure where you'd prefer the comment (before, in, after the rule spec).
It looks like that comments are not described in the manual pages. It would be a great idea to somehow include it in the documentation. I think it would make sense if it was part of the rule language section, inside usbguard-rules.conf.5.adoc
file.
Yes, we do appreciate PRs :) Thanks.
Please note issue "Permanently allowing device deletes comments in rules.conf" (#486)
So given that this is not yet documented… how are comments made?
@calestyo the character starting comments in rules syntax is #
, a hash mark.
(For proof:) https://github.com/USBGuard/usbguard/blob/927a41da7538d9f31846bdf14a49197d8e5a0d80/src/Library/RuleParser/Grammar.hpp#L207
PS: Also there is: https://github.com/USBGuard/usbguard/blob/927a41da7538d9f31846bdf14a49197d8e5a0d80/src/Tests/Rules/test-rules.good#L767-L770
@Cropi I would like to suggest this ticket either for closing as "fixed, already works" or to pin it, so that it's most easy to find. What do you think?
Can't we just add a line the usbguard-rules.conf
telling how comments look like?
@calestyo good point, I guess I forgot about https://github.com/USBGuard/usbguard/issues/461#issuecomment-800143546 above :+1:
Thanks, but is that written clearly enough?
Is really everything after a #
ignored? Or just when there was only leading (or no) whitespace? And if it's actually the former, wouldn't one need a way to quote a #
if it shall e.g. be part of a device name or so?
Thanks, but is that written clearly enough?
Is really everything after a
#
ignored? Or just when there was only leading (or no) whitespace? And if it's actually the former, wouldn't one need a way to quote a#
if it shall e.g. be part of a device name or so?
One or more leading white spaces should already be handled properly. I think that the symbol is not treated as a comment if it's inside the rule, although will need to double check it. If I am wrong on this, can you create a new issue for this?