-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Question
I see there are at least two of warnings that should be given if there's a possibility for an SQL injection attack: CA3001 and EF1002.
No matter how egregious of a hole I'm trying to make, I get zero warnings from ExecuteSqlRaw.
In my editorconfig I have:
dotnet_diagnostic.CA3001.severity = error
dotnet_diagnostic.EF1002.severity = error
And I have set this for all projects via Directory.Build.Props
<PropertyGroup>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
The projects are .NET 9 and the Microsoft.EntityFrameworkCore.Analyzers are enabled.
I get a bunch of other warnings but it seems like these injection vulnerabilities are not detected in the first place.
Can anyone actually get these warnings some way?
Your code
await ctx.ExecuteSqlRawAsync("SELECT * FROM ExampleEntities WHERE ID = '" + request.NameSearch + "'", cancellationToken)`
where the request.NameSearch comes directly from the API. Does not get any more obvious than this
EF Core version
9.0.0
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 9.0
Operating system
Windows 11
IDE
No response