Defining Global Custom Detection Rules
Please make sure the rules you add aren’t too broad, as they can impact the performance of Bitbucket.
With Security for Bitbucket you can create custom security rules with regular expressions. The rules can only be created, enabled or disabled by Bitbucket Administrators or anyone that's been granted explicit access.
To create a rule, go to Administration → Security for Bitbucket Server → Security Validation Rules → Custom Rules. Alternatively, you may reach the configuration by clicking the gear icon on the Security Scan Report:
![](../../__attachments/14497972231/image-20210810-041751.png?inst-v=dd2e15ff-a066-4891-84cc-df8425dc8a25)
Our application uses the built-in JDK java regex library (Java 7), which you can compare to other regex engines here.
![](../../__attachments/14497972231/Screen%20Shot%202021-08-09%20at%202.23.35%20PM.png?inst-v=dd2e15ff-a066-4891-84cc-df8425dc8a25)
If a secret that's being committed matches more than one regex, only the first match will be reported
Here are some example rules:
Bitcoin Address
^[13][a-km-zA-HJ-NP-Z0-9]{26,33}$
Youtube Links
<a\s+(?:[^>]*)href=\"((?:https|http):\/\/\w{0,3}.youtube+\.\w{2,3}\/watch\?v=[\w-]{11})">(?:.*?)<\/a>