Regex security model
The Regex security model lets you implement text data validation based on statically defined regular expressions.
A PSL file containing a description of the Regex security model is located in the KasperskyOS SDK at the following path:
toolchain/include/nk/regex.psl
Regex security model object
The regex.psl
file contains a declaration that creates a Regex security model object named re
. Consequently, inclusion of the regex.psl
file into the solution security policy description will create a Regex security model object by default.
A Regex security model object does not have any parameters.
A Regex security model object can be covered by a security audit. You can also define the audit completion conditions specific to the Regex security model. To do so, use the following constructs in the audit configuration description:
emit : ["match"]
– the audit is performed if thematch
method is called.emit : ["select"]
– the audit is performed if theselect
method is called.emit : ["match", "select"]
– the audit is performed if thematch
orselect
method is called.emit : []
– the audit is not performed.
It is necessary to create additional objects of the Regex security model in the following cases:
- You need to configure a security audit differently for different objects of the Regex security model (for example, you can apply different audit profiles or different audit configurations of the same profile for different objects).
- You need to distinguish between calls of methods provided by different objects of the Regex security model (audit data includes the name of the security model method and the name of the object that provides this method, so you can verify that the method of a specific object was called).
Regex security model methods
The Regex
security model contains the following expressions:
match {text :
<Text
>, pattern :
<Text
>}
Returns a value of the
Boolean
type. If the specifiedtext
matches thepattern
regular expression, it returnstrue
. Otherwise it returnsfalse
.Example:
assert (re.match {text : message.text, pattern : "^[0-9]*$"})
select {text :
<Text
>}
It is intended to be used as an expression that verifies fulfillment of the conditions in the
choice
construct (for details on thechoice
construct, see "Binding methods of security models to security events"). It checks whether the specifiedtext
matches regular expressions. Depending on the results of this check, various options for security event processing can be performed.Example:
choice (re.select {text : "hello world"}) {
"^hello .*": grant ()
".*world$" : grant ()
_ : deny ()
}