/* goodG2B() - use goodsource and badsink */ private void GoodG2B() { string data = null; /* FIX: Use a hardcoded string */ data = "foo"; goodG2BPublicStatic = true; CWE313_Cleartext_Storage_in_a_File_or_on_Disk__ReadLine_22b.GoodG2BSink(data); }
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ private void GoodB2G2() { string data = null; 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"); } } goodB2G2PublicStatic = true; CWE313_Cleartext_Storage_in_a_File_or_on_Disk__ReadLine_22b.GoodB2G2Sink(data); }