public static API_Veracode_DetailedXmlFindings loadFromXmlFile(this API_Veracode_DetailedXmlFindings apiVeracode, string xmlFile) { if (xmlFile.inValid()) { "[API_Veracode_DetailedXmlFindings] in loadFromXmlFile, there was no xmlFile provided".error(); return(apiVeracode); } apiVeracode.DetailedReport = detailedreport.Load(xmlFile); if (apiVeracode.DetailedReport.isNull()) { "[API_Veracode_DetailedXmlFindings] in loadFromXmlFile, failed to create serialized detailedreport from file: {0}".error(xmlFile); } else { apiVeracode.LocalFileMappingsCache.Clear(); "Loaded Ok file {0} which had {1} flaws".debug(xmlFile.fileName(), apiVeracode.flaws().size()); } return(apiVeracode); }
public static ctrl_TableList show_In_TableList(this List <FlawType> flaws, Control control) { control.clear(); var tableList = control.add_TableList(); Action showData = () => { var selectedRows = from flaw in flaws select new { flaw.severity, flaw.categoryname, flaw.issueid, flaw.module, flaw.type, flaw.description, flaw.cweid, flaw.exploitLevel, flaw.categoryid, flaw.sourcefile, flaw.line, flaw.sourcefilepath, flaw.scope, flaw.functionprototype, flaw.functionrelativelocation }; tableList.show(selectedRows); tableList.makeColumnWidthMatchCellWidth(); }; tableList.onDrop( (file) => { var apiVeracode = new API_Veracode_DetailedXmlFindings().load(file); flaws = apiVeracode.flaws(); showData(); }); if (flaws.size() > 0) { showData(); } else { tableList.add_Column("note") .add_Row("drop a Veracode DetailedFindings Xml (or zip) file to view it") .makeColumnWidthMatchCellWidth(); } return(tableList); }
public static API_Veracode_DetailedXmlFindings show_Flaws_In_SourceCodeViewer(this API_Veracode_DetailedXmlFindings apiVeracode, Control control) { var topPanel = control.clear(); var codeViewer = topPanel.add_GroupBox("Flaw SourceCode reference").add_SourceCodeViewer(); var treeView = codeViewer.parent().insert_Left("Flaws").add_TreeView(); var propertyGrid = treeView.insert_Below(150, "Flaw properties") .add_PropertyGrid().helpVisible(false); var description = codeViewer.insert_Below(150, "Flaw description") .add_TextArea(); treeView.afterSelect <FlawType>( (flaw) => { propertyGrid.show(flaw); if (apiVeracode.hasLocalSourceCodeFile(flaw)) { codeViewer.open(apiVeracode.sourceCodeFile(flaw)); codeViewer.editor().gotoLine((int)flaw.line); } else { codeViewer.set_Text(".. no source code available..."); } description.set_Text(flaw.description.fix_CRLF()); treeView.focus(); }); treeView.beforeExpand <List <FlawType> >( (flaws) => { var selectedNode = treeView.selected(); if (selectedNode.nodes().size() == 1) { selectedNode.clear(); selectedNode.add_Nodes(flaws, (flaw) => flaw.type, (flaw) => apiVeracode.hasLocalSourceCodeFile(flaw) ? Color.DarkGreen : Color.DarkRed ); } }); Action <TreeNode, Dictionary <string, List <FlawType> > > addFlawsToTreeNode = (treeNode, mappedFlaws) => { foreach (var item in mappedFlaws) { treeNode.add_Node(item.Key, item.Value, item.Value.size() > 0); } /*.*/ }; Action showData = () => { treeView.clear(); var o2Timer = new O2Timer("Building XRefs for flaws").start(); var mappedFlawsByType = new Dictionary <string, List <FlawType> >(); var mappedFlawsByCategoryName = new Dictionary <string, List <FlawType> >(); var mappedFlawsByFile = new Dictionary <string, List <FlawType> >(); var mappedFlawsBySeverity = new Dictionary <string, List <FlawType> >(); foreach (var flaw in apiVeracode.flaws()) { mappedFlawsByCategoryName.add(flaw.categoryname, flaw); mappedFlawsByType.add(flaw.type, flaw); mappedFlawsByFile.add(flaw.sourceCodeFile(), flaw); mappedFlawsBySeverity.add(flaw.severity.str(), flaw); } o2Timer.stop(); o2Timer = new O2Timer("Populating treeview").start(); addFlawsToTreeNode(treeView.add_Node("by Category Name"), mappedFlawsByCategoryName); addFlawsToTreeNode(treeView.add_Node("by Type"), mappedFlawsByType); addFlawsToTreeNode(treeView.add_Node("by File"), mappedFlawsByFile); addFlawsToTreeNode(treeView.add_Node("by Severity"), mappedFlawsBySeverity); o2Timer.stop(); }; treeView.onDrop( (file) => { apiVeracode.load(file); showData(); }); if (apiVeracode.ReportXmlFile.valid()) { showData(); } else { treeView.add_Node("drop a Veracode DetailedFindings Xml (or zip) file to view it"); } // "There were {0} Files That Could Not Mapped Locally".error(apiVeracode.FilesThatCouldNotMappedLocally.size()); /*if (treeView.nodes()>0)) * { * treeView.nodes()[0] * .expand().nodes()[2].selected(); * } */ return(apiVeracode); }
public static ctrl_TableList show_In_TableList(this API_Veracode_DetailedXmlFindings apiVeracode, Control control) { return(apiVeracode.flaws().show_In_TableList(control)); }
public static ctrl_TableList show_In_TableList(this List<FlawType> flaws , Control control) { control.clear(); var tableList = control.add_TableList(); Action showData = ()=>{ var selectedRows = from flaw in flaws select new {flaw.severity, flaw.categoryname, flaw.issueid, flaw.module, flaw.type, flaw.description, flaw.cweid, flaw.exploitLevel, flaw.categoryid, flaw.sourcefile, flaw.line, flaw.sourcefilepath, flaw.scope, flaw.functionprototype, flaw.functionrelativelocation}; tableList.show(selectedRows); tableList.makeColumnWidthMatchCellWidth(); }; tableList.onDrop( (file)=>{ var apiVeracode = new API_Veracode_DetailedXmlFindings().load(file); flaws = apiVeracode.flaws(); showData(); }); if (flaws.size()>0) showData(); else tableList.add_Column("note") .add_Row("drop a Veracode DetailedFindings Xml (or zip) file to view it") .makeColumnWidthMatchCellWidth(); return tableList; }