2021-02-16 17:52:17 +01:00
|
|
|
include::../description.adoc[]
|
2020-06-30 12:48:07 +02:00
|
|
|
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
Public Sub SqlCommands(ByVal connection As SqlConnection, ByVal query As String, ByVal param As String)
|
|
|
|
Dim sensitiveQuery As String = String.Concat(query, param)
|
|
|
|
command = New SqlCommand(sensitiveQuery) ' Sensitive
|
|
|
|
|
|
|
|
command.CommandText = sensitiveQuery ' Sensitive
|
|
|
|
|
|
|
|
Dim adapter As SqlDataAdapter
|
|
|
|
adapter = New SqlDataAdapter(sensitiveQuery, connection) ' Sensitive
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Public Sub Foo(ByVal context As DbContext, ByVal query As String, ByVal param As String)
|
|
|
|
Dim sensitiveQuery As String = String.Concat(query, param)
|
|
|
|
context.Database.ExecuteSqlCommand(sensitiveQuery) ' Sensitive
|
|
|
|
|
|
|
|
context.Query(Of User)().FromSql(sensitiveQuery) ' Sensitive
|
|
|
|
End Sub
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
Public Sub Foo(ByVal context As DbContext, ByVal value As String)
|
|
|
|
context.Database.ExecuteSqlCommand("SELECT * FROM mytable WHERE mycol=@p0", value) ' Compliant, the query is parameterized
|
|
|
|
End Sub
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|