Ejemplo n.º 1
0
        /* goodB2G() - use BadSource and GoodSink */
        private static void GoodB2G()
        {
            string data;

            data = ""; /* Initialize data */
            /* Read data using an outbound tcp connection */
            {
                try
                {
                    /* Read data using an outbound tcp connection */
                    using (TcpClient tcpConn = new TcpClient("host.example.org", 39544))
                    {
                        /* read input from socket */
                        using (StreamReader sr = new StreamReader(tcpConn.GetStream()))
                        {
                            /* POTENTIAL FLAW: Read data using an outbound tcp connection */
                            data = sr.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);
            CWE643_Xpath_Injection__Connect_tcp_74b.GoodB2GSink(dataDictionary);
        }
Ejemplo n.º 2
0
        /* 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);
            CWE643_Xpath_Injection__Connect_tcp_74b.GoodG2BSink(dataDictionary);
        }