64 lines
1.6 KiB
Plaintext
64 lines
1.6 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password="); // Noncompliant
|
|
}
|
|
----
|
|
|
|
In https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/[appsettings.json]
|
|
|
|
----
|
|
{
|
|
"ConnectionStrings": {
|
|
"DefaultConnection": "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password="
|
|
}
|
|
}
|
|
----
|
|
|
|
In https://docs.microsoft.com/en-us/troubleshoot/aspnet/create-web-config[Web.config]
|
|
|
|
----
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<configuration>
|
|
<connectionStrings>
|
|
<add name="myConnection" connectionString="Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=" /> <!-- Noncompliant -->
|
|
</connectionStrings>
|
|
</configuration>
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlServer("Server=myServerAddress;Database=myDataBase;Integrated Security=True");
|
|
}
|
|
----
|
|
|
|
In https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/[appsettings.json]
|
|
|
|
----
|
|
{
|
|
"ConnectionStrings": {
|
|
"DefaultConnection": "Server=myServerAddress;Database=myDataBase;Integrated Security=True"
|
|
}
|
|
}
|
|
----
|
|
|
|
In https://docs.microsoft.com/en-us/troubleshoot/aspnet/create-web-config[Web.config]
|
|
|
|
----
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<configuration>
|
|
<connectionStrings>
|
|
<add name="myConnection" connectionString="Server=myServerAddress;Database=myDataBase;Integrated Security=True" />
|
|
</connectionStrings>
|
|
</configuration>
|
|
----
|
|
|
|
include::../see.adoc[]
|