public override void Bad() { string data; /* FLAW: Set data to a hardcoded value */ data = "23 ~j;asn!@#/>as"; string[] dataArray = new string[5]; dataArray[2] = data; CWE321_Hard_Coded_Cryptographic_Key__basic_66b.BadSink(dataArray); }
/* goodG2B() - use goodsource and badsink */ private static void GoodG2B() { string data; data = ""; /* Initialize data */ /* read user input from console with readLine */ try { /* FIX: Read data from the console using readLine() */ data = Console.ReadLine(); } catch (IOException exceptIO) { IO.Logger.Log(NLog.LogLevel.Warn, "Error with stream reading", exceptIO); } string[] dataArray = new string[5]; dataArray[2] = data; CWE321_Hard_Coded_Cryptographic_Key__basic_66b.GoodG2BSink(dataArray); }