Repository navigation
fix match-all always matching on string rule attributes - #704
Open
Bountybette wants to merge 1 commit into
Open
Bountybette wants to merge 1 commit into
Bountybette wants to merge 1 commit into
Conversation
The match-all set operator is solved with Predicates::isSupersetOf, which is only specialized for USBDeviceID and USBInterfaceType. The generic template was a stub that returned true, so match-all on name, serial, hash, parent-hash, via-port and with-connect-type matched any device. Implement it as equality, like the generic isSubsetOf.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
match-allset operator added in 1.0.0 is evaluated bysetSolveMatchAllinRule.hpp, which callsPredicates::isSupersetOffor every rule value. OnlyUSBDeviceIDandUSBInterfaceTypespecialize that predicate. The generic template was left as a stub that logs "Not implemented" and returns true, and it is what all thestd::stringattributes go through:name,serial,hash,parent-hash,via-portandwith-connect-type. So a rule likeallow via-port match-all { "1-1" "1-2" }orallow hash match-all { "..." "..." }authorizes any device on any port with any descriptors, which silently turns a restrictive allow rule into a wildcard. I noticed it from the(E) Not implementedlines in the log while testing rule evaluation, and the new unit test intest_Rule.cppfails on main (allow name match-all { "Disk" "Mouse" }applies to a device named "Keyboard"). For a single-valued attribute, superset reduces to equality, so the genericisSupersetOfnow mirrors the genericisSubsetOf; the two existing specializations are unchanged andmake checkpasses.