I was assigned a task to fix the SQL injection flaw reported by a code analysis tool and. I am not the original author of the code and. I do have fair amount of knowledge onam fairly knowledgeable with SQL.
1 public int ExecuteNonQuery(string query, SqlParameter[] parameters)
2 {
3 using (SqlCommand command = CreateCommand(query, parameters))
4 {
5 int rowsAffected = command.ExecuteNonQuery();
6 log.Debug("rows affected: {0}", rowsAffected);
7 return rowsAffected;
8 }
9 }
public int ExecuteNonQuery(string query, SqlParameter[] parameters)
{
using (SqlCommand command = CreateCommand(query, parameters))
{
int rowsAffected = command.ExecuteNonQuery();
log.Debug("rows affected: {0}", rowsAffected);
return rowsAffected;
}
}
My questions are:Is there any injection risk in this code? If yes, how do I recognize it?
- Is there any injection risk in this code?
- If yes, how do I recognize?