public override bool execute()
        {
            if (sourceObject == null)
                DI.log.error("source object was null");
            else
                if (sourceObject.GetType() != sourceType)
                    DI.log.error("source object type was not List<string> is was " + sourceObject.GetType().FullName);
                else
                {
                    var filesToProcess = (List<string>) sourceObject;

                    setProgressBarValue(filesToProcess.Count);

                    var o2Assessment = new O2Assessment();
                    foreach (string file in filesToProcess)
                    {
                        DI.log.info("Importing file {0}", file);
                        if (false == o2AssessmentLoad.importFile(file, o2Assessment))
                            return false;
                        DI.log.info("There are {0} Findings loaded ", o2Assessment.o2Findings.Count);
                        incProgressBarValue();
                    }
                    resultsObject = o2Assessment;
                    return true;
                }
            return false;
        }
Exemple #2
0
 public static void createO2AssessmentFromTraces(IO2AssessmentSave o2AssessmentSave,string fileToCreate, List<IO2Trace> traces)
 {
     var o2Assessment = new O2Assessment();            
     foreach (IO2Trace trace in traces)
         o2Assessment.o2Findings.Add(createO2FindingFromTrace(trace));
     o2Assessment.save(o2AssessmentSave, fileToCreate);
 }
        //"Glue WebInspect -> Ounce Finding (Sql Injection)";
        public static List <IO2Finding> glueOnTraceNames(IO2AssessmentLoad o2AssessmentLoad, String ozasmtWithSinks, String ozasmtWithSoures, string gluedFindingVulnType)
        {
            var o2AssessmentOfOzasmtWithSinks   = new O2Assessment(o2AssessmentLoad, ozasmtWithSinks);
            var o2AssessmentOfOzasmtWithSources = new O2Assessment(o2AssessmentLoad, ozasmtWithSoures);

            return(glueOnTraceNames(o2AssessmentOfOzasmtWithSinks.o2Findings, o2AssessmentOfOzasmtWithSources.o2Findings, gluedFindingVulnType));
        }
Exemple #4
0
        public static void populateTreeNodeWithAssessmentStats(TreeNode treeNode, O2Assessment o2Assessment,
                                                               int imageIndex)
        {
            O2Forms.newTreeNode(treeNode, "# Findings:" + getNumberOf_Findings(o2Assessment), imageIndex, null);
            O2Forms.newTreeNode(treeNode, "# Smart Traces:" + getNumberOf_Findings_WithSmartTrace(o2Assessment),
                                imageIndex, null);

            /*   O2Forms.newTreeNode(treeNode, "File:" + Path.GetFileName(o2Assessment.lastOzasmtImportFile), imageIndex,
             *                     null);
             * O2Forms.newTreeNode(treeNode, "Size:" + o2Assessment.lastOzasmtImportFileSize, imageIndex, null);
             * string importTimeString =
             *     ((o2Assessment.lastOzasmtImportTimeSpan.Hours > 0)
             *          ? o2Assessment.lastOzasmtImportTimeSpan.Hours + "h : "
             *          : "") +
             *     ((o2Assessment.lastOzasmtImportTimeSpan.Minutes > 0)
             *          ? o2Assessment.lastOzasmtImportTimeSpan.Minutes + "m : "
             *          : "") +
             *     ((o2Assessment.lastOzasmtImportTimeSpan.Seconds > 0)
             *          ? o2Assessment.lastOzasmtImportTimeSpan.Seconds + "s : "
             *          : "") +
             *     ((o2Assessment.lastOzasmtImportTimeSpan.Milliseconds > 0)
             *          ? o2Assessment.lastOzasmtImportTimeSpan.Milliseconds + "ms"
             *          : "");
             * O2Forms.newTreeNode(treeNode, "Imported in:   " + importTimeString, imageIndex, null);*/
        }
Exemple #5
0
        public static void populateTreeNodeWithAssessmentStats(TreeNode treeNode, O2Assessment o2Assessment,
                                                               int imageIndex)
        {
            O2Forms.newTreeNode(treeNode, "# Findings:" + getNumberOf_Findings(o2Assessment), imageIndex, null);
            O2Forms.newTreeNode(treeNode, "# Smart Traces:" + getNumberOf_Findings_WithSmartTrace(o2Assessment),
                                imageIndex, null);

            /*   O2Forms.newTreeNode(treeNode, "File:" + Path.GetFileName(o2Assessment.lastOzasmtImportFile), imageIndex,
                                   null);
               O2Forms.newTreeNode(treeNode, "Size:" + o2Assessment.lastOzasmtImportFileSize, imageIndex, null);
               string importTimeString =
                   ((o2Assessment.lastOzasmtImportTimeSpan.Hours > 0)
                        ? o2Assessment.lastOzasmtImportTimeSpan.Hours + "h : "
                        : "") +
                   ((o2Assessment.lastOzasmtImportTimeSpan.Minutes > 0)
                        ? o2Assessment.lastOzasmtImportTimeSpan.Minutes + "m : "
                        : "") +
                   ((o2Assessment.lastOzasmtImportTimeSpan.Seconds > 0)
                        ? o2Assessment.lastOzasmtImportTimeSpan.Seconds + "s : "
                        : "") +
                   ((o2Assessment.lastOzasmtImportTimeSpan.Milliseconds > 0)
                        ? o2Assessment.lastOzasmtImportTimeSpan.Milliseconds + "ms"
                        : "");
               O2Forms.newTreeNode(treeNode, "Imported in:   " + importTimeString, imageIndex, null);*/
        }
        public static void createO2AssessmentFromTraces(IO2AssessmentSave o2AssessmentSave, string fileToCreate, List <IO2Trace> traces)
        {
            var o2Assessment = new O2Assessment();

            foreach (IO2Trace trace in traces)
            {
                o2Assessment.o2Findings.Add(createO2FindingFromTrace(trace));
            }
            o2Assessment.save(o2AssessmentSave, fileToCreate);
        }
Exemple #7
0
        public static int getNumberOf_Findings_WithSmartTrace(O2Assessment o2Assessment)
        {
            /*
             * query = new NLinqQuery(
             * @"  from m in methods
             * where !m.IsStatic
             * orderby m.Name
             * group m by m.Name into g
             * select new { MethodName = g.Key, Overloads = g.Count() }");
             */

            try
            {
                //var O2Timer = new O2Timer("Calculating Findings with Native Linq").start();
                return
                    ((from O2Finding finding in o2Assessment.o2Findings where finding.o2Traces.Count > 0 select finding).
                     Count());
                //O2Timer.stop();
                //if (findingsCountNative != null)// && findingsCountNlinqQuery is List<object>)
                //{
                //DI.log.debug("{0} == {1}", findingsCountNative, findingsCountNlinqQuery.Count);
                //  return (findingsCountNlinqQuery).Count;

                /*var timer2 = new O2Timer("Calculating Findings with NLinqQuery").start();
                 * var query =
                 *  new NLinqQuery(
                 *      //"from O2Finding finding in o2Findings where finding.o2Trace != null select finding).Count()");
                 *      "from O2Finding finding in o2Findings select finding");
                 * var linq = new LinqToMemory(query);
                 * linq.AddSource("o2Findings", o2Assessment.o2Findings);
                 * var findingsCountNlinqQuery = (List<object>)linq.Evaluate();
                 * timer2.stop();
                 * if (findingsCountNlinqQuery != null)// && findingsCountNlinqQuery is List<object>)
                 * {
                 *  DI.log.debug("{0} == {1}", findingsCountNative, findingsCountNlinqQuery.Count);
                 *  return (findingsCountNlinqQuery).Count;
                 * }
                 */
                //foreach (object o in linq.Enumerate())
                //{
                //    DI.log.info(o.ToString());
                //}
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "error execution NLinqQuery");
            }


            /*        var O2Timer = new O2Timer("Calculating Findings with Smart Trace").start();
             * var findingsCount =  (from O2Finding finding in o2Assessment.o2Findings where finding.o2Trace != null select finding).Count();
             * O2Timer.stop();*/
            //return findingsCount;
            return(0);
        }
Exemple #8
0
        public static int getNumberOf_Findings_WithSmartTrace(O2Assessment o2Assessment)
        {
            /*
             * query = new NLinqQuery(
    @"  from m in methods
          where !m.IsStatic
          orderby m.Name
          group m by m.Name into g
          select new { MethodName = g.Key, Overloads = g.Count() }");
*/

            try
            {
                //var O2Timer = new O2Timer("Calculating Findings with Native Linq").start();
                return
                    (from O2Finding finding in o2Assessment.o2Findings where finding.o2Traces.Count > 0 select finding).
                        Count();
                //O2Timer.stop();
                //if (findingsCountNative != null)// && findingsCountNlinqQuery is List<object>)
                //{
                //DI.log.debug("{0} == {1}", findingsCountNative, findingsCountNlinqQuery.Count);
                //  return (findingsCountNlinqQuery).Count;

                /*var timer2 = new O2Timer("Calculating Findings with NLinqQuery").start();
                var query =
                    new NLinqQuery(
                        //"from O2Finding finding in o2Findings where finding.o2Trace != null select finding).Count()");
                        "from O2Finding finding in o2Findings select finding");
                var linq = new LinqToMemory(query);
                linq.AddSource("o2Findings", o2Assessment.o2Findings);
                var findingsCountNlinqQuery = (List<object>)linq.Evaluate();
                timer2.stop();
                if (findingsCountNlinqQuery != null)// && findingsCountNlinqQuery is List<object>)
                {
                    DI.log.debug("{0} == {1}", findingsCountNative, findingsCountNlinqQuery.Count);
                    return (findingsCountNlinqQuery).Count;
                }
                */
                //foreach (object o in linq.Enumerate())
                //{
                //    DI.log.info(o.ToString());
                //}
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "error execution NLinqQuery");
            }


            /*        var O2Timer = new O2Timer("Calculating Findings with Smart Trace").start();
            var findingsCount =  (from O2Finding finding in o2Assessment.o2Findings where finding.o2Trace != null select finding).Count();
            O2Timer.stop();*/
            //return findingsCount;
            return 0;
        }
        public Thread loadO2Assessment(IO2AssessmentLoad o2AssessmentLoad, string pathToFileToLoad)
        {
            if (o2AssessmentLoad == null || false == File.Exists(pathToFileToLoad))
            {
                this.invokeOnThread(() => laLoadingDroppedFile.Visible = false);
                return null;
            }
            return O2Thread.mtaThread(() =>
                                          {
                                              this.invokeOnThread(() => laLoadingDroppedFile.Visible = true);

                                              var o2Assemment = new O2Assessment(o2AssessmentLoad, pathToFileToLoad);
                                                  // load this on another thread 
                                              var sync = new AutoResetEvent(false);
                                              this.invokeOnThread(() => // and then complete it on the controls thread
                                                                      {
                                                                          loadO2Assessment(o2Assemment);
                                                                          tbSavedFileName.Text =
                                                                              (cbClearOnOzasmtDrop.Checked)
                                                                                  ? pathToFileToLoad
                                                                                  : DI.config.TempFileNameInTempDirectory + "_" + Path.GetFileName(pathToFileToLoad);
                                                                          laLoadingDroppedFile.Visible = false;
                                                                          sync.Set();
                                                                      });
                                              sync.WaitOne();
                                          });

        }
 public static Thread openInFloatWindow(string ozasmtFile, string controlName)
 {
     var o2AssessmentLoadEngine = OzasmtUtils.getO2AssessmentLoadEngine(ozasmtFile, o2AssessmentLoadEngines);
     if (o2AssessmentLoadEngine != null)
     {
         var o2Assessment = new O2Assessment(o2AssessmentLoadEngine, ozasmtFile);
         if (o2Assessment.o2Findings.Count > 0)
             return openInFloatWindow(o2Assessment.o2Findings, controlName);
     }
     return null;
 }
        private void saveFindings(IEnumerable<IO2Finding> o2FindingsToSave, bool saveIntoO2BinaryFormat)
        {
            btSaveFindings.Enabled = false;
            btSave.Enabled = false;

            if (o2AssessmentSave == null)
                DI.log.showMessageBox("Aborting save since there is no O2AssessmentSave Engine configured");
            {

                OzasmtCompatibility.makeCompatibleWithOunceV6(o2FindingsToSave);

                string targetFile = tbSavedFileName.Text;
                var o2Assessment = new O2Assessment {name = assessmentName};
                o2Assessment.o2Findings.AddRange(o2FindingsToSave);
                if (saveIntoO2BinaryFormat)
                {
                    if (Path.GetExtension(targetFile) != DI.config.O2FindingsFileExtension)
                    {
                        targetFile += DI.config.O2FindingsFileExtension;
                        tbSavedFileName.Text = targetFile;
                    }
                    if (o2Assessment.saveAsO2Format(targetFile))
                        lbFileSaved.Visible = true;

                }
                else
                    if (o2Assessment.save(o2AssessmentSave, targetFile))
                        lbFileSaved.Visible = true;
                btSaveFindings.Enabled = true;
                btSave.Enabled = true;
            }
        }
Exemple #12
0
  //"Glue WebInspect -> Ounce Finding (Sql Injection)";
 public static List<IO2Finding> glueOnTraceNames(IO2AssessmentLoad o2AssessmentLoad, String ozasmtWithSinks, String ozasmtWithSoures, string gluedFindingVulnType)
 {
     var o2AssessmentOfOzasmtWithSinks = new O2Assessment(o2AssessmentLoad,ozasmtWithSinks);
     var o2AssessmentOfOzasmtWithSources = new O2Assessment (o2AssessmentLoad,ozasmtWithSoures);
     return glueOnTraceNames(o2AssessmentOfOzasmtWithSinks.o2Findings, o2AssessmentOfOzasmtWithSources.o2Findings, gluedFindingVulnType);
 }
Exemple #13
0
 public static int getNumberOf_Findings(O2Assessment o2Assessment)
 {
     return(o2Assessment.o2Findings.Count);
 }
Exemple #14
0
 public static int getNumberOf_Findings(O2Assessment o2Assessment)
 {
     return o2Assessment.o2Findings.Count;
 }
        public static Dictionary <String, List <IO2Trace> > getDictionaryWithO2AllSubTraces(O2Assessment o2Assessment, bool uniqueList)
        {
            var allTracesInAssessmment = new Dictionary <String, List <IO2Trace> >();

            foreach (IO2Finding o2Finding in o2Assessment.o2Findings)
            {
                getAllTraces(o2Finding.o2Traces, allTracesInAssessmment, uniqueList);
            }
            return(allTracesInAssessmment);
        }
 public static Dictionary <String, List <IO2Trace> > getDictionaryWithO2AllSubTraces(O2Assessment o2Assessment)
 {
     return(getDictionaryWithO2AllSubTraces(o2Assessment, true));
 }