Ejemplo n.º 1
0
 /// <summary>
 /// This event handler opens a new RegexEditorForm with the contents
 /// of the file for the selected path passed into the context menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void goToToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string          fileText = File.ReadAllText(richTextBox1.SelectedText);
         RegexEditorForm regexf   = new RegexEditorForm(this.crs, this.crl,
                                                        RegexEditorForm.fileSavePath, this.workingScanDir, fileText);
         regexf.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        private void matchSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //do scan here
            ScanEngine se          = new ScanEngine();
            CRScanner  newcrsanner = new CRScanner();

            newcrsanner.Patterns.Add(richTextBox1.SelectedText);
            foreach (var fex in crs.FileExtensions)
            {
                newcrsanner.FileExtensions.Add(fex);
            }

            Cursor = Cursors.WaitCursor;
            try
            {
                if (workingScanDir == "")
                {
                    DialogResult result = folderBrowserDialog1.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        var vuls = se.GetVuls(folderBrowserDialog1.SelectedPath, newcrsanner);
                        //create the output
                        StringBuilder sb = new StringBuilder();
                        foreach (var v in vuls)
                        {
                            //sb.AppendFormat("{0}\n", v.VulData());
                            sb.AppendFormat("{0}\n", v.ToString());
                        }

                        //call new reg form here
                        RegexEditorForm newref = new RegexEditorForm(newcrsanner, crl,
                                                                     RegexEditorForm.fileSavePath, this.workingScanDir, sb.ToString());
                        newref.Show();
                    }
                }
                else
                {
                    var vuls = se.GetVuls(workingScanDir, newcrsanner);
                    //create the output
                    StringBuilder sb = new StringBuilder();
                    foreach (var v in vuls)
                    {
                        //sb.AppendFormat("{0}\n", v.VulData());
                        sb.AppendFormat("{0}\n", v.ToString());
                    }
                    //call new reg form here
                    RegexEditorForm newref = new RegexEditorForm(newcrsanner, crl,
                                                                 RegexEditorForm.fileSavePath, this.workingScanDir, sb.ToString());
                    newref.Show();
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while performing quick scan " +
                             ex.Message);
                Cursor = Cursors.Default;
            }
        }