public static IO2Finding getO2Finding(AssessmentAssessmentFileFinding finding,
                                              AssessmentAssessmentFile assessmentFile, AssessmentRun assessmentRun)
        {
            var o2Finding = new O2Finding
            {
                actionObject = finding.actionobject_id,
                columnNumber = finding.column_number,
                confidence   = finding.confidence,
                exclude      = finding.exclude,
                file         = assessmentFile.filename,
                lineNumber   = finding.line_number,
                ordinal      = finding.ordinal,
                propertyIds  = finding.property_ids,
                recordId     = finding.record_id,
                severity     = finding.severity,
                o2Traces     = getO2TraceFromCallInvocation(finding.Trace, assessmentRun),
            };

            if (finding.cxt_id != null)
            {
                o2Finding.context = getStringIndexValue(UInt32.Parse(finding.cxt_id), assessmentRun);
            }

            o2Finding.callerName = finding.caller_name;
            if (o2Finding.callerName == null && finding.caller_name_id != null)
            {
                o2Finding.callerName = getStringIndexValue(UInt32.Parse(finding.caller_name_id), assessmentRun);
            }

            o2Finding.projectName = finding.project_name;
            if (o2Finding.projectName == null && finding.project_name_id != null)
            {
                o2Finding.projectName = getStringIndexValue(UInt32.Parse(finding.project_name_id), assessmentRun);
            }

            o2Finding.vulnName = finding.vuln_name;
            if (o2Finding.vulnName == null && finding.vuln_name_id != null)
            {
                o2Finding.vulnName = getStringIndexValue(UInt32.Parse(finding.vuln_name_id), assessmentRun);
            }

            o2Finding.vulnType = finding.vuln_type;
            if (o2Finding.vulnType == null && finding.vuln_type_id != null)
            {
                o2Finding.vulnType = getStringIndexValue(UInt32.Parse(finding.vuln_type_id), assessmentRun);
            }

            if (finding.Text != null)
            {
                o2Finding.text = new List <string>(finding.Text);
            }

            OzasmtUtils.fixExternalSourceSourceMappingProblem(o2Finding);
            return(o2Finding);
        }
 public void addO2FindingsToAssessmentRunObject(IEnumerable<IO2Finding> o2Findings)
 {
     Dictionary<string, List<AssessmentAssessmentFileFinding>> filesMappedToO2Findings =
         getFilesToO2FindingMappings(o2Findings);
     var assessmentFiles = new List<AssessmentAssessmentFile>();
     foreach (string file in filesMappedToO2Findings.Keys)
     {
         var assessmentFile = new AssessmentAssessmentFile
                                  {
                                      filename = file,
                                      Finding = filesMappedToO2Findings[file].ToArray()
                                  };
         assessmentFiles.Add(assessmentFile);
     }
     assessmentRun.Assessment.Assessment[0].AssessmentFile = assessmentFiles.ToArray();
 }
        public void addO2FindingsToAssessmentRunObject(IEnumerable <IO2Finding> o2Findings)
        {
            Dictionary <string, List <AssessmentAssessmentFileFinding> > filesMappedToO2Findings =
                getFilesToO2FindingMappings(o2Findings);
            var assessmentFiles = new List <AssessmentAssessmentFile>();

            foreach (string file in filesMappedToO2Findings.Keys)
            {
                var assessmentFile = new AssessmentAssessmentFile
                {
                    filename = file,
                    Finding  = filesMappedToO2Findings[file].ToArray()
                };
                assessmentFiles.Add(assessmentFile);
            }
            assessmentRun.Assessment.Assessment[0].AssessmentFile = assessmentFiles.ToArray();
        }
        public static IO2Finding getO2Finding(AssessmentAssessmentFileFinding finding,
                                              AssessmentAssessmentFile assessmentFile, AssessmentRun assessmentRun)
        {
            var o2Finding = new O2Finding
                                {
                                    actionObject = finding.actionobject_id,
                                    columnNumber = finding.column_number,
                                    confidence = finding.confidence,
                                    exclude = finding.exclude,
                                    file = assessmentFile.filename,
                                    lineNumber = finding.line_number,
                                    ordinal = finding.ordinal,
                                    propertyIds = finding.property_ids,
                                    recordId = finding.record_id,
                                    severity = finding.severity,
                                    o2Traces = getO2TraceFromCallInvocation(finding.Trace, assessmentRun),
                                };

            if (finding.cxt_id != null)
                o2Finding.context = getStringIndexValue(UInt32.Parse(finding.cxt_id), assessmentRun);

            o2Finding.callerName = finding.caller_name;
            if (o2Finding.callerName == null && finding.caller_name_id != null)
                o2Finding.callerName = getStringIndexValue(UInt32.Parse(finding.caller_name_id), assessmentRun);

            o2Finding.projectName = finding.project_name;
            if (o2Finding.projectName == null && finding.project_name_id != null)
                o2Finding.projectName = getStringIndexValue(UInt32.Parse(finding.project_name_id), assessmentRun);

            o2Finding.vulnName = finding.vuln_name;
            if (o2Finding.vulnName == null && finding.vuln_name_id != null)
                o2Finding.vulnName = getStringIndexValue(UInt32.Parse(finding.vuln_name_id), assessmentRun);

            o2Finding.vulnType = finding.vuln_type;
            if (o2Finding.vulnType == null && finding.vuln_type_id != null)
                o2Finding.vulnType = getStringIndexValue(UInt32.Parse(finding.vuln_type_id), assessmentRun);

            if (finding.Text != null)
                o2Finding.text = new List<string>(finding.Text);

            OzasmtUtils.fixExternalSourceSourceMappingProblem(o2Finding);
            return o2Finding;
        }
Example #5
0
        public static AssessmentRun createFilteredAssessmentRunObjectBasedOnCriteria(AnalysisFilters.filter fFilter,
                                                                                     O2AssessmentData_OunceV6
                                                                                         fadO2AssessmentDataOunceV6)
        {
            AssessmentRun arFilteredAssessmentRun = OzasmtUtils_OunceV6.getDefaultAssessmentRunObject();

            // create list to contain the filtered AssessmentFiles
            var lafFilteredAssessmentFiles = new List<AssessmentAssessmentFile>();

            if (StringsAndLists.notNull(fadO2AssessmentDataOunceV6.arAssessmentRun, typeof (AssessmentRun).Name))
                if (null != fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment)
                    foreach (Assessment aAssessment in fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment)
                    {
                        foreach (AssessmentAssessmentFile afAssessmentFile in aAssessment.AssessmentFile)
                        {
                            // create filtered AssesmentFile object
                            var afFilteredAssessmentFile = new AssessmentAssessmentFile();
                            // and copy the important values from the original into it
                            afFilteredAssessmentFile.filename = afAssessmentFile.filename;
                            afFilteredAssessmentFile.error_status = afAssessmentFile.error_status;
                            afFilteredAssessmentFile.last_modified_time = afAssessmentFile.last_modified_time;
                            // create list to contain Findings that match filter
                            var lfFindingsThatMatchCriteria = new List<AssessmentAssessmentFileFinding>();
                            // if there are findings
                            if (null != afAssessmentFile.Finding)
                            {
                                foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding)
                                    fFilter.applyFilterAndPopulateList(fadO2AssessmentDataOunceV6.arAssessmentRun, fFinding,
                                                                       lfFindingsThatMatchCriteria,
                                                                       lafFilteredAssessmentFiles);
                                // invoke the respective filter

                                if (lfFindingsThatMatchCriteria.Count > 0)
                                    // if there were findings in this AssessmentFile
                                {
                                    afFilteredAssessmentFile.Finding = lfFindingsThatMatchCriteria.ToArray();
                                    // map them to the Finding array
                                    lafFilteredAssessmentFiles.Add(afFilteredAssessmentFile);
                                    // add add the filtered AssessmentFile to its list
                                }
                            }
                        }
                    }

            // (if there are some)add the filtered AssessentFiles into the Filtered AssessmentRun object
            if (lafFilteredAssessmentFiles.Count > 0)
                arFilteredAssessmentRun.Assessment.Assessment[0].AssessmentFile = lafFilteredAssessmentFiles.ToArray();
            // for now all consolidate all projects into one
            return arFilteredAssessmentRun;
        }
Example #6
0
 public static AssessmentAssessmentFile createNewAssessmentFileFromExistingOne(
     AssessmentAssessmentFile afOriginalFile)
 {
     // need to create a new one since we don't want to add the findings of the current file
     var afNewFile = new AssessmentAssessmentFile();
     afNewFile.error_status = afOriginalFile.error_status;
     afNewFile.filename = afOriginalFile.filename;
     afNewFile.last_modified_time = afOriginalFile.last_modified_time;
     return afNewFile;
 }