/* goodG2B() - use goodsource and badsink */ private static void GoodG2B() { string data; /* FIX: Use a hardcoded string */ data = "foo"; Dictionary <int, string> dataDictionary = new Dictionary <int, string>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE15_External_Control_of_System_or_Configuration_Setting__ReadLine_74b.GoodG2BSink(dataDictionary); }
public override void Bad() { string data; data = ""; /* Initialize data */ { /* read user input from console with ReadLine */ try { /* POTENTIAL FLAW: Read data from the console using ReadLine */ data = Console.ReadLine(); } catch (IOException exceptIO) { IO.Logger.Log(NLog.LogLevel.Warn, exceptIO, "Error with stream reading"); } } Dictionary <int, string> dataDictionary = new Dictionary <int, string>(); dataDictionary.Add(0, data); dataDictionary.Add(1, data); dataDictionary.Add(2, data); CWE15_External_Control_of_System_or_Configuration_Setting__ReadLine_74b.BadSink(dataDictionary); }