
ISoultanov145051 (Community Member) asked a question.
See the code below that is being flagged on line "return builder.ConnectionString;". As you can see there is no chance anything is being controlled from external source, everything is hardcoded. Is there a way to avoid CWE 15 by using another approach to construct connection string, perhaps? Any ideas?
private CustomerDbConfiguration ConnectionConfig
{
get
{
CustomerDbConfig org = new CustomerDbConfig();
org.DatabaseName = "CustomerDB";
org.DatabaseServer = "somedbname.database.windows.net";
org.DatabaseUser = "username";
org.DatabasePassword = "asjkdhashdaskdj!!!";
org.UseWindowsAuthentication = false;
return org;
}
}
internal string GetOrganizationConnectionString()
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = ConnectionConfig.DatabaseServer;
builder.InitialCatalog = ConnectionConfig.DatabaseName;
if (ConnectionConfig.UseWindowsAuthentication)
{
builder.IntegratedSecurity = true;
}
else
{
builder.IntegratedSecurity = false;
builder.UserID = ConnectionConfig.DatabaseUser;
builder.Password = ConnectionConfig.DatabasePassword;
}
builder.Pooling = true;
builder.Enlist = false;
return builder.ConnectionString;
}
.png)
Hi @ISoultanov145051 (Community Member) ,
Please review the answer given for a similar post here: https://community.veracode.com/s/question/0D53n00007fLVveCAG/i-need-your-help-wit-cwe-15 .
Typically if we're reporting this on an application that makes use of hardcoded configuration data it will be the result of an incorrect module selection. You can learn more about Veracode Static Analysis Scannable Modules here: https://community.veracode.com/s/article/What-are-Modules-and-how-do-my-results-change-based-on-what-I-select .
If you have any other questions, I would recommend you schedule a consultation call to discuss.
You can check out this knowledge article (https://community.veracode.com/s/article/How-to-schedule-a-consultation-call) on how to schedule a consultation call with us.
Thank you,
Boy Baukema