Hardened: Parameterized the rest of string queries
This commit is contained in:
@@ -41,10 +41,11 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT " + countryFieldSequence + " WHERE Code='" +
|
||||
countryCode.ToUpperInvariant().Replace ("'", "''") + "'",
|
||||
"SELECT " + countryFieldSequence + " WHERE Code=@countryCode",
|
||||
connection);
|
||||
|
||||
AddParameterWithName(command, "countryCode", countryCode);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
|
||||
@@ -60,8 +60,8 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT" + currencyFieldSequence + "WHERE Code='" +
|
||||
currencyCode.Replace ("'", "''").ToUpperInvariant() + "';", connection);
|
||||
"SELECT" + currencyFieldSequence + "WHERE Code=@currencyCode;", connection);
|
||||
AddParameterWithName(command, "currencyCode", currencyCode);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
@@ -13,8 +13,9 @@ namespace Swarmops.Database
|
||||
connection.Open();
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand ("SELECT DataValue FROM FlatData WHERE DataKey='" + key.Replace ("'", "''") + "'",
|
||||
GetDbCommand ("SELECT DataValue FROM FlatData WHERE DataKey=@dataKey",
|
||||
connection);
|
||||
AddParameterWithName(command, "dataKey", key);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
@@ -87,7 +87,8 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand(
|
||||
"SELECT" + hotBitcoinAddressFieldSequence + "WHERE BitcoinChainId=" + (Int32) chain + " AND AddressString='" + SqlSanitize (address) + "';", connection);
|
||||
"SELECT" + hotBitcoinAddressFieldSequence + "WHERE BitcoinChainId=" + (Int32) chain + " AND AddressString=@addressString;", connection);
|
||||
AddParameterWithName(command, "addressString", address);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace Swarmops.Database
|
||||
string Domain, string MailPrefix, int AnchorGeographyId, bool AcceptsMembers, bool AutoAssignNewMembers,
|
||||
int DefaultCountryId, int OrganizationId)
|
||||
{
|
||||
throw new NotImplementedException("Needs to use SPs per field");
|
||||
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -491,9 +491,11 @@ namespace Swarmops.Database
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT " + personFieldSequence + " WHERE GeographyId IN (" + JoinIds (geographyIds) +
|
||||
") AND (Name like '" + sqlPattern + "' OR Email like '" + sqlPattern + "')",
|
||||
") AND (Name LIKE @searchPattern OR Email LIKE @searchPattern)",
|
||||
connection);
|
||||
|
||||
AddParameterWithName(command, "searchPattern", pattern);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
|
||||
@@ -148,10 +148,12 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName='" + cityName.Replace ("'", "''") +
|
||||
"' AND CountryId=" + countryId,
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName=@cityName " +
|
||||
"AND CountryId=" + countryId,
|
||||
connection);
|
||||
|
||||
AddParameterWithName(command, "cityName", cityName);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
@@ -172,10 +174,13 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName='" + cityName.Replace ("'", "''") +
|
||||
"' AND CountryCode='" + countryCode.ToUpperInvariant().Replace ("'", "''") + "'",
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName=@cityName " +
|
||||
" AND CountryCode=@countryCode",
|
||||
connection);
|
||||
|
||||
AddParameterWithName(command, "cityName", cityName);
|
||||
AddParameterWithName(command, "countryCode", countryCode);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
@@ -196,9 +201,12 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName='" + cityName.Replace ("'", "''") +
|
||||
"' AND CountryId=" + countryId,
|
||||
"SELECT " + cityFieldSequence + " WHERE CityName=@cityName " +
|
||||
" AND CountryId=" + countryId,
|
||||
connection);
|
||||
|
||||
AddParameterWithName(command, "cityName", cityName);
|
||||
|
||||
List<BasicCity> resList = new List<BasicCity>();
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
@@ -76,8 +76,10 @@ namespace Swarmops.Database
|
||||
|
||||
DbCommand command =
|
||||
GetDbCommand (
|
||||
"SELECT TranslatedUrl FROM UrlTranslations WHERE OriginalUrl='" + url.Replace ("'", "''") +
|
||||
"' AND Translated=1", connection);
|
||||
"SELECT TranslatedUrl FROM UrlTranslations WHERE OriginalUrl=@originalUrl " +
|
||||
" AND Translated=1", connection);
|
||||
|
||||
AddParameterWithName("originalUrl", url);
|
||||
|
||||
using (DbDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user