Skip to content

Commit a231e51

Browse files
author
Daniel Kopeček
committed
Update rule language documentation
1 parent 76b7119 commit a231e51

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

documentation/rule-language.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The rule language grammar, expressed in a BNF-like syntax, is the following:
1919
device_attributes ::= device_attributes | attribute.
2020
device_attributes ::= .
2121

22-
attribute ::= name string.
22+
See the [Device attributes](#device-attributes) section for the list of available attributes and their syntax.
2323

2424
## Targets
2525

@@ -41,15 +41,29 @@ In the rule, it's possible to use an asterisk character to match either any devi
4141

4242
### Device attributes
4343

44-
(Please see [issue #11](https://github.com/dkopecek/usbguard/issues/11) and comment on the proposed changes related to this section)
44+
(Please see [issue #11](https://github.com/dkopecek/usbguard/issues/11) and comment on the changes related to this section)
4545

46-
Device attributes are specific value read from the USB device after it's inserted to the system. Which attributes are available is defined bellow. Some of the attributes are derived or based on attributes read directly from the device. The value of an attribute is represented as a double-quoted string.
46+
Device attributes are specific value read from the USB device after it's inserted to the system. Which attributes are
47+
available is defined bellow. Some of the attributes are derived or based on attributes read directly from the device.
48+
The value of an attribute is represented as a double-quoted string.
4749

4850
List of attributes:
4951

50-
* `class "NN"`
51-
* `hash "[0-9a-f]{32}"`
52-
* `name "..."`
53-
* `port "[0-9]{1,2}-[0-9]{1,2}"`
54-
* `port { "[0-9]{1,2}-[0-9]{1,2}" "[0-9]{1,2}-[0-9]{1,2}" ... }`
55-
52+
* `hash "[0-9a-f]{32}"`: Match a hash of the device attributes (the hash is computed for every device by USBGuard).
53+
* `name "device-name"`: Match the USB device name attribute.
54+
* `serial "serial-number"`: Match the iSerial USB device attribute.
55+
* `via-port "port-id"`: Match the USB port through which the device is connected.
56+
* `via-port [operator] { "port-id" "port-id" ... }`: Match a set of USB ports.
57+
* `with-interface interface-type`: Match an interface the USB device provides.
58+
* `with-interface [operator] { interface-type interface-type ... }`: Match a set of interface types against the set of interfaces that the USB device provides.
59+
60+
`operator` is one of:
61+
* `all-of`: The device attribute set must contain all of the specified values for the rule to match.
62+
* `one-of`: The device attribute set must contain at least one of the specified values for the rule to match.
63+
* `none-of`: The device attribute set must not contain any of the specified values for the rule to match.
64+
* `equals`: The device attribute set must contain exactly the same set of values for the rule to match.
65+
* `equals-ordered`: The device attribute set must contain exactly the same set of values in the same order for the rule to match.
66+
67+
`port-id` is a platform specific USB port identification. On Linux it's in the form "b-n" where `b` and `n` are unsigned integers (e.g. "1-2", "2-4", ...).
68+
69+
`interface-type` represents a USB interface and should be formated as three 8-bit numbers in hexadecimal base delimited by colon, i.e. `cc:ss:pp`. The numbers represent the interface class (`cc`), subclass (`ss`) and protocol (`pp`) as assigned by the [USB-IF](www.usb.org/about) ([List of assigned classes, subclasses and protocols](http://www.usb.org/developers/defined_class)). Instead of the subclass and protocol number, you may write an asterisk character (`\*`) to match all subclasses or protocols. Matching a specific class and a specific protocol is not allowed, i.e. if you use an asterisk as the subclass number, you have to use an asterisk for the protocol too.

0 commit comments

Comments
 (0)