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 and have the hook scan code using those regexes. The rules can only be made by Bitbucket Administrators, and can only be enabled and disabled by admistrators.
To create a rule, go to Administration → Security for Bitbucket Server → Security Validation Rules → Custom Rules
If a secret that's being committed matches more than one regex, only the first match will be reported
Here are some example rules: