Skip to content

Commit f01bd3b

Browse files
committed
Task 37261: [S360] [SM05137] DefaultAzureCredential use in Production
- Adjusted CodeQL suppression to meet the strict requirements of where it may appear relative to the flagged code.
1 parent 18becfe commit f01bd3b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,23 @@ private static TokenCredentialData CreateTokenCredentialInstance(TokenCredential
587587
// specify 'Authentication = Active Directory Default' in
588588
// connection string.
589589
//
590-
// CodeQL Suppression - do not modify this comment:
591-
//
592-
// CodeQL [SM05137] Default Azure Credential is instantiated by
593-
// the calling application when using "Active Directory Default"
590+
// Default Azure Credential is instantiated by the calling
591+
// application when using "Active Directory Default"
594592
// authentication code to connect to Azure SQL instance.
595593
// SqlClient is a library, doesn't instantiate the credential
596594
// without running application instructions.
597-
return new TokenCredentialData(new DefaultAzureCredential(defaultAzureCredentialOptions), GetHash(secret));
595+
//
596+
// Note that CodeQL suppression support can only detect
597+
// suppression comments that appear immediately above the
598+
// flagged statement, or appended to the end of the statement.
599+
// Multi-line justifications are not supported.
600+
//
601+
// https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/codeql-semmle#guidance-on-suppressions
602+
//
603+
// CodeQL [SM05137] See above for justification.
604+
DefaultAzureCredential cred = new(defaultAzureCredentialOptions);
605+
606+
return new TokenCredentialData(cred, GetHash(secret));
598607
}
599608

600609
TokenCredentialOptions tokenCredentialOptions = new() { AuthorityHost = new Uri(tokenCredentialKey._authority) };

0 commit comments

Comments
 (0)