Search for connection strings in code programmatically

It seems like a pretty simple problem. I want to browse around 6 GB of content and classic asp code and find everything that looks like a connection string. The problem is that the connection strings are formatted in a dozen different ways.

I was thinking about using regular expressions to search for specific properties, such as "catalog =" or "password =" etc.

+3
source share
4 answers

Can't you use this regex?

@"^([^=;]+=[^=;]*)(;[^=;]+=[^=;]*)*;?$"

http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/48bf2a4f-7312-4a32-b874-b77a27f7c5d0

+3
source

- ?

regex/grep-like - . .

+1

, . ( ) , . 6 .

0

, :

x = "Provider=xyz;Initial Catalog=bdf;Database=pdq;"

:

x = "Provider=xyz;" & _
    "Initial Catalog=bdf;" & _
    "Database=pdq;"

:

x = "Provider=xyz;"
x = x & "Initial Catalog=bdf;"
x = x & "Database=pdq;"

dotnet ConnectionBuilder

SqlConnectionStringBuilder x = newSqlConnectionStringBuilder();
x.Add("Data Source", "pdq");
x.Add("Initial Catalog", "xyz");

, ?

"SQLConnection | odbcconnect | OleDbConnection | ConnectionString"

0

Source: https://habr.com/ru/post/1711094/


All Articles