Example #1
0
 /// <summary>
 /// Opens a saved scanner file
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void scannerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
         if (result == DialogResult.OK)                      // Test result.
         {
             CRObjSerializer cros = new CRObjSerializer();
             crs = cros.LoadCRScanner(openFileDialog1.FileName);
             //set drop down box
             comboBox1.Items.Clear();
             foreach (var p in crs.Patterns)
             {
                 comboBox1.Items.Add(p);
             }
             //set the save path
             fileSavePath = openFileDialog1.FileName;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error"
                         , MessageBoxButtons.OK, MessageBoxIcon.Error);
         crl.WriteLog(CRLogger.CRLogTitle.Error, "Error opening a scanner file " +
                      ex.Message);
     }
 }
Example #2
0
 /// <summary>
 /// If a save path was created via Save As then this event simply
 /// saves to that path
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (fileSavePath == "")
     {
         //call save as
         saveAsToolStripMenuItem_Click(this, null);
     }
     else
     {
         try
         {
             //do save to fileSavePath
             CRObjSerializer cros = new CRObjSerializer();
             cros.SaveCRObj(fileSavePath, crs);
             MessageBox.Show("File saved to: " + fileSavePath, "Info",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
             crl.WriteLog(CRLogger.CRLogTitle.Error, "Error performing save " +
                          ex.Message);
         }
     }
 }
Example #3
0
 /// <summary>
 /// initScanner() loads scanner objects from serialized scanner files
 // </summary>
 /// <exception cref="SN17001Exception">SN17001Exception</exception>
 public void initScanner()
 {
     try
     {
         //Get the scanner objects
         CRObjSerializer cros = new CRObjSerializer();
         Icrscanner = cros.LoadCRScanner(iScanner);
         Acrscanner = cros.LoadCRScanner(aScanner);
     }
     catch (Exception ex)
     {
         throw new SN17001Exception(ex.Message);
     }
 }
Example #4
0
        public CRVData Scan()
        {
            //Get the scanner object
            CRObjSerializer cros      = new CRObjSerializer();
            CRScanner       crscanner = cros.LoadCRScanner(sPath);

            //Call the ICRISE implementation for this scanner
            ICRISE             icrise     = new SN171001IndicatorScan();
            List <CRIndicator> indicators = icrise.GetIndicators(dPath, crscanner);

            //Call the ICRIAE implementation for this scanner
            ICRIAE  icriae = new SN17001AnalyzerScan();
            CRVData crd    = icriae.GetCRVData(indicators, null);

            return(null);
        }
Example #5
0
        public void Test17001IScanner()
        {
            SN17001Scanner sn17 = new SN17001Scanner();

            try
            {
                var d = sn17.Scan(@"C:\Working\Project\CampaignPlanner");
                d.Notes = "This is a test scan on a real code base.";
                CRObjSerializer cros = new CRObjSerializer();
                cros.SaveCRObj(CRGlobal.CRScanData + "\\" + d.CRID + "_testScan" + ".xml", d);
            }
            catch (Exception ex)
            {
                throw new AssertFailedException(ex.Message);
            }
        }
Example #6
0
 /// <summary>
 /// Creates a new project with the data entered in the form and
 /// exits the form.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Savebutton_Click(object sender, EventArgs e)
 {
     try
     {
         CRProject crp = new CRProject();
         crp.Name        = ProjectNametextBox.Text;
         crp.Description = ProjectDescriptiontextBox.Text;
         newprojectsaveFileDialog.ShowDialog();
         crp.Path = newprojectsaveFileDialog.FileName;
         //write the project
         CRObjSerializer cros = new CRObjSerializer();
         cros.SaveCRObj(crp.Path, crp);
         //set the app var
         AppVar.Project = crp;
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #7
0
        /// <summary>
        /// Opens the SaveFile dialog and sets the save path
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //get attributes
                crScanner.Name        = textBox1.Text;
                crScanner.Description = textBox2.Text;

                CRObjSerializer cros = new CRObjSerializer();
                saveFileDialog1.ShowDialog();
                cros.SaveCRObj(saveFileDialog1.FileName, crScanner);
                RegexEditorForm.fileSavePath = saveFileDialog1.FileName;
                MessageBox.Show("file saved to: " + RegexEditorForm.fileSavePath,
                                "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while save file " +
                             ex.Message);
            }
        }
Example #8
0
        public void TestSTIGCL()
        {
            try
            {
                CRObjSerializer cros = new CRObjSerializer();
                CHECKLIST       ckl  = cros.LoadSTIGCKL(@"C:\TEMP\ckl_testSave.xml");
                foreach (var vuln in ckl.STIGS.iSTIG.VULN)
                {
                    if (vuln.STIG_DATA[0].ATTRIBUTE_DATA == "V-70149")
                    {
                        //vuln.FINDING_DETAILS = "finding test test";
                        //Console.WriteLine(vuln.COMMENTS.ToString());
                        Console.WriteLine(vuln.FINDING_DETAILS.ToString());
                        vuln.STATUS = "Open";
                    }
                }

                cros.SaveCRObj(@"C:\TEMP\ckl_testSave.ckl", ckl);
            }
            catch (Exception ex)
            {
                throw new AssertFailedException(ex.Message);
            }
        }