Last active
February 28, 2023 23:15
-
-
Save profesor79/176d6b81a7000b74b8a80159cd4b771f to your computer and use it in GitHub Desktop.
secure coding example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UCanHave10YearsExperienceCounted1x10_or_10x1 | |
{ | |
public void Shit(string docNumber) | |
{ | |
int documentNumber = 0; | |
if (int.TryParse(docNumber, out documentNumber)) | |
{ | |
documentNumber = Convert.ToInt32(docNumber); | |
} | |
NowWeCallAMethodWitOurInt(documentNumber); | |
} | |
// this is called only ONCE | |
public void NowWeCallAMethodWitOurInt(int i = 0) | |
{ | |
AndNowAnotherCallWithIt(i); | |
} | |
public void AndNowAnotherCallWithIt(int i) | |
{ | |
var data = ExpensiveCallToDatabase(i).FirstOrDefault(); | |
if (data != null) | |
{ | |
//some coe here | |
} | |
} | |
public List<object> ExpensiveCallToDatabase(int i) | |
{ | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment