linux - Regex for searching or gripping complex passwords in code repos -


i need regex use notepad++ "find in files" or find , grep command on linux find $dirs -type f -name '*.php' -o -name '*.sh' -exec grep -rhn "regex" make sure no passwords hard coded in our code repositories passwords should @ least 8 characters long , maximum 12 , should @ least have 1 lowercase,uppercase,digit characters , can have special characters or not

here example passwords want match

sh@r3d1nh3re

f0llowup

thanks

it pretty impossible distinguish password other text/code, here regex looking for, match match whitespaces, including single , double quotes:

[!-~]{8,12}

if don't want include quotes , password must have quotes around try (not sure if you'll need escape start parenthesis, shouldn't hurt):

['"][!#-&(-~]{8,12}['"]

note, grep, you'll have use -p option , escape double quotes, example:

grep -p "['\"][!#-&(-~]{8,12}['\"]"

if wanted ensure had @ least 1 lowercase , @ least 1 uppercase , @ least 1 digit, you'll have use lookahead , that's more completed, site has example , explanation @ bottom (note: couldn't lookaheard working in notepad++): https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s19.html#validation-password-variations


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -