public static List<String> getListWithUsedActionObjects(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsActionObjects = new List<String>(); try { if (StringsAndLists.notNull(fadO2AssessmentDataOunceV6.arAssessmentRun, typeof(AssessmentRun).Name)) if (null != fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) foreach (Assessment aAssessment in fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) { AssessmentAssessmentFile[] afAssessmentFiles = aAssessment.AssessmentFile; "There are {0} assessment files loaded".debug(afAssessmentFiles.Length.ToString()); foreach (AssessmentAssessmentFile afAssessmentFile in afAssessmentFiles) if (null != afAssessmentFile.Finding) foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding) if (false == lsActionObjects.Contains(fFinding.actionobject_id.ToString())) lsActionObjects.Add(fFinding.actionobject_id.ToString()); } "There are {0} unique ActionObjects".debug(lsActionObjects.Count.ToString()); } catch (Exception e) { "In getListWithUsedActionObjects: {0}".error(e.Message); } return lsActionObjects; }
public static List<String> getListOf_Sinks(String sPathToSavedXmlFile, ref O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { // Analysis.TraceType ttTraceType = Analysis.TraceType.Known_Sink; List<String> lsSinks = getListOf_KnownSinks(sPathToSavedXmlFile, ref fadO2AssessmentDataOunceV6); lsSinks.AddRange(getListOf_LostSinks(sPathToSavedXmlFile, ref fadO2AssessmentDataOunceV6)); return lsSinks; }
public static List <String> getListOfVulnerabilityTypes(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsVulnerabilityType = new List <string>(); if (null != fadO2AssessmentDataOunceV6) { if (fadO2AssessmentDataOunceV6.dVulnerabilityType != null) { foreach (String sVulnerabilityType in fadO2AssessmentDataOunceV6.dVulnerabilityType.Keys) { if (sVulnerabilityType.IndexOf("Vulnerability.") > -1) // normal case { lsVulnerabilityType.Add(String.Format("{0} ({1})", sVulnerabilityType, fadO2AssessmentDataOunceV6.dVulnerabilityType[ sVulnerabilityType].Count)); } else // case where the vuln type has been changed (for example using the o2 custom filters { lsVulnerabilityType.Add(sVulnerabilityType); } } } } return(lsVulnerabilityType); }
public static String getLineFromSourceCode(CallInvocation ciCallInvocation, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { List <string> lsSourceCode = Files.loadSourceFileIntoList( fadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces[ciCallInvocation.fn_id - 1].value); return(Files.getLineFromSourceCode(ciCallInvocation.line_number, lsSourceCode)); }
public static void fixAllFileReferencesOnAssessmentDataObject(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6, String sFix_PathToFind, String sFix_PathToReplace) { var rfmresolvedFileMapping = new SourceCodeMappingsUtils.resolvedFileMapping("") { sFix_PathToFind = sFix_PathToFind, sFix_PathToReplace = sFix_PathToReplace }; fixAllFileReferencesOnAssessmentDataObject(oadO2AssessmentDataOunceV6, rfmresolvedFileMapping); }
public static void tryToFixSourceCodeReferences(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6) { DI.log.debug("Trying To Fix Source Code References"); SourceCodeMappings scmSourceCodeMappings = SourceCodeMappingsUtils.getSourceCodeMappings(); foreach (SourceCodeMappingsMapping mMapping in scmSourceCodeMappings.Mapping) { fixAllFileReferencesOnAssessmentDataObject(oadO2AssessmentDataOunceV6, mMapping.replaceThisString, mMapping.withThisString); } }
public static String getSource(AssessmentAssessmentFileFinding fFinding, O2AssessmentData_OunceV6 oadF1AssessmentDataOunceV6) { CallInvocation ciCallInvocation = AnalysisSearch.findTraceTypeInSmartTrace_Recursive_returnCallInvocation(fFinding.Trace, TraceType.Source); if (ciCallInvocation != null) return OzasmtUtils_OunceV6.getStringIndexValue(ciCallInvocation.sig_id, oadF1AssessmentDataOunceV6); return ""; }
public static List<String> getListOfAssessmentFiles(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsAssessmentFiles = new List<string>(); if (fadO2AssessmentDataOunceV6.dAssessmentFiles != null) foreach (AssessmentAssessmentFile asAssessmentFile in fadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) { lsAssessmentFiles.Add(String.Format("{0} ({1})", asAssessmentFile.filename, asAssessmentFile.Finding.Length)); } return lsAssessmentFiles; }
public static void MakeAllLostSinksIntoKnownSinks(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6) { foreach (AssessmentAssessmentFileFinding fFinding in oadO2AssessmentDataOunceV6.dFindings.Keys) { CallInvocation ciLostSink = AnalysisSearch.findTraceTypeInSmartTrace_Recursive_returnCallInvocation(fFinding.Trace, TraceType.Lost_Sink); if (ciLostSink != null) { ciLostSink.trace_type = (UInt32) TraceType.Known_Sink; } } }
public static List<String> getListOfUniqueFiles(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6) { var lsUniqueFiles = new List<string>(); // search in FileIndexes foreach (AssessmentRunFileIndex fiFileIndex in oadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces) if (false == lsUniqueFiles.Contains(fiFileIndex.value)) lsUniqueFiles.Add(fiFileIndex.value); foreach (AssessmentAssessmentFile fFile in oadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) if (false == lsUniqueFiles.Contains(fFile.filename)) lsUniqueFiles.Add(fFile.filename); // search in FileFindings // {to do} return lsUniqueFiles; }
public static void getListWithMethodsCalled_Recursive(CallInvocation[] cCallInvocations, List<CallInvocation> lciMethodsCalled, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6, Analysis.SmartTraceFilter stfSmartTraceFilter) { if (cCallInvocations != null) foreach (CallInvocation cCall in cCallInvocations) { lciMethodsCalled.Add(cCall); //lsMethodsCalled.Add(getTextFromFindingBySmartTraceFilter(cCall,fadO2AssessmentDataOunceV6,stfSmartTraceFilter)); getListWithMethodsCalled_Recursive(cCall.CallInvocation1, lciMethodsCalled, fadO2AssessmentDataOunceV6, stfSmartTraceFilter); } }
public static List<String> getListOfFindingsPerVulnerabilityType(String sVulnerabilityType, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsFindings = new List<String>(); if (fadO2AssessmentDataOunceV6.dVulnerabilityType != null) foreach ( AssessmentAssessmentFileFinding fFinding in fadO2AssessmentDataOunceV6.dVulnerabilityType[sVulnerabilityType]) lsFindings.Add(fFinding.caller_name ?? getStringIndexValue(UInt32.Parse(fFinding.caller_name_id), fadO2AssessmentDataOunceV6)); return lsFindings; }
public static List<String> getListOfVulnerabilityTypes(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsVulnerabilityType = new List<string>(); if (null != fadO2AssessmentDataOunceV6) if (fadO2AssessmentDataOunceV6.dVulnerabilityType != null) foreach (String sVulnerabilityType in fadO2AssessmentDataOunceV6.dVulnerabilityType.Keys) if (sVulnerabilityType.IndexOf("Vulnerability.") > -1) // normal case lsVulnerabilityType.Add(String.Format("{0} ({1})", sVulnerabilityType, fadO2AssessmentDataOunceV6.dVulnerabilityType[ sVulnerabilityType].Count)); else // case where the vuln type has been changed (for example using the o2 custom filters lsVulnerabilityType.Add(sVulnerabilityType); return lsVulnerabilityType; }
public static List <String> getListOfAssessmentFiles(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsAssessmentFiles = new List <string>(); if (fadO2AssessmentDataOunceV6.dAssessmentFiles != null) { foreach (AssessmentAssessmentFile asAssessmentFile in fadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) { lsAssessmentFiles.Add(String.Format("{0} ({1})", asAssessmentFile.filename, asAssessmentFile.Finding.Length)); } } return(lsAssessmentFiles); }
public static void fixAllFileReferencesOnAssessmentDataObject(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6, SourceCodeMappingsUtils.resolvedFileMapping rfmResolvedFileMapping) { if (oadO2AssessmentDataOunceV6 != null && rfmResolvedFileMapping != null) { foreach (AssessmentRunFileIndex fiFileIndex in oadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces) fiFileIndex.value = fiFileIndex.value.Replace(rfmResolvedFileMapping.sFix_PathToFind, rfmResolvedFileMapping.sFix_PathToReplace); foreach (AssessmentAssessmentFile fFile in oadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) if (rfmResolvedFileMapping.sFix_PathToFind != "") fFile.filename = fFile.filename.Replace(rfmResolvedFileMapping.sFix_PathToFind, rfmResolvedFileMapping.sFix_PathToReplace); else fFile.filename = Path.Combine(rfmResolvedFileMapping.sFix_PathToReplace, fFile.filename); } }
public static List<String> getListOf_LostSinks_Unique(String sPathToSavedXmlFile, ref O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lMatches = new List<string>(); bool bChangeFindingData = false; Analysis.FindingNameFormat ffnFindingNameFormat = Analysis.FindingNameFormat.FindingType; var ffulsFilter = new AnalysisFilters.filter_FindUniqueLostSinks(ffnFindingNameFormat, bChangeFindingData); List<AssessmentAssessmentFileFinding> laaffFindings = getListOfFindingsUsingFilter(sPathToSavedXmlFile, ffulsFilter, ref fadO2AssessmentDataOunceV6); foreach (AssessmentAssessmentFileFinding aaffFinding in laaffFindings) lMatches.Add(Analysis.getSmartTraceNameOfTraceType(aaffFinding.Trace, TraceType.Lost_Sink, fadO2AssessmentDataOunceV6)); return lMatches; }
public static List<String> getListOfFindingsPerFile(String sAssessmentFileNameToProcess, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsFindings = new List<String>(); if (fadO2AssessmentDataOunceV6.dAssessmentFiles != null) foreach (AssessmentAssessmentFile afAssessmentFile in fadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) if (afAssessmentFile.filename == sAssessmentFileNameToProcess) // we have found the assessment file, so add the filtered findings to the List { foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding) lsFindings.Add(fFinding.caller_name ?? getStringIndexValue(UInt32.Parse(fFinding.caller_name_id), fadO2AssessmentDataOunceV6)); return lsFindings; } return lsFindings; }
public static List <String> getListOfFindingsPerVulnerabilityType(String sVulnerabilityType, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsFindings = new List <String>(); if (fadO2AssessmentDataOunceV6.dVulnerabilityType != null) { foreach ( AssessmentAssessmentFileFinding fFinding in fadO2AssessmentDataOunceV6.dVulnerabilityType[sVulnerabilityType]) { lsFindings.Add(fFinding.caller_name ?? getStringIndexValue(UInt32.Parse(fFinding.caller_name_id), fadO2AssessmentDataOunceV6)); } } return(lsFindings); }
public static void showCallInvocationDetailsInDataGridView(DataGridView dgvDataGridView, CallInvocation ciCallInvocation, O2AssessmentData_OunceV6 oadAssessmentDataOunceV6) { if (ciCallInvocation != null) { try { dgvDataGridView.Columns.Clear(); O2Forms.addToDataGridView_Column(dgvDataGridView, "Name", 90); O2Forms.addToDataGridView_Column(dgvDataGridView, "Value", -1); dgvDataGridView.Rows.Add("sig_id", OzasmtUtils_OunceV6.getStringIndexValue(ciCallInvocation.sig_id, oadAssessmentDataOunceV6)); dgvDataGridView.Rows.Add("cxt_id", OzasmtUtils_OunceV6.getStringIndexValue(ciCallInvocation.cxt_id, oadAssessmentDataOunceV6)); dgvDataGridView.Rows.Add("fn_id", OzasmtUtils_OunceV6.getFileIndexValue(ciCallInvocation.fn_id, oadAssessmentDataOunceV6)); dgvDataGridView.Rows.Add("cn id", OzasmtUtils_OunceV6.getStringIndexValue(ciCallInvocation.cn_id, oadAssessmentDataOunceV6)); dgvDataGridView.Rows.Add("trace_type", ciCallInvocation.trace_type.ToString()); dgvDataGridView.Rows.Add("column_number", ciCallInvocation.column_number.ToString()); dgvDataGridView.Rows.Add("line_number", ciCallInvocation.line_number.ToString()); dgvDataGridView.Rows.Add("mn_id", OzasmtUtils_OunceV6.getStringIndexValue(ciCallInvocation.mn_id, oadAssessmentDataOunceV6)); dgvDataGridView.Rows.Add("ordinal", ciCallInvocation.ordinal.ToString()); dgvDataGridView.Rows.Add("taint_propagation", ciCallInvocation.taint_propagation); if (ciCallInvocation.Text != null) { var sbText = new StringBuilder(); foreach (String sLine in ciCallInvocation.Text) sbText.AppendLine(sLine); dgvDataGridView.Rows.Add("Text", sbText.ToString()); } //ciCallInvocation.Text; } catch (Exception ex) { DI.log.error("in showCallInvocationDetailsInDataGridView :{0}", ex.Message); } } }
public static List<String> getListOf_TraceSignatures_ByTraceType(String sPathToSavedXmlFile, TraceType ttTraceType, ref O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsMatches = new List<string>(); bool bVerbose = false; if (fadO2AssessmentDataOunceV6 == null) Analysis.loadAssessmentFile(sPathToSavedXmlFile, bVerbose, ref fadO2AssessmentDataOunceV6); if (null != fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) foreach (Assessment aAssessment in fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) foreach (AssessmentAssessmentFile afAssessmentFile in aAssessment.AssessmentFile) if (null != afAssessmentFile.Finding) foreach (AssessmentAssessmentFileFinding aaffFinding in afAssessmentFile.Finding) { String sSignature = Analysis.getSmartTraceNameOfTraceType(aaffFinding.Trace, ttTraceType, fadO2AssessmentDataOunceV6); if (sSignature != "" && false == lsMatches.Contains(sSignature)) lsMatches.Add(sSignature); } return lsMatches; }
public static List <String> getListWithUsedActionObjects(O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsActionObjects = new List <String>(); try { if (StringsAndLists.notNull(fadO2AssessmentDataOunceV6.arAssessmentRun, typeof(AssessmentRun).Name)) { if (null != fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) { foreach (Assessment aAssessment in fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment) { AssessmentAssessmentFile[] afAssessmentFiles = aAssessment.AssessmentFile; DI.log.debug("There are {0} assessment files loaded", afAssessmentFiles.Length.ToString()); foreach (AssessmentAssessmentFile afAssessmentFile in afAssessmentFiles) { if (null != afAssessmentFile.Finding) { foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding) { if (false == lsActionObjects.Contains(fFinding.actionobject_id.ToString())) { lsActionObjects.Add(fFinding.actionobject_id.ToString()); } } } } } } } DI.log.debug("There are {0} unique ActionObjects", lsActionObjects.Count.ToString()); } catch (Exception e) { DI.log.error("In getListWithUsedActionObjects: {0}", e.Message); } return(lsActionObjects); }
public static bool areAllSourceCodeReferencesInAssessmentFileValid(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6) { DI.log.debug("Checking to see if all source code references are valid"); if (oadO2AssessmentDataOunceV6.arAssessmentRun == null) { DI.log.error( "in areAllSourceCodeReferencesInAssessmentFileValid: oadO2AssessmentDataOunceV6.arAssessmentRun == null (aborting)"); return true; } try { foreach (string sFile in getListOfUniqueFiles(oadO2AssessmentDataOunceV6)) if (false == File.Exists(sFile)) return false; return true; } catch (Exception ex) { DI.log.error("in areAllSourceCodeReferencesInAssessmentFileValid: {0}", ex.Message); return false; } }
public static TimeSpan loadAssessmentFile(string sXmlFileToLoad, bool bVerbose, ref O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { try { if (sXmlFileToLoad == null) return new TimeSpan(); fadO2AssessmentDataOunceV6 = new O2AssessmentData_OunceV6(); DateTime dStartTime = DateTime.Now; // if (sXmlFileToLoad.IndexOf(".xml") == -1 && sXmlFileToLoad.IndexOf("ozasmt") == -1) // { // DI.log.error("Invalid Assessment file provided {0}", sXmlFileToLoad); // return new TimeSpan(); // } if (bVerbose) DI.log.info("Loading Assessment Xml File {0}", sFileLoaded); sFileLoaded = sXmlFileToLoad; fadO2AssessmentDataOunceV6.arAssessmentRun = OzasmtUtils_OunceV6.getAssessmentRunObjectFromXmlFile(sXmlFileToLoad); fadO2AssessmentDataOunceV6.sDb_id = OzasmtUtils_OunceV6.fromAssessmentFile_get_DbId(sXmlFileToLoad); // populateDictionariesWithXrefsToLoadedAssessment(); // no need to this here DateTime dEndTime = DateTime.Now; TimeSpan tsLoadAssessmentTime = dEndTime - dStartTime; if (bVerbose) DI.log.info("Loaded Assessment Xml File: {0} in {1}.{2} seconds", sFileLoaded, tsLoadAssessmentTime.Seconds.ToString(), tsLoadAssessmentTime.Milliseconds.ToString()); fixFilePaths(fadO2AssessmentDataOunceV6); return tsLoadAssessmentTime; } catch (Exception ex) { DI.log.error("in loadAssessmentFile({0}) : {1}", sXmlFileToLoad, ex.Message); return new TimeSpan(); } }
public static List <String> getListOfFindingsPerFile(String sAssessmentFileNameToProcess, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsFindings = new List <String>(); if (fadO2AssessmentDataOunceV6.dAssessmentFiles != null) { foreach (AssessmentAssessmentFile afAssessmentFile in fadO2AssessmentDataOunceV6.dAssessmentFiles.Keys) { if (afAssessmentFile.filename == sAssessmentFileNameToProcess) // we have found the assessment file, so add the filtered findings to the List { foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding) { lsFindings.Add(fFinding.caller_name ?? getStringIndexValue(UInt32.Parse(fFinding.caller_name_id), fadO2AssessmentDataOunceV6)); } return(lsFindings); } } } return(lsFindings); }
public static void mapSmartTraceCall_into_DataGridView(DataGridView dgvDataGridView, TraceType tTraceType, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { var lsSmartTraceCalls = new List<Int32>(); dgvDataGridView.Columns.Clear(); dgvDataGridView.Columns.Add("ID", tTraceType + " ID"); dgvDataGridView.Columns.Add("Signature", tTraceType + " Signature"); dgvDataGridView.Columns.Add("Number of Occurences", "Number of Occurences"); dgvDataGridView.Columns.Add("Number of Occurences ND", "Number of Occurences ND"); dgvDataGridView.Columns.Add("Number of Occurences IR", "Number of Occurences IR"); int iFindings = 0, iTracesFound = 0; 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) if (null != afAssessmentFile.Finding) foreach (AssessmentAssessmentFileFinding fFinding in afAssessmentFile.Finding) { iFindings++; if (fFinding.Trace != null) { iTracesFound++; int iSmartTraces = AnalysisSearch.findTraceTypeInSmartTrace_Recursive_returnSigId( fFinding.Trace, tTraceType); if (-1 != iSmartTraces && false == lsSmartTraceCalls.Contains(iSmartTraces)) lsSmartTraceCalls.Add(iSmartTraces); } } dgvDataGridView.DataSource = null; int iSmartTrace_Sum = 0, iNotDuplicated_Sum = 0, iIgnoreRoot_Sum = 0; /// need to figure out what are the cases when iSmartTraceIndex =0 foreach (int iSmartTraceIndex in lsSmartTraceCalls) if (iSmartTraceIndex > 0) { int iSmartTrace = 0, iNotDuplicated = 0, iIgnoreRoot = 0; calculateSmartTraceCallStatistics(fadO2AssessmentDataOunceV6.arAssessmentRun, (UInt32) iSmartTraceIndex, tTraceType, ref iSmartTrace, ref iNotDuplicated, ref iIgnoreRoot); iSmartTrace_Sum += iSmartTrace; iNotDuplicated_Sum += iNotDuplicated; iIgnoreRoot_Sum += iIgnoreRoot; dgvDataGridView.Rows.Add(new Object[] { iSmartTraceIndex, fadO2AssessmentDataOunceV6.arAssessmentRun.StringIndeces[ iSmartTraceIndex - 1].value, //iKey-1 because of the way StringIndeces is populated iSmartTrace, iNotDuplicated, iIgnoreRoot }); } else DI.log.error("_NOT RECOGNIZED STRING for ID ", iSmartTraceIndex.ToString()); // reset DataGridView Column width O2Forms.dataGridView_Utils_MaxColumnsWidth(dgvDataGridView); // all done DI.log.info( "Found {0} Unique SmartTraces of Type {1} (In {2} Findings (with {3} traces)). Totals: SmartTraces={4} , NonDuplicated={5} , IgnoreRoot = {6} ", lsSmartTraceCalls.Count.ToString(), tTraceType.ToString(), iFindings.ToString(), iTracesFound.ToString(), iSmartTrace_Sum.ToString(), iNotDuplicated_Sum.ToString(), iIgnoreRoot_Sum.ToString()); }
public static void saveFilteredAssessmentRun(AssessmentRun arFilteredAssessmentRun, String sTargetFileName, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { if (arFilteredAssessmentRun.Assessment.Assessment[0].AssessmentFile == null) DI.log.error( " .There were no AssessmentFiles (with Fidings) using the current filter, so no file will be created"); else { // add the stringIndeces and FileIndexes from the original file (ideally these should be filtered so that only the ones that are used are include arFilteredAssessmentRun.StringIndeces = fadO2AssessmentDataOunceV6.arAssessmentRun.StringIndeces; arFilteredAssessmentRun.FileIndeces = fadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces; // so that we can apply change back to the original project arFilteredAssessmentRun.Assessment.owner_name = fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.owner_name; arFilteredAssessmentRun.Assessment.owner_type = fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.owner_type; arFilteredAssessmentRun.Assessment.Assessment[0].owner_name = fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment[0].owner_name; arFilteredAssessmentRun.Assessment.Assessment[0].owner_type = fadO2AssessmentDataOunceV6.arAssessmentRun.Assessment.Assessment[0].owner_type; // and save the serialized object as an Xml file OzasmtUtils_OunceV6.createSerializedXmlFileFromAssessmentRunObject(arFilteredAssessmentRun, sTargetFileName); // and display a quick analysis outputQuickAnalysisOfAssessmentRunObject(arFilteredAssessmentRun); } }
public static String createAssessmentFileWithAllTraces(bool bDropDuplicateSmartTraces, bool bIgnoreRootCallInvocation, FindingNameFormat ffnFindingNameFormat, bool bChangeFindingData, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { string sTargetFilename = calculateTargetFileName("ALL_TRACES", ffnFindingNameFormat); return createAssessmentFileWithAllTraces(bDropDuplicateSmartTraces, bIgnoreRootCallInvocation, ffnFindingNameFormat, bChangeFindingData, fadO2AssessmentDataOunceV6, sTargetFilename); }
public static string getStringIndexValue(UInt32 uStringIndexId, O2AssessmentData_OunceV6 o2AssessmentDataOunceV6) { return(getStringIndexValue(uStringIndexId, o2AssessmentDataOunceV6.arAssessmentRun)); }
public static string getFileIndexValue(UInt32 uFileIndexId, O2AssessmentData_OunceV6 assessmentDataOunceV6) { return(getFileIndexValue(uFileIndexId, assessmentDataOunceV6.arAssessmentRun)); }
public static void addFindingAsGlueTrace(O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6WithTracesToGlue, AssessmentAssessmentFileFinding fFinding, O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6, TreeView tvRawData, bool bAddGluedTracesAsRealTraces) { String sUniqueSignature = analyzer.getUniqueSignature(fFinding, TraceType.Known_Sink, oadO2AssessmentDataOunceV6, true); var otbO2TraceBlockWithTracesToReceiveTraces = (O2TraceBlock_OunceV6) tvRawData.Nodes[sUniqueSignature].Tag; foreach (AssessmentAssessmentFileFinding fFindingToGlue in otbO2TraceBlockOunceV6WithTracesToGlue.dSinks.Keys) { if (false == otbO2TraceBlockWithTracesToReceiveTraces.dGluedSinks.ContainsKey(fFindingToGlue)) otbO2TraceBlockWithTracesToReceiveTraces.dGluedSinks.Add(fFindingToGlue, otbO2TraceBlockOunceV6WithTracesToGlue.dSinks[ fFindingToGlue]); if (bAddGluedTracesAsRealTraces) // so that the traces show in the Raw View list if (false == otbO2TraceBlockWithTracesToReceiveTraces.dSinks.ContainsKey(fFindingToGlue)) otbO2TraceBlockWithTracesToReceiveTraces.dSinks.Add(fFindingToGlue, otbO2TraceBlockOunceV6WithTracesToGlue.dSinks[ fFindingToGlue]); } }
public static String createAssessmentFileWithAllTraces(bool bDropDuplicateSmartTraces, bool bIgnoreRootCallInvocation, O2AssessmentData_OunceV6 o2AssessmentDataOunceV6, string sTargetFilename) { FindingNameFormat ffnFindingNameFormat = FindingNameFormat.FindingType; const bool bChangeFindingData = false; return createAssessmentFileWithAllTraces(bDropDuplicateSmartTraces, bIgnoreRootCallInvocation, ffnFindingNameFormat, bChangeFindingData, o2AssessmentDataOunceV6, sTargetFilename); }
public static String getSmartTraceNameOfTraceType(CallInvocation[] cCallInvocations, TraceType tTraceType, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { if (cCallInvocations != null) { int iActionObjectId = AnalysisSearch.findTraceTypeInSmartTrace_Recursive_returnSigId(cCallInvocations, tTraceType); if (iActionObjectId > 0) return fadO2AssessmentDataOunceV6.arAssessmentRun.StringIndeces[iActionObjectId - 1].value; } return ""; }
public void loadAssessmentFile(O2AssessmentData_OunceV6 _oadO2AssessmentData) { oadO2AssessmentData = _oadO2AssessmentData; lbLoadedAssessmentFile.Text = oadO2AssessmentData.ToString(); loadFileMappingsIntoListBoxes(); }
// this will make permanate changes to the supplied fadO2AssessmentData (which is why it is nulled at the end) public static void createAssessmentFileFromFindingsDictionary( Dictionary<AssessmentAssessmentFileFinding, AssessmentAssessmentFile> dFindings, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { throw new Exception("createAssessmentFileFromFindingsDictionary not implemented yet"); /* AssessmentRun arAssessmentRun = getDefaultAssessmentRunObject(); Assessment aAssessment = arAssessmentRun.Assessment.Assessment[0]; foreach (AssessmentAssessmentFileFinding fFinding in dFindings.Keys) { } fadO2AssessmentDataOunceV6 = null;*/ }
public static string getFileIndexValue(UInt32 uFileIndexId, O2AssessmentData_OunceV6 assessmentDataOunceV6) { return getFileIndexValue(uFileIndexId, assessmentDataOunceV6.arAssessmentRun); }
public static String getLineFromSourceCode(CallInvocation ciCallInvocation, O2AssessmentData_OunceV6 fadO2AssessmentDataOunceV6) { List<string> lsSourceCode = Files_WinForms.loadSourceFileIntoList( fadO2AssessmentDataOunceV6.arAssessmentRun.FileIndeces[ciCallInvocation.fn_id - 1].value); return Files.getLineFromSourceCode(ciCallInvocation.line_number, lsSourceCode); }
public static string getStringIndexValue(UInt32 uStringIndexId, O2AssessmentData_OunceV6 o2AssessmentDataOunceV6) { return getStringIndexValue(uStringIndexId, o2AssessmentDataOunceV6.arAssessmentRun); }
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; }