Skip to content

Commit

Permalink
collect test metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshboddu committed May 29, 2024
1 parent 9f181b2 commit 4d6171d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CalculatorApp.Console/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ public int Reminder(int a, int b)
return a % b;
}

// Method with SQL injection vulnerability
public void ConnectToDatabase(string userInput)
{
string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";

// Create a SQL query using the user input directly
string query = $"SELECT * FROM Users WHERE Username = '{userInput}'";

using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(query, connection);
connection.Open();

SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine($"User: {reader["Username"]}, Email: {reader["Email"]}");
}
}
}

// Method with hardcoded credentials
public void ConnectToDatabase()
{
Expand Down

0 comments on commit 4d6171d

Please sign in to comment.