/* goodG2B() - use goodsource and badsink */ private void GoodG2B() { string data = null; /* FIX: Use a regular string (non-sensitive string) */ data = "Hello World"; goodG2BPublicStatic = true; CWE319_Cleartext_Tx_Sensitive_Info__send_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; using (SecureString securePwd = new SecureString()) { for (int i = 0; i < "AP@ssw0rd".Length; i++) { /* INCIDENTAL: CWE-798 Use of Hard-coded Credentials */ securePwd.AppendChar("AP@ssw0rd"[i]); } /* POTENTIAL FLAW: Set data to be a password, which can be transmitted over a non-secure * channel in the sink */ data = securePwd.ToString(); } goodB2G2PublicStatic = true; CWE319_Cleartext_Tx_Sensitive_Info__send_22b.GoodB2G2Sink(data); }