ISoultanov145051 (Community Member) asked a question.

Veracode scan is picking up twenty CWE 15 HIGH flaws that go through the same method that constructs SQL connection string and returns it. Even if I hardcoded the values in the SqlConnectionStringBuilder properties, this method is still being flagged.

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;    

    }


Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.