-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add label to rules #293
Add label to rules #293
Conversation
A new attribute is added to associate an arbitrary string to a rule. This string can, for instance, be used to store the origin of the rule or some contextual information about it. This attribute is not used when testing if a rule applies to a device.
b206419
to
0d40a2a
Compare
Redefine listRules IPC method to only return vector<Rule> and not a RuleSet. The query parameter is reused for matching against the label of the rule.
0d40a2a
to
e6b2d21
Compare
Thanks again, this looks like an useful usability improvement.
Ok, that makes sense.
I have to look at the code again here, as I don't remember what was the intention. I think the query was supposed to be used to filter the result if needed.
Ok, I've read the linked issue and agree with dropping the required/optional annotations. |
Is this a problem? Maybe I'm not seeing the problem here. I would say this is how it should behave. i.e. list-rules should list rules that match on the attributes of the query rule: query: match label "foo" rule "allow id 1234:4568 label "foo" (matches) |
It is not a problem for list-rules, which would work as expected. But it is a problem for the standard rule matching when evaluating if a device should be authorised or denied. In this case, the device rule does not contain that label and therefore does not match any rule anymore. (This was implemented within the appliesTo method of RulePrivale.cpp, there might be another way to make that work). |
Ok, I see that now. To be honest I don't like that the list rules query parameter is now reserved and interpreted only as the label attribute value. But let's not block this feature on such a minor detail. We can meditate on it and deal with it later :-) Maybe there should be some sort of context parameter that would tell the API how to handle the "appliesTo" logic. Or the "device" and "match" rule targets [1] could be used to parametrize the applicability logic, e.g. a "match ..." rule when applied to a "device ..." rule would not invoke the matching on label attributes. [1] https://github.com/USBGuard/usbguard/blob/master/src/Library/public/usbguard/Rule.hpp#L59 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG(enough)TM
This PR adds a new attribute to the Rule class named "label", as suggested in #283. This attribute can be used to store further background on a rule. For instance,
allow id 045e:00db label "user-preference"
. It is then possible use the commandusbguard list-rules -l "user-preference"
to only return the rules matching this label.Worth noticing:
vector<Rule>
(there is currently no client for the default_target attribute, both list-rules and dbus discard that value). If required, this could be implemented in another IPC method).payloadToMessage
by verifying the returned value of ParseFromString. I would also suggest moving all the required field to optional at some point (reasoning at why messge type remove 'required,optional'? protocolbuffers/protobuf#2497).