Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorSpagnolo committed Jan 28, 2023
1 parent 054c9ba commit 1262e6a
Show file tree
Hide file tree
Showing 33 changed files with 97 additions and 97 deletions.
6 changes: 3 additions & 3 deletions src/SecureBank/Authorization/AuthorizeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public virtual bool AuthorizeAdmin(AuthorizationFilterContext context)
return false;
}

Claim roleCalim = claims
Claim roleClaim = claims
.Where(x => x.Type == CookieConstants.ROLE_CLAIM_TYPE)
.SingleOrDefault();
if (roleCalim == null)
if (roleClaim == null)
{
return false;
}

if (roleCalim.Value != CookieConstants.ADMIN_ROLE_STRING)
if (roleClaim.Value != CookieConstants.ADMIN_ROLE_STRING)
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/SecureBank/Authorization/CookieService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public virtual string CreateCookie(UserDBModel user, HttpContext context)
random.NextBytes(byteArray);

string cookieHash = Sha256HashUtils.ComputeSha256Hash(byteArray);
string inrole = user.Role.ToString();
string inRole = user.Role.ToString();

if (user.Role > ADMIN_ROLE)
{
inrole = ADMIN_ROLE_COOKIE_VALUE;
inRole = ADMIN_ROLE_COOKIE_VALUE;
}

IUserDAO userDAO = context.RequestServices.GetRequiredService<IUserDAO>();
Expand All @@ -65,7 +65,7 @@ public virtual string CreateCookie(UserDBModel user, HttpContext context)
return null;
}

string allCookie = string.Format(COOKIE_FORMAT, EncoderUtils.Base64Encode(user.UserName), cookieHash, inrole);
string allCookie = string.Format(COOKIE_FORMAT, EncoderUtils.Base64Encode(user.UserName), cookieHash, inRole);

CookieOptions cookieOptions = new CookieOptions
{
Expand Down
6 changes: 3 additions & 3 deletions src/SecureBank/Authorization/EncryptedCookieService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public override string CreateCookie(UserDBModel user, HttpContext context)
random.NextBytes(byteArray);

string cookieHash = Sha256HashUtils.ComputeSha256Hash(byteArray);
string inrole = user.Role.ToString();
string inRole = user.Role.ToString();

if (user.Role > ADMIN_ROLE)
{
inrole = ADMIN_ROLE_COOKIE_VALUE;
inRole = ADMIN_ROLE_COOKIE_VALUE;
}

IUserDAO userDAO = context.RequestServices.GetRequiredService<IUserDAO>();
Expand All @@ -51,7 +51,7 @@ public override string CreateCookie(UserDBModel user, HttpContext context)
return null;
}

string allCookie = string.Format(COOKIE_FORMAT, EncoderUtils.Base64Encode(user.UserName), cookieHash, inrole);
string allCookie = string.Format(COOKIE_FORMAT, EncoderUtils.Base64Encode(user.UserName), cookieHash, inRole);

string encodedCookie = _protector.Protect(allCookie);

Expand Down
2 changes: 1 addition & 1 deletion src/SecureBank/Controllers/Api/StoreController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<IActionResult> GetHistory([FromQuery] string username = null)
username = HttpContext.GetUserName();
}

List<PurcahseHistoryItemResp> history = await _storeBL.GetPurcahseHistory(username);
List<PurcahseHistoryItemResp> history = await _storeBL.GetPurchaseHistory(username);

return Ok(history);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SecureBank/Controllers/StoreController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task<IActionResult> ItemDetails([FromQuery] int itemId)
public async Task<IActionResult> History()
{
List<PurcahseHistoryItemResp> purchasedItems =
await _storeBL.GetPurcahseHistory(HttpContext.GetUserName());
await _storeBL.GetPurchaseHistory(HttpContext.GetUserName());

return View(purchasedItems);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SecureBank/Controllers/TransactionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<IActionResult> Edit(int? id)
}

// POST: Transaction/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// To protect from overpoting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[UnknownGeneration]
[HttpPost]
Expand Down
2 changes: 1 addition & 1 deletion src/SecureBank/Controllers/UploadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public UploadController(IUploadFileBL uploadFileBL)
_uploadFileBL = uploadFileBL;
}

public async Task<IActionResult> UploadTansactions()
public async Task<IActionResult> UploadTransactions()
{
ViewBag.Success = false;

Expand Down
6 changes: 3 additions & 3 deletions src/SecureBank/Ctf/CTFd/Models/CTFdChallengeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CTFdChallengeModel
public string Category { get; set; }
public string Type { get; set; }
public string State { get; set; }
public CTFdChallengePrequsites Requirements { get; set; }
public CTFdChallengePerquisites Requirements { get; set; }

public CTFdChallengeModel(long id, string name, string description, int maxAttempts, int value, string category,
string type, string state)
Expand All @@ -30,11 +30,11 @@ public CTFdChallengeModel(long id, string name, string description, int maxAttem
State = state;
}

public class CTFdChallengePrequsites
public class CTFdChallengePerquisites
{
public List<long> Prerequisites { get; set; }

public CTFdChallengePrequsites(List<long> prerequisites)
public CTFdChallengePerquisites(List<long> prerequisites)
{
Prerequisites = prerequisites;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SecureBank/Ctf/Services/CtfAdminStoreBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public override async Task<DataTableResp<StoreItem>> GetStoreItems()
bool xss = storeItems.Data.Any(x => CtfConstants.XXS_KEYVORDS.Any(c => (x.Name?.Contains(c) ?? false) || (x.Description?.Contains(c) ?? false)));
if (xss)
{
CtfChallengeModel xxsChallange = _ctfOptions.CtfChallenges
CtfChallengeModel xxsChallenge = _ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.Xss)
.Single();

_httpContextAccessor.HttpContext.Response.Headers.Add(xxsChallange.FlagKey, xxsChallange.Flag);
_httpContextAccessor.HttpContext.Response.Headers.Add(xxsChallenge.FlagKey, xxsChallenge.Flag);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/SecureBank/Ctf/Services/CtfAuthBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public override Task<bool> Register(UserModel registrationModel)
{
if (_ctfOptions.CtfChallengeOptions.RegistrationRoleSet)
{
CtfChallengeModel registrationRoleSetChallange = _ctfOptions.CtfChallenges
CtfChallengeModel registrationRoleSetChallenge = _ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.RegistrationRoleSet)
.Single();

_httpContextAccessor.HttpContext.Response.Headers.Add(registrationRoleSetChallange.FlagKey, registrationRoleSetChallange.Flag);
_httpContextAccessor.HttpContext.Response.Headers.Add(registrationRoleSetChallenge.FlagKey, registrationRoleSetChallenge.Flag);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/SecureBank/Ctf/Services/CtfPortalSearchBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override PortalSearchModel Search(string search)
bool hasXss = CtfConstants.XXS_KEYVORDS.Any(x => search.ToUpper().Contains(x.ToUpper()));
if (hasXss)
{
CtfChallengeModel xssChallenge = _ctfOptions.CtfChallanges
CtfChallengeModel xssChallenge = _ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.Xss)
.Single();

Expand Down
30 changes: 15 additions & 15 deletions src/SecureBank/Ctf/Services/CtfStoreBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class CtfStoreBL : StoreBL
/// username
/// productId
/// </summary>
private const string SIMULTANEOUS_REQUESTS_KEY = "simultenous_{0}_{1}";
private const string SIMULTANEOUS_REQUESTS_KEY = "simultaneous_{0}_{1}";

private readonly TimeSpan SIMULTANEOUS_REQUESTS_WAIT_FOR = new TimeSpan(0, 0, 1);
private readonly TimeSpan LOCK_BUY_REQUEST_FOR = new TimeSpan(0, 0, 1);
Expand Down Expand Up @@ -67,7 +67,7 @@ public async override Task<bool> BuyProduct(BuyProductReq buyProductReq, string
List<StoreItem> storeItems = await _storeAPICalls.GetStoreItemsAsync();
if (storeItems != null)
{
CtfChallengeModel invalidModelChallange = _ctfOptions.CtfChallenges
CtfChallengeModel invalidModelChallenge = _ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.InvalidStoreModel)
.Single();

Expand All @@ -78,7 +78,7 @@ public async override Task<bool> BuyProduct(BuyProductReq buyProductReq, string
{
if (storeItem.Price != buyProductReq.Price)
{
_httpContextAccessor.HttpContext.Response.Headers.Add(invalidModelChallange.FlagKey, invalidModelChallange.Flag);
_httpContextAccessor.HttpContext.Response.Headers.Add(invalidModelChallenge.FlagKey, invalidModelChallenge.Flag);
}
}
}
Expand All @@ -91,12 +91,12 @@ public async override Task<bool> BuyProduct(BuyProductReq buyProductReq, string

protected override async Task<bool> Pay(BuyProductReq buyProductReq, string userName)
{
double accountBalance = _transactionDAO.GetAccountbalance(userName);
double accountBalance = _transactionDAO.GetAccountBalance(userName);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
double ammountToPay;
double amountToPay;

ammountToPay = buyProductReq.Price * buyProductReq.Quantity;
amountToPay = buyProductReq.Price * buyProductReq.Quantity;


List<StoreItem> storeItems = await _storeAPICalls.GetStoreItemsAsync();
Expand Down Expand Up @@ -125,7 +125,7 @@ protected override async Task<bool> Pay(BuyProductReq buyProductReq, string user
}
else
{
ammountToPay = storeItem.Price * buyProductReq.Quantity;
amountToPay = storeItem.Price * buyProductReq.Quantity;
}


Expand All @@ -136,14 +136,14 @@ protected override async Task<bool> Pay(BuyProductReq buyProductReq, string user
{
await Task.Delay(sleepFor);
}
if (accountBalance < ammountToPay)
if (accountBalance < amountToPay)
{
return false;
}


double accountBalanceAfterWait = _transactionDAO.GetAccountbalance(userName);
if (accountBalanceAfterWait < ammountToPay)
double accountBalanceAfterWait = _transactionDAO.GetAccountBalance(userName);
if (accountBalanceAfterWait < amountToPay)
{
if (_ctfOptions.CtfChallengeOptions.SimultaneousRequest)
{
Expand All @@ -157,7 +157,7 @@ protected override async Task<bool> Pay(BuyProductReq buyProductReq, string user

DepositRequest depositRequest = new DepositRequest
{
Amount = ammountToPay,
Amount = amountToPay,
Reason = TRANSACTION_REASON,
ReceiverId = TRANSACTION_RECIVER_ID,
SenderId = userName
Expand All @@ -166,25 +166,25 @@ protected override async Task<bool> Pay(BuyProductReq buyProductReq, string user
return _transactionDAO.Pay(depositRequest);
}

public override Task<List<PurcahseHistoryItemResp>> GetPurcahseHistory(string userName)
public override Task<List<PurcahseHistoryItemResp>> GetPurchaseHistory(string userName)
{
if (userName != _httpContextAccessor.HttpContext.GetUserName())
{
if (_ctfOptions.CtfChallengeOptions.SensitiveDataExposureStore)
{
CtfChallengeModel sensitiveDataExpusure = _ctfOptions.CtfChallenges
CtfChallengeModel sensitiveDataExposure = _ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.SensitiveDataExposure)
.Single();

_httpContextAccessor.HttpContext.Response.Headers.Add(sensitiveDataExpusure.FlagKey, sensitiveDataExpusure.Flag);
_httpContextAccessor.HttpContext.Response.Headers.Add(sensitiveDataExposure.FlagKey, sensitiveDataExposure.Flag);
}
else
{
userName = _httpContextAccessor.HttpContext.GetUserName();
}
}

return base.GetPurcahseHistory(userName);
return base.GetPurchaseHistory(userName);
}
}
}
Loading

0 comments on commit 1262e6a

Please sign in to comment.