Configure Regular Expressions
Focus
Focus
Enterprise DLP

Configure Regular Expressions

Table of Contents

Configure Regular Expressions

Use the Enterprise Data Loss Prevention (E-DLP) regex builder to create expressions that make content matching easy.
Where Can I Use This?What Do I Need?
  • NGFW (Managed by Panorama or Strata Cloud Manager)
  • Prisma Access (Managed by Panorama or Strata Cloud Manager)
  • Enterprise Data Loss Prevention (E-DLP) license
    Review the Supported Platforms for details on the required license for each enforcement point.
Or any of the following licenses that include the Enterprise DLP license
  • Prisma Access CASB license
  • Next-Generation CASB for Prisma Access and NGFW (CASB-X) license
  • Data Security license
The regular expression builder in Enterprise Data Loss Prevention (E-DLP) provides an easy mechanism to configure regular expressions (regex for short), which you define when you create a custom data pattern. You can use the regular expression builder to construct a data pattern expression, view matches, filter occurrences and weight thresholds, and assess match results to determine if the content poses a risk to your organization.
There are two types of regular expressions:
  • Basic—Searches for a specific text pattern. When Enterprise DLP displays the match occurrences when inspected traffic matches the data pattern match criteria.
  • Weighted—Assigns a score to a text entry. When the score threshold is exceeded, such as enough expressions from a pattern match an asset, the service returns a match for the pattern.
    To reduce false-positives and maximize the search performance of your regular expressions, you can assign scores using the weighted regular expression builder in Enterprise DLP to find and calculate scores for the information that’s important to you. Scoring applies to a match threshold, and when a threshold is exceeded, such as enough words from a pattern are found in a document, the document will be indicated as a match for the pattern.
Use Case: Calculating and Scoring a weighted regular expression
For example, Joe is an employee at a water treatment plant and needs to compile user data on a proprietary pH additive that is used when source water arrives at the plant. If Joe initiated a regular expression search with just the term tap water thousands of match results display, as the matched tap water documents list the additive. However, Joe is searching for the first use of the additive and not every document the additive is listed in, making it difficult for Joe to find the usage data he needs.
To get more accurate results, Joe can initiate a weighted regular expression to assign weight and occurrence scores to the expression, or indicate the information to exclude by assigning a negative weight value.
Joe enters a negative weight value to exclude tap water and higher values to source water and the proprietary water additive. The results are filtered and counted to a more manageable list, meaning that a document containing 10 occurrences of water counts as one when all files and folders are scanned. This enables Joe to view the match results, adjust the totals for weight and occurrences, and calculate an adjusted score to determine if the content poses a risk to his organization.
Weighted Regex Item
Occurrence
Adjusted Occurrence Score
Adjusted Total
Water; 1
50
50 (1 Occurrence X 1)
110 minus 100 for tap water = 10 regex weight
IP pH; 2
30
60 (30 occurrences X 2)
Tap Water; -10
10
-100 (10 occurrences x -10)
  1. Consider the best practices for using regular expression matches.
    • Use predefined data patterns instead of regular expressions. Use Enterprise DLP predefined data patterns instead of regular expressions where possible. Data patterns are more efficient than regular expressions because the predefined data patterns are tuned for accuracy and the data is validated. For example, if you want to search for social security numbers, use the US Social Security Number (SSN) data pattern instead of a regular expression.
    • Use regular expressions sparingly. Regular expressions can be computationally expensive. If you add a regular expression condition, observe the system for 1 hour for efficient performance. Make sure that the system does not slow down and there are no false positives.
    • Test regular expressions. If you implement regular expression matching, consider using a third-party tool to test the regular expressions before you enable the policy rules. The recommended tool is RegexBuddy. Another good tool for testing your regular expressions is RegExr. If your expression is incorrect, the service can’t match or will match incorrectly.
  2. Understand expression terminology.
    Expression Terminology:
    Term
    Description
    Literal
    A literal is any character you use in a search or matching expression, for example, to find dlp in Enterprise DLP, dlp is a literal string - each character plays a part in the search, it’s literally the string we want to find.
    Metacharacter
    A metacharacter is one or more special characters that have a unique meaning and are not used as literals in the search expression, for example, the character < > (caret) is a metacharacter.
    Regular Expression
    This term describes the search expression data pattern that you will be using to search in Enterprise DLP.
    Escape Sequence
    An escape sequence is a way of indicating that you want to use one of the metacharacters as a literal. In a regular expression an escape sequence involves placing the metacharacter \ (backslash) in front of the metacharacter that you use as a literal, for example, if you want to find (dlp) in Enterprise DLP then use the search expression \(dlp\), and if you want to find \\file in the target string c:\\file then you would need to use the search expression \\\\file (each \ to search for a literal (there are 2) that is preceded by an escape sequence \).
  3. Understand expression constructs.
    Enterprise DLP implements Perl Compatible Regular Expressions (PCRE) syntax for policy rule condition matching. Enterprise DLP provides some common reference constructs for writing regular expressions to match or exclude characters in content.
    Regular expression constructs:
    Construct
    Description
    .
    A dot, any single character, except newline (line ending, end of line, or line break) characters.
    \
    Escape the next character (the character becomes a normal/literal character.)
    \d
    Any digit (0-9.)
    \s
    Any white space.
    \W
    Any word character (a-z, A-Z, 0-9.)
    \D
    Anything other than a digit.
    \S
    Anything other than a white space.
    [ ]
    Elements inside brackets are a character class (for example, [abc] matches 1 character [a. b. or c.]
    ^
    At the beginning of a character class, negates it (for example, [^abc] matches anything except (a, b, or c.)
    $
    At the end of a character class, or before the newline at the end.
    +
    Following a regular expression means 1 or more (for example, \d+ means 1 more digit.)
    ?
    Following a regular expression means 0 or 1 (for example, \d? means 1 or no digit.)
    *
    Following a regular expression means any number (for example \d* means 0, 1, or more digits.)
    (?i)
    At the beginning of a regular expression makes it case-insensitive (regular expressions are case-sensitive by default.)
    ( )
    Groups regular expressions together.
    (?u)
    Makes a period ( . ) match to even newline characters.
    |
    Means OR (for example, A|B means regular expression A or regular expression B.)
  4. Understand expression qualifiers.
    Quantifiers can be used to specify the number or length that part of a pattern should match or repeat. A quantifier will bind to the expression group to its immediate left.
    Regular expression quantifiers:
    Quantifier
    Description
    *
    Match 0 or more times.
    +
    Match 1 or more times.
    ?
    Match 1 or 0 times.
    {n}
    Match exactly n times.
    {n, }
    Match at least n times.
    {n, m}
    Match at least n but not more than m times.
  5. Enter one regular expression per line, up to 100 lines of expressions.
    There is no limit to the number of regular expressions you can add to a data pattern. Add as many lines of regular expressions as needed.
  6. (Weighted expressions only): Assign a regular expression for each line entry between -9999 (lowest importance) to 9999 (highest importance) by entering the regular expression, the delimiter, and the weight score. Enter a weight threshold score of one (1) of more.
  7. (Optional) Customize your delimiter.
    By default, the delimiter for all weighted regular expressions is semicolon ( ; ). You can customize your delimiter to copy and paste existing expressions instead of entering them manually. Use a delimiter to specify separate strings of data when configuring regular expressions. For example, you can configure a weighted regular expression using a delimiter to separate the string of text you’re matching from the weight threshold value. If you have large amounts of existing expressions to match, you can customize your delimiter to copy and paste the expressions instead of entering them manually. A delimiter can be any nonalphanumeric, nonbackslash, nonwhitespace character.
    Regular expression delimiters:
    Delimiter
    Note
    ;
    Semicolon — If the delimiter isn't customized, the semicolon is the default delimiter in Enterprise Data Loss Prevention (E-DLP).
    :
    Colon.
    |
    Pipe.
    /
    Forward Slash — You must escape the delimiter using a backlash ( \ ) if the delimiter needs to match inside the data pattern. If the delimiter appears often inside the pattern, it’s a good idea to choose another delimiter to increase readability.
    +
    Plus — Include phrase for matching.
    -
    Minus — Ignore phrase for matching.
    #
    Hash — Used to denote a number.
    ~
    Tilde
    { } Curly
    Use brackets to find a range of characters. You don't need to escape bracket-style delimiters when used as meta characters within the pattern, but you must escape bracket-style delimiters when used as literal characters.
    [ ] Square
    ( ) Parenthesis
    < > Caret