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 the match
method is called.emit : ["select"]
– the audit is performed if the select
method is called.emit : ["match", "select"]
– the audit is performed if the match
or select
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:
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 specified text
matches the pattern
regular expression, it returns true
. Otherwise it returns false
.
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 the choice
construct, see "Binding methods of security models to security events"). It checks whether the specified text
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 ()
}