/* goodG2B() - use goodsource and badsink */ private void GoodG2B(HttpRequest req, HttpResponse resp) { string data = null; /* FIX: Use a hardcoded string */ data = "foo"; goodG2BPublicStatic = true; CWE89_SQL_Injection__Web_Get_Cookies_Web_ExecuteScalar_22b.GoodG2BSink(data, req, resp); }
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ private void GoodB2G2(HttpRequest req, HttpResponse resp) { string data = null; data = ""; /* initialize data in case there are no cookies */ /* Read data from cookies */ { HttpCookieCollection cookieSources = req.Cookies; if (cookieSources != null) { /* POTENTIAL FLAW: Read data from the first cookie value */ data = cookieSources[0].Value; } } goodB2G2PublicStatic = true; CWE89_SQL_Injection__Web_Get_Cookies_Web_ExecuteScalar_22b.GoodB2G2Sink(data, req, resp); }