diff --git a/.classpath b/.classpath index 7822ac21..1e00c02d 100644 --- a/.classpath +++ b/.classpath @@ -2,7 +2,7 @@ - + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index a4764ea5..b65f67e4 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Bundle-Version: 1.0.0.qualifier Bundle-Vendor: Checkmarx Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.22.0", - org.eclipse.jdt.core;bundle-version="3.26.0" + org.eclipse.jdt.core;bundle-version="3.26.0", + org.eclipse.ui.ide;bundle-version="3.18.300" Automatic-Module-Name: com.checkmarx.eclipse Bundle-RequiredExecutionEnvironment: JavaSE-11 Import-Package: org.eclipse.core.resources @@ -20,5 +21,5 @@ Bundle-ClassPath: lib/lombok-1.18.20.jar, lib/jackson-core-2.12.4.jar, lib/jackson-databind-2.12.4.jar, lib/commons-lang3-3.12.0.jar, - lib/ast-cli-java-wrapper-1.0.12.jar, + lib/ast-cli-java-wrapper-1.0.18.jar, . diff --git a/build.properties b/build.properties index 45819a26..f60b2af2 100644 --- a/build.properties +++ b/build.properties @@ -10,6 +10,6 @@ bin.includes = plugin.xml,\ lib/jackson-core-2.12.4.jar,\ lib/jackson-databind-2.12.4.jar,\ lib/commons-lang3-3.12.0.jar,\ - lib/ast-cli-java-wrapper-1.0.12.jar,\ + lib/ast-cli-java-wrapper-1.0.18.jar,\ . source.. = src/ diff --git a/lib/ast-cli-java-wrapper-1.0.12.jar b/lib/ast-cli-java-wrapper-1.0.18.jar similarity index 60% rename from lib/ast-cli-java-wrapper-1.0.12.jar rename to lib/ast-cli-java-wrapper-1.0.18.jar index 6788a86e..351196ba 100644 Binary files a/lib/ast-cli-java-wrapper-1.0.12.jar and b/lib/ast-cli-java-wrapper-1.0.18.jar differ diff --git a/src/com/checkmarx/eclipse/properties/AuthButtonFieldEditor.java b/src/com/checkmarx/eclipse/properties/AuthButtonFieldEditor.java index 1ca88aba..33dbec8a 100644 --- a/src/com/checkmarx/eclipse/properties/AuthButtonFieldEditor.java +++ b/src/com/checkmarx/eclipse/properties/AuthButtonFieldEditor.java @@ -18,8 +18,8 @@ protected AuthButtonFieldEditor(String name, String labelText, @Override protected String changePressed() { - Integer result = Authenticator.INSTANCE.doAuthentication(); - if(result == 0) + String result = Authenticator.INSTANCE.doAuthentication(); + if(!result.isEmpty()) { MessageDialog.openInformation(null, "Authentication", "Connection successfull !"); } diff --git a/src/com/checkmarx/eclipse/runner/Authenticator.java b/src/com/checkmarx/eclipse/runner/Authenticator.java index ef9d741c..ad6232bd 100644 --- a/src/com/checkmarx/eclipse/runner/Authenticator.java +++ b/src/com/checkmarx/eclipse/runner/Authenticator.java @@ -6,9 +6,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.checkmarx.ast.exceptions.CxException; -import com.checkmarx.ast.scans.CxAuth; -import com.checkmarx.ast.scans.CxScanConfig; +import com.checkmarx.ast.wrapper.CxConfig; +import com.checkmarx.ast.wrapper.CxConfig.InvalidCLIConfigException; +import com.checkmarx.ast.wrapper.CxException; +import com.checkmarx.ast.wrapper.CxWrapper; import com.checkmarx.eclipse.properties.Preferences; public class Authenticator { @@ -33,32 +34,33 @@ public class Authenticator { // // } - public Integer doAuthentication() { + public String doAuthentication() { - CxScanConfig config = new CxScanConfig(); + CxConfig config = CxConfig.builder().baseUri(Preferences.getServerUrl()).tenant(Preferences.getTenant()).apiKey(Preferences.getApiKey()).additionalParameters("").build(); - config.setBaseUri(Preferences.getServerUrl()); - config.setTenant(Preferences.getTenant()); - config.setApiKey(Preferences.getApiKey()); +// config.setBaseUri(Preferences.getServerUrl()); +// config.setTenant(Preferences.getTenant()); +// config.setApiKey(Preferences.getApiKey()); Logger log = LoggerFactory.getLogger(Authenticator.class.getName()); - CxAuth cxAuth; + CxWrapper wrapper; try { - cxAuth = new CxAuth(config, log); - Integer result = cxAuth.cxAuthValidate(); - System.out.println("Authentication Status :" + result); - return result; - } catch (CxException e) { + wrapper = new CxWrapper(config, log); + String cxValidateOutput = wrapper.authValidate(); + // Integer result = cxValidateOutput.getExitCode(); + System.out.println("Authentication Status :" + cxValidateOutput); + return cxValidateOutput; + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (IOException e) { + } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (URISyntaxException e) { + } catch (InvalidCLIConfigException e) { // TODO Auto-generated catch block e.printStackTrace(); - } catch (InterruptedException e) { + } catch (CxException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/com/checkmarx/eclipse/utils/PluginConstants.java b/src/com/checkmarx/eclipse/utils/PluginConstants.java new file mode 100644 index 00000000..ef3fb78d --- /dev/null +++ b/src/com/checkmarx/eclipse/utils/PluginConstants.java @@ -0,0 +1,7 @@ +package com.checkmarx.eclipse.utils; + +public class PluginConstants { + public static final String SAST = "sast"; + public static final String SCA_DEPENDENCY = "dependency"; + public static final String KICS_INFRASTRUCTURE = "infrastructure"; +} diff --git a/src/com/checkmarx/eclipse/views/CheckmarxView.java b/src/com/checkmarx/eclipse/views/CheckmarxView.java index 933ddbfb..44bdf7d3 100644 --- a/src/com/checkmarx/eclipse/views/CheckmarxView.java +++ b/src/com/checkmarx/eclipse/views/CheckmarxView.java @@ -1,216 +1,272 @@ package com.checkmarx.eclipse.views; -import java.io.IOException; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceProxy; +import org.eclipse.core.resources.IResourceProxyVisitor; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.ViewPart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.checkmarx.ast.exceptions.CxException; -import com.checkmarx.ast.results.structure.CxResult; -import com.checkmarx.ast.results.structure.CxResultOutput; -import com.checkmarx.ast.scans.CxAuth; -import com.checkmarx.ast.scans.CxScanConfig; + +import com.checkmarx.ast.results.result.Node; +import com.checkmarx.ast.results.result.PackageData; import com.checkmarx.eclipse.Activator; -import com.checkmarx.eclipse.properties.Preferences; -import com.checkmarx.eclipse.runner.Authenticator; +import com.checkmarx.eclipse.utils.PluginConstants; import com.checkmarx.eclipse.views.provider.ColumnProvider; -import com.checkmarx.eclipse.views.provider.ColumnTextProvider; import com.checkmarx.eclipse.views.provider.TreeContentProvider; public class CheckmarxView extends ViewPart { - - /** * The ID of the view as specified by the extension. */ public static final String ID = "com.checkmarx.eclipse.views.CheckmarxView"; - - public static final Image CRITICAL_SEVERITY = - Activator.getImageDescriptor("/icons/severity-critical.png").createImage(); - - public static final Image HIGH_SEVERITY = - Activator.getImageDescriptor("/icons/severity-high.png").createImage(); - - public static final Image MEDIUM_SEVERITY = - Activator.getImageDescriptor("/icons/severity-medium.png").createImage(); - - public static final Image LOW_SEVERITY = - Activator.getImageDescriptor("/icons/severity-low.png").createImage(); + public static final Image CRITICAL_SEVERITY = Activator.getImageDescriptor("/icons/severity-critical.png") + .createImage(); + + public static final Image HIGH_SEVERITY = Activator.getImageDescriptor("/icons/severity-high.png").createImage(); + + public static final Image MEDIUM_SEVERITY = Activator.getImageDescriptor("/icons/severity-medium.png") + .createImage(); + + public static final Image LOW_SEVERITY = Activator.getImageDescriptor("/icons/severity-low.png").createImage(); + +// public static final Image SAST_ICON = +// Activator.getImageDescriptor("platform:/plugin/org.eclipse.ui.views/icons/full/dlcl16/new.png").createImage(); +// +// public static final Image SCA_ICON = +// Activator.getImageDescriptor("platform:/plugin/org.eclipse.ui.views/icons/full/dlcl16/new.png").createImage(); +// +// public static final Image KICS_ICON = +// Activator.getImageDescriptor("platform:/plugin/org.eclipse.ui.views/icons/full/dlcl16/tree_mode.png").createImage(); - IWorkbench workbench; - private ListViewer listViewer; + private TreeViewer viewer; - private Action getResults, openPrefPage, abortGettingResults; + private StringFieldEditor scanIdField; + private Action getScanResultsAction, openPrefPageAction, abortGetResultsAction; private DisplayModel rootModel; private Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - - private static final String RUNNING = "Scanning your project..."; - private static final String ABORTING = "abort scanning..."; - - private List monitorActions = new ArrayList<>(); - + + private static final String RUNNING = "Retriving the results for the scan id: %s ."; + private static final String ABORTING = "Aborting the retrieval of results..."; + + private boolean alreadyRunning = false; - + private IPropertyChangeListener stringChangeListener; - private CxAuth cxAuth; + // private CxAuth cxAuth; + + Font boldFont; + private Text typeValueText; + private Text severityValueText; + private Text statusValueText; + private Text descriptionValueText; + private Text attackVectorValueLinkText; + + private Composite attackVectorCompositePanel; + +// private List resultList; +// private CxResultOutput resultCommandOutput; - private List resultList; - private CxResultOutput resultCommandOutput; - - public CheckmarxView() { super(); - // getResultsForScanId(); - + rootModel = new DisplayModel(); + DisplayModel init = new DisplayModel(); + init.name = "Paste a scanId and hit play to fetch the results."; + rootModel.children.add(init); + +// stringChangeListener = new IPropertyChangeListener() { +// public void propertyChange(PropertyChangeEvent event) { +// System.out.println(scanIdField.getStringValue()); +// } +// }; +// } - + + @Override + public void dispose() { + super.dispose(); + boldFont.dispose(); + } + @Override public void createPartControl(Composite parent) { createViewer(parent); -// -// getSite().setSelectionProvider(viewer); - -// hookContextMenu(); -// - + createActions(); + createToolbar(); + createContextMenu(); - // Create menu and toolbars. - createActions(); - contributeToActionBars(); -// createMenu(); -// createToolbar(); - // createContextMenu(); -// hookGlobalActions(); - - // Restore state from the previous session. - // restoreState(); - } + private void createContextMenu() { + MenuManager menuManager = new MenuManager("#PopupMenu"); + menuManager.setRemoveAllWhenShown(true); + menuManager.addMenuListener(CheckmarxView.this::fillContextMenu); + Menu menu = menuManager.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(menuManager, viewer); + } - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - fillLocalToolBar(bars.getToolBarManager()); - + private void fillContextMenu(IMenuManager manager) { +// ITreeSelection selection = viewer.getStructuredSelection(); +// DisplayModel selected = (DisplayModel)selection.getFirstElement(); + manager.add(openPrefPageAction); } - private void fillLocalToolBar(IToolBarManager toolBarManager) { - toolBarManager.add(getResults); - + private void createToolbar() { + IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); + toolBarManager.add(getScanResultsAction); + toolBarManager.add(abortGetResultsAction); } private void createActions() { - getResults = new Action() { + getScanResultsAction = new Action() { @Override public void run() { - - CompletableFuture.runAsync(()-> { - getResultsForScanId(); - // rootModel.children.clear(); + if (alreadyRunning) + return; + String scanId = scanIdField.getStringValue(); + if (!validateScanIdFormat(scanId)) { + showMessage("Incorrect scanId format."); + return; + } + showMessage(String.format(RUNNING, scanId)); + + getScanResultsAction.setEnabled(false); + abortGetResultsAction.setEnabled(true); + + CompletableFuture.runAsync(() -> { + alreadyRunning = true; + List scanResults = DataProvider.INSTANCE.getResultsForScanId(scanId); + // List scanResults = + // DataProvider.INSTANCE.processResultsV2(resultCommandOutput, scanId); + rootModel.children.clear(); + rootModel.children.addAll(scanResults); viewer.getTree().getDisplay().asyncExec(() -> viewer.refresh()); + getScanResultsAction.setEnabled(true); + alreadyRunning = false; }); - + } }; - - getResults.setText("Scan Results"); - getResults.setToolTipText("Get Results for the scan id."); - getResults.setImageDescriptor( + + getScanResultsAction.setText("Scan Results"); + getScanResultsAction.setToolTipText("Get results for the scan id."); + getScanResultsAction.setImageDescriptor( Activator.getImageDescriptor("platform:/plugin/org.eclipse.ui.browser/icons/clcl16/nav_go.png")); - - openPrefPage = new Action() { - + + openPrefPageAction = new Action() { + @Override public void run() { - PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( - shell, "com.checkmarx.eclipse.properties.preferencespage", - null, null); - if (pref != null) pref.open(); + PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(shell, + "com.checkmarx.eclipse.properties.preferencespage", null, null); + if (pref != null) + pref.open(); } }; - - openPrefPage.setText("Preferences"); - + + openPrefPageAction.setText("Preferences"); + + abortGetResultsAction = new Action() { + @Override + public void run() { + showMessage(ABORTING); + DataProvider.abort.set(true); + abortGetResultsAction.setEnabled(false); + } + }; + abortGetResultsAction.setImageDescriptor( + Activator.getImageDescriptor("platform:/plugin/org.eclipse.ui.browser/icons/clcl16/nav_stop.png")); + abortGetResultsAction.setEnabled(false); + + } + + private boolean validateScanIdFormat(String scanId) { + + if (scanId.matches("[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[0-9a-f]{12}")) { + return true; + } + return false; } @Override public void setFocus() { - + viewer.getControl().setFocus(); } - + private void createViewer(Composite parent) { - - // parent.setLayout(new FillLayout(SWT.HORIZONTAL)); - - StringFieldEditor scanIdField = new StringFieldEditor("scanId", "Scan Id:", parent); - // scanIdField.setPropertyChangeListener(stringChangeListener); - - -// stringChangeListener = new IPropertyChangeListener() { -// public void propertyChange(PropertyChangeEvent event) { -// // if (event.getProperty().equals()) -// // getResultsForScanId(); -// } -// }; - - - getResultsForScanId(); - - - viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); + // define a new composite for ScanID Field and ScanResults Tree + Composite leftCompositePanel = new Composite(parent, SWT.BORDER); + + scanIdField = new StringFieldEditor("scanId", "Scan Id:", 36, leftCompositePanel); + scanIdField.setTextLimit(36); + scanIdField.setEmptyStringAllowed(false); + + scanIdField.getTextControl(leftCompositePanel).addListener(SWT.DefaultSelection, new Listener() { + public void handleEvent(Event event) { + getScanResultsAction.run(); + } + }); + + viewer = new TreeViewer(leftCompositePanel, + SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); ColumnViewerToolTipSupport.enableFor(viewer); createColumns(); - + viewer.getTree().setHeaderVisible(true); viewer.getTree().setLinesVisible(true); - + viewer.setContentProvider(new TreeContentProvider()); - //viewer.setLabelProvider(); + // viewer.setLabelProvider(); getSite().setSelectionProvider(viewer); // define layout for the viewer @@ -221,27 +277,348 @@ private void createViewer(Composite parent) { gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; viewer.getControl().setLayoutData(gridData); - - rootModel = DataProvider.INSTANCE.processResults(resultCommandOutput); viewer.setInput(rootModel); + + // configureSelectionListener + configureTreeItemSelectionChangeEvent(viewer); + + // Original working code above + // SECTION 2 + + // Setting the BOLD Font for Labels + Display display = parent.getShell().getDisplay(); + FontData systemFontData = display.getSystemFont().getFontData()[0]; + boldFont = new Font(display, systemFontData.getName(), systemFontData.getHeight(), SWT.BOLD); + + Composite resultInfoCompositePanel = new Composite(parent, SWT.BORDER); + resultInfoCompositePanel.setLayout(new FillLayout(SWT.VERTICAL)); + + Label typeLabel = new Label(resultInfoCompositePanel, SWT.NONE); + typeLabel.setFont(boldFont); + typeLabel.setText("Type:"); + + typeValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); + typeValueText.setText("Not Available."); + + Label severityLabel = new Label(resultInfoCompositePanel, SWT.NONE); + severityLabel.setFont(boldFont); + severityLabel.setText("Severity:"); + + severityValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); + severityValueText.setText("Not Available."); + + Label statusLabel = new Label(resultInfoCompositePanel, SWT.NONE); + statusLabel.setFont(boldFont); + statusLabel.setText("Status:"); + + statusValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); + statusValueText.setText("Not Available."); + + Label descriptionLabel = new Label(resultInfoCompositePanel, SWT.NONE); + descriptionLabel.setFont(boldFont); + descriptionLabel.setText("Description:"); + + descriptionValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); + descriptionValueText.setText("Not Available."); + + // Section 3 + attackVectorCompositePanel = new Composite(parent, SWT.BORDER); + attackVectorCompositePanel.setLayout(new RowLayout(SWT.VERTICAL)); + + Label attackVectorLabel = new Label(attackVectorCompositePanel, SWT.NONE); + attackVectorLabel.setFont(boldFont); + attackVectorLabel.setText("Attack Vector:"); + + } + + private void configureTreeItemSelectionChangeEvent(TreeViewer viewer) { + + viewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @Override + public void selectionChanged(SelectionChangedEvent event) { + // if the selection is empty clear the label + if (event.getSelection().isEmpty()) { + return; + } + if (event.getSelection() instanceof IStructuredSelection) { + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + DisplayModel selectedItem = (DisplayModel) selection.getFirstElement(); + + // added this line to generate the view dynamically + // createDetailsSection(viewer); + + if (selectedItem.getType() != null) { + typeValueText.setText((selectedItem.getType()).toUpperCase()); + } + + if (selectedItem.getSeverity() != null) { + severityValueText.setText(selectedItem.getSeverity()); + } + + if(selectedItem.getResult()!= null) + { + if (selectedItem.getResult().getStatus() != null) { + statusValueText.setText(selectedItem.getResult().getStatus()); + } + + if (selectedItem.getResult().getData().getDescription() != null) { + descriptionValueText.setText(selectedItem.getResult().getData().getDescription()); + } else { + descriptionValueText.setText("Not Available."); + } + + } + + + if(selectedItem.getType()!=null) + { + updateAttackVectorForSelectedTreeItem(selectedItem); + } + + // Delete the following commented code later +// StringBuffer toShow = new StringBuffer(); +// for (Iterator iterator = selection.iterator(); iterator.hasNext();) { +// Object domain = (Model) iterator.next(); +// String value = labelProvider.getText(domain); +// toShow.append(value); +// toShow.append(", "); +// } +// // remove the trailing comma space pair +// if(toShow.length() > 0) { +// toShow.setLength(toShow.length() - 2); +// } +// text.setText(toShow.toString()); + } + } + }); + + } + + +// private void createDetailsSection(TreeViewer treeViewer) +// { +// Composite parent = treeViewer.getControl().getParent(); +// +// Display display = parent.getShell().getDisplay(); +// FontData systemFontData = display.getSystemFont().getFontData()[0]; +// Font boldFont = new Font(display, systemFontData.getName(), +// systemFontData.getHeight(), SWT.BOLD); +// +// +// Composite resultInfoCompositePanel = new Composite(parent, SWT.BORDER); +// resultInfoCompositePanel.setLayout(new RowLayout(SWT.VERTICAL)); +// +// +// Text typeText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// typeText.setFont(boldFont); +// typeText.setText("Type:"); +// +// typeValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// // typeValueText.setText("Not Available."); +// +// Text severity = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// severity.setFont(boldFont); +// severity.setText("Severity:"); +// +// severityValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// // severityValueText.setText("Not Available."); +// +// Text status = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// status.setFont(boldFont); +// status.setText("Status:"); +// +// statusValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// // statusValueText.setText("Not Available."); +// +// Text description = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// description.setFont(boldFont); +// description.setText("Description:"); +// +// descriptionValueText = new Text(resultInfoCompositePanel, SWT.READ_ONLY); +// // descriptionValueText.setText("Not Available."); +// +// +// //Section 3 +// attackVectorCompositePanel = new Composite(parent, SWT.BORDER); +// attackVectorCompositePanel.setLayout(new RowLayout(SWT.VERTICAL)); +// +// Text attackVector = new Text(attackVectorCompositePanel, SWT.READ_ONLY); +// attackVector.setFont(boldFont); +// attackVector.setText("Attack Vector:"); +// +// parent.layout(); +// +// +// } + + private void updateAttackVectorForSelectedTreeItem(DisplayModel selectedItem) { + + clearAttackVectorSection(attackVectorCompositePanel); + + if (selectedItem.getType().equalsIgnoreCase(PluginConstants.SCA_DEPENDENCY)) { + + List packageDataList = selectedItem.getResult().getData().getPackageData(); + + if (packageDataList!= null && !packageDataList.isEmpty()) { + + for(PackageData packageDataItem : packageDataList) + { + Text packageDataTypeLabel = new Text(attackVectorCompositePanel, SWT.READ_ONLY); + packageDataTypeLabel.setFont(boldFont); + packageDataTypeLabel.setText(packageDataItem.getType()); + + Link packageDataLink = new Link(attackVectorCompositePanel, SWT.NONE); + packageDataLink.setText("" + packageDataItem.getUrl() + ""); + + + } + + attackVectorCompositePanel.layout(); + + } else { + if (attackVectorValueLinkText != null) { + attackVectorValueLinkText.setText("Not Available."); + } + } + + } + if (selectedItem.getType().equalsIgnoreCase(PluginConstants.KICS_INFRASTRUCTURE)) { + + } + + if (selectedItem.getType().equalsIgnoreCase(PluginConstants.SAST)) { + + String queryName = selectedItem.getResult().getData().getQueryName(); + String groupName = selectedItem.getResult().getData().getGroup(); + + List nodesList = selectedItem.getResult().getData().getNodes(); + if (nodesList != null && nodesList.size() > 0) { + + + for (Node node : nodesList) { + + String nodeName = node.getName(); + String markerDescription = groupName+"_"+queryName+"_"+ nodeName; + + // attackVectorValueText = new Text(attackVectorCompositePanel, SWT.READ_ONLY); + // attackVectorValueText.setText(node.getFileName() + "[" + node.getLine() + "," + // + node.getColumn() + "]"); + + Link attackVectorValueLinkText = new Link(attackVectorCompositePanel, SWT.NONE); + String text = "" + node.getFileName() + "[" + node.getLine() + "," + node.getColumn() + "]" + + ""; + attackVectorValueLinkText.setText(text); + attackVectorValueLinkText.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + openTheSelectedFile(node.getFileName(), node.getLine(), markerDescription); + } + }); + + attackVectorCompositePanel.layout(); + + } + } else { + if (attackVectorValueLinkText != null) { + attackVectorValueLinkText.setText("Not Available."); + } + + } + } + + } + + private void clearAttackVectorSection(Composite attackVectorCompositePanel) { + + for (Control child : attackVectorCompositePanel.getChildren()) { + + if(!(child instanceof Label)) + child.dispose(); + } } + private void openTheSelectedFile(String fileName, Integer lineNumber, String markerDescription) { + + Path filePath = new Path(fileName); + List filesFound = findFileInWorkspace(filePath.lastSegment()); + + for (IFile file : filesFound) { + Path fullPath = (Path) file.getFullPath(); + Path absolutePathOfFoundFile = (Path) fullPath.removeFirstSegments(1).makeAbsolute(); + + if (absolutePathOfFoundFile.equals(filePath)) { + try { + IMarker fileMarker = file.createMarker(IMarker.TEXT); + fileMarker.setAttribute(IMarker.LINE_NUMBER, lineNumber); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + // IDE.openEditor(marker); //3.0 API + IDE.openEditor(page, fileMarker); + // marker.delete(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + } + + } + +// private void createFileMarkers(IFile file, Integer lineNumber, String markerDescription) { +// +// try { +// fileMarker = file.createMarker(IMarker.PROBLEM); +// fileMarker.setAttribute(IMarker.LINE_NUMBER, lineNumber); +// fileMarker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING); +// fileMarker.setAttribute(IMarker.MESSAGE, markerDescription); +// } catch (CoreException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// // return fileMarker; +// +// } + + private List findFileInWorkspace(final String fileName) { + final List foundFiles = new ArrayList(); + try { + // visiting only resources proxy because we obtain the resource only when + // matching name, thus the workspace traversal is much faster + ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceProxyVisitor() { + @Override + public boolean visit(IResourceProxy resourceProxy) throws CoreException { + if (resourceProxy.getType() == IResource.FILE) { + String resourceName = resourceProxy.getName(); + if (resourceName.equals(fileName)) { + IFile foundFile = (IFile) resourceProxy.requestResource(); + foundFiles.add(foundFile); + } + } + return true; + } + }, IResource.NONE); + } catch (Exception e) { +// CxLogger.getLogger().error("Error occured while searching for file name in project",e); + e.printStackTrace(); + } + return foundFiles; + } + private void createColumns() { TreeViewerColumn col = createTreeViewerColumn("Title", 400); - ColumnProvider label = new ColumnProvider(this::findSeverityImage ,model -> model.name); + ColumnProvider label = new ColumnProvider(this::findSeverityImage, model -> model.name); col.setLabelProvider((label)); - col = createTreeViewerColumn("State", 400); - col.setLabelProvider(new ColumnTextProvider(model -> model.state)); - - col = createTreeViewerColumn("Status", 400); - col.setLabelProvider(new ColumnTextProvider(model -> model.status)); +// col = createTreeViewerColumn("State", 400); +// col.setLabelProvider(new ColumnTextProvider(model -> model.state)); +// +// col = createTreeViewerColumn("Status", 400); +// col.setLabelProvider(new ColumnTextProvider(model -> model.status)); // // col = createTreeViewerColumn("Fix", 400); // col.setLabelProvider(new ColumnTextProvider(model -> model.fix)); } - + private TreeViewerColumn createTreeViewerColumn(String title, int bound) { final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE); final TreeColumn column = viewerColumn.getColumn(); @@ -251,45 +628,60 @@ private TreeViewerColumn createTreeViewerColumn(String title, int bound) { column.setMoveable(true); return viewerColumn; } - + private Image findSeverityImage(DisplayModel model) { String severity = model.severity; - if (severity == null) return null; + if (severity == null) + return null; + + if (severity.equalsIgnoreCase("critical")) + return CRITICAL_SEVERITY; + if (severity.equalsIgnoreCase("high")) + return HIGH_SEVERITY; + if (severity.equalsIgnoreCase("medium")) + return MEDIUM_SEVERITY; + if (severity.equalsIgnoreCase("low")) + return LOW_SEVERITY; + +// if (model.getType().equalsIgnoreCase("sast")) return SAST_ICON; +// if (model.getType().equalsIgnoreCase("infrastructure")) return KICS_ICON; +// if (model.getType().equalsIgnoreCase("kics")) return KICS_ICON; - if (severity.equalsIgnoreCase("critical")) return CRITICAL_SEVERITY; - if (severity.equalsIgnoreCase("high")) return HIGH_SEVERITY; - if (severity.equalsIgnoreCase("medium")) return MEDIUM_SEVERITY; - if (severity.equalsIgnoreCase("low")) return LOW_SEVERITY; - return null; } - - public void getResultsForScanId() { - - - CxScanConfig config = new CxScanConfig(); - config.setBaseUri(Preferences.getServerUrl()); - config.setTenant(Preferences.getTenant()); - config.setApiKey(Preferences.getApiKey()); - - Logger log = LoggerFactory.getLogger(Authenticator.class.getName()); - - try { - cxAuth = new CxAuth(config, log); - Integer result = cxAuth.cxAuthValidate(); - System.out.println("Authentication Status :" + result); - resultCommandOutput = cxAuth.cxGetResults("e3c7a6d6-98fd-4513-84e0-2dc86a61b2a9"); //adfa3bb4-754d-4444-b8ca-67edbe767186 for sca kics and sast - System.out.println("Result :" + resultCommandOutput.getTotalCount()); - resultList = resultCommandOutput.getResults(); - - - } catch (IOException | CxException | URISyntaxException | InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - +// public void getResultsForScanId(String scanId) { +// +// CxScanConfig config = new CxScanConfig(); +// +// config.setBaseUri(Preferences.getServerUrl()); +// config.setTenant(Preferences.getTenant()); +// config.setApiKey(Preferences.getApiKey()); +// +// Logger log = LoggerFactory.getLogger(Authenticator.class.getName()); +// +// try { +// cxAuth = new CxAuth(config, log); +// Integer result = cxAuth.cxAuthValidate(); +// System.out.println("Authentication Status :" + result); +// System.out.println("Fetching the results for scanId :" + scanId); +// resultCommandOutput = cxAuth.cxGetResults(scanId); //adfa3bb4-754d-4444-b8ca-67edbe767186 for sca kics and sast +// System.out.println("Result :" + resultCommandOutput.getTotalCount()); +// resultList = resultCommandOutput.getResults(); +// +// +// } catch (IOException | CxException | URISyntaxException | InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } + + public void showMessage(String message) { + rootModel.children.clear(); + rootModel.children.add(DataProvider.INSTANCE.message(message)); + viewer.refresh(); + // monitorActions.forEach(act -> act.setEnabled(true)); } - - + } diff --git a/src/com/checkmarx/eclipse/views/DataProvider.java b/src/com/checkmarx/eclipse/views/DataProvider.java index f469cff0..88d26806 100644 --- a/src/com/checkmarx/eclipse/views/DataProvider.java +++ b/src/com/checkmarx/eclipse/views/DataProvider.java @@ -1,141 +1,308 @@ package com.checkmarx.eclipse.views; +import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; +import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import com.checkmarx.ast.results.structure.CxResult; -import com.checkmarx.ast.results.structure.CxResultOutput; +import com.checkmarx.ast.results.Results; +import com.checkmarx.ast.results.result.Result; +import com.checkmarx.ast.wrapper.CxConfig; +import com.checkmarx.ast.wrapper.CxWrapper; +import com.checkmarx.ast.wrapper.Execution; +import com.checkmarx.eclipse.properties.Preferences; +import com.checkmarx.eclipse.runner.Authenticator; +import com.checkmarx.eclipse.utils.PluginConstants; public class DataProvider { - + private static final Bundle BUNDLE = FrameworkUtil.getBundle(DataProvider.class); private static final ILog LOG = Platform.getLog(BUNDLE); - public static final DataProvider INSTANCE = new DataProvider(); + public static final DataProvider INSTANCE = new DataProvider(); + + public static final AtomicBoolean abort = new AtomicBoolean(false); + + private List scanTypes = new ArrayList(); + private List severityTypes = new ArrayList(); + + private Integer sastCount = 0; + private Integer scaCount = 0; + private Integer kicsCount = 0; + public DisplayModel message(String message) { + DisplayModel messageModel = new DisplayModel(); + messageModel.name = message; + return messageModel; + } - public DisplayModel processResults(CxResultOutput resultsCommandOutput){ - + public List error(Exception e) { + e.printStackTrace(); + List result = new ArrayList<>(); + result.add(message("Error: " + e.getMessage())); + return result; + } + + public List abortResult() { + List result = new ArrayList<>(); + result.add(message("Scan results call aborted.")); + return result; + } + + public List getResultsForScanId(String scanId) { + + abort.set(false); + Results scanResults = null; + + Logger log = LoggerFactory.getLogger(Authenticator.class.getName()); + + try { + CxConfig config = CxConfig.builder().baseUri(Preferences.getServerUrl()).tenant(Preferences.getTenant()) + .apiKey(Preferences.getApiKey()).additionalParameters("").build(); + + CxWrapper wrapper = new CxWrapper(config, log); + String validationResult = wrapper.authValidate(); + + + System.out.println("Authentication Status :" + validationResult); + System.out.println("Fetching the results for scanId :" + scanId); + + scanResults = wrapper.results(UUID.fromString(scanId)); + System.out.println("Scan results :" + scanResults.getTotalCount()); + + } catch (Exception e) { + return error(e); + } + + return processResults(scanResults, scanId); + } + + private List processResults(Results scanResults, String scanId) { + DisplayModel projectModel; - List allResults = resultsCommandOutput.getResults(); - - List sastResults = new ArrayList<>(); - List scaResults = new ArrayList<>(); - List kicsResults = new ArrayList<>(); - - //filtering by each scanner type - sastResults.addAll(filterResultsByScannerType(allResults, "sast")); - scaResults.addAll(filterResultsByScannerType(allResults, "sca")); - kicsResults.addAll(filterResultsByScannerType(allResults, "infrastructure")); - - //filtering by each severity type - Map> sastMap = new HashMap<>(); - sastMap.put("LOW", filterResultsBySeverity(sastResults, "LOW")); - sastMap.put("MEDIUM", filterResultsBySeverity(sastResults, "MEDIUM")); - sastMap.put("HIGH", filterResultsBySeverity(sastResults, "HIGH")); + List resultsList = scanResults.getResults(); + + // transform all the results at once to avoid multiple transformation steps + List allResultsTransformed = resultsList.stream().map(resultItem -> transform(resultItem)) + .collect(Collectors.toList()); + // Divide all the results as per the scanner type + Map> filteredResultsByScannerType = filterResultsByScannerTypeV2( + allResultsTransformed); + + // Divide the results for each scanner as per the severity + Map> sastResultsMap = new HashMap<>(); + Map> scaResultsMap = new HashMap<>(); + Map> kicsResultsMap = new HashMap<>(); + + if (filteredResultsByScannerType.containsKey(PluginConstants.SAST)) { + List sastList = filteredResultsByScannerType.get(PluginConstants.SAST); + sastResultsMap = filterResultsBySeverityV2(sastList); + } + if (filteredResultsByScannerType.containsKey(PluginConstants.SCA_DEPENDENCY)) { + List scaList = filteredResultsByScannerType.get(PluginConstants.SCA_DEPENDENCY); + scaResultsMap = filterResultsBySeverityV2(scaList); + } + if (filteredResultsByScannerType.containsKey(PluginConstants.KICS_INFRASTRUCTURE)) { + List kicsList = filteredResultsByScannerType.get(PluginConstants.KICS_INFRASTRUCTURE); + kicsResultsMap = filterResultsBySeverityV2(kicsList); + } + + // Creating a parent node for each scanner + // SAST + sastCount = 0; List sastParentModelList = new ArrayList(); - - for (Map.Entry mapEntry : sastMap.entrySet()) { - - List resultList = (List) mapEntry.getValue(); - - List sastChildModelList = resultList.stream() - .map(resultItem -> transform(resultItem)).collect(Collectors.toList()); - - if(sastChildModelList.size() > 0) - { - new DisplayModel(); - DisplayModel sastModel = DisplayModel.builder().name((String) mapEntry.getKey()).children(sastChildModelList).build(); - sastParentModelList.add(sastModel); - } - - } - - - -// List sastResultsModel = sastResults.stream() -// .map(resultItem -> transform(resultItem)).collect(Collectors.toList()); - List scaResultsModel = scaResults.stream() - .map(resultItem -> transform(resultItem)).collect(Collectors.toList()); - List kicsResultsModel = kicsResults.stream() - .map(resultItem -> transform(resultItem)).collect(Collectors.toList()); - - List results = new ArrayList<>(); - if(sastParentModelList.size()>0) - { + for (Map.Entry> mapEntry : sastResultsMap.entrySet()) { + + List listForEachSeverity = mapEntry.getValue(); + sastCount = sastCount + listForEachSeverity.size(); + new DisplayModel(); + DisplayModel sastSeverityParentModel = DisplayModel.builder() + .name(mapEntry.getKey() + " (" + listForEachSeverity.size() + ")").children(listForEachSeverity) + .build(); + sastParentModelList.add(sastSeverityParentModel); + + } + // SCA + scaCount = 0; + List scaParentModelList = new ArrayList(); + for (Map.Entry> mapEntry : scaResultsMap.entrySet()) { + + List listForEachSeverity = mapEntry.getValue(); + scaCount = scaCount + listForEachSeverity.size(); + new DisplayModel(); + DisplayModel scaSeverityParentModel = DisplayModel.builder() + .name(mapEntry.getKey() + " (" + listForEachSeverity.size() + ")").children(listForEachSeverity) + .build(); + scaParentModelList.add(scaSeverityParentModel); + + } + + // kics + kicsCount = 0; + List kicsParentModelList = new ArrayList(); + for (Map.Entry> mapEntry : kicsResultsMap.entrySet()) { + + List listForEachSeverity = mapEntry.getValue(); + kicsCount = kicsCount + listForEachSeverity.size(); + new DisplayModel(); + DisplayModel kicsSeverityParentModel = DisplayModel.builder() + .name(mapEntry.getKey() + " (" + listForEachSeverity.size() + ")").children(listForEachSeverity) + .build(); + kicsParentModelList.add(kicsSeverityParentModel); + + } + + List results = new ArrayList<>(); + if (sastParentModelList.size() > 0) { + new DisplayModel(); - DisplayModel sastModel = DisplayModel.builder().name("SAST").children(sastParentModelList).build(); + DisplayModel sastModel = DisplayModel.builder().name("SAST" + " (" + sastCount + ")") + .children(sastParentModelList).build(); results.add(sastModel); } - if(scaResultsModel.size()>0) - { + if (scaParentModelList.size() > 0) { new DisplayModel(); - DisplayModel scaModel = DisplayModel.builder().name("SCA").children(scaResultsModel).build(); + DisplayModel scaModel = DisplayModel.builder().name("SCA" + " (" + scaCount + ")") + .children(scaParentModelList).build(); results.add(scaModel); } - if(kicsResultsModel.size()>0) - { + if (kicsParentModelList.size() > 0) { new DisplayModel(); - DisplayModel kicsModel = DisplayModel.builder().name("KICS").children(kicsResultsModel).build(); - results.add(kicsModel); + DisplayModel kicsModel = DisplayModel.builder().name("KICS" + " (" + kicsCount + ")") + .children(kicsParentModelList).build(); + results.add(kicsModel); } - - - // for (Map.Entry mapEntry : treeItemMap.entrySet()) { // DisplayModel parentDisplayItem = new DisplayModel().builder().name((String) mapEntry.getKey()).children((List) mapEntry.getValue()).build(); // results.add(parentDisplayItem); // } - - - projectModel = DisplayModel.builder().name("Scan ID can be placed here") - .type(" Total Issues Found :" + resultsCommandOutput.getTotalCount()).children(results) - .build(); - return projectModel; + + projectModel = DisplayModel.builder().name(scanId + " (" + scanResults.getTotalCount() + " Issues)") + .children(results).build(); + + List returnList = new ArrayList<>(); + returnList.add(projectModel); + + return returnList; } - - private DisplayModel transform(CxResult resultItem) { - String queryName = (resultItem.getData()).getQueryName(); - - return DisplayModel.builder().name(queryName).state(resultItem.getState()).status(resultItem.getStatus()).severity(resultItem.getSeverity()).type(resultItem.getType()).build(); + private DisplayModel transform(Result resultItem) { + + String displayName; + if ((resultItem.getType()).equals(PluginConstants.SCA_DEPENDENCY)) { + displayName = resultItem.getSimilarityId(); + } else { + displayName = (resultItem.getData()).getQueryName(); + } + + + return DisplayModel.builder().name(displayName).severity(resultItem.getSeverity()).type(resultItem.getType()) + .result(resultItem).build(); + +// return DisplayModel.builder().name(displayName).state(resultItem.getState()).status(resultItem.getStatus()) +// .severity(resultItem.getSeverity()).type(resultItem.getType()).description(description).nodes(nodesList).build(); } - - private List filterResultsByScannerType(List resultList ,String scannerType) { - - List filteredResults = new ArrayList<>(); - - for (CxResult cxResult : resultList) { - - if(cxResult.getType().equalsIgnoreCase(scannerType)) - { - filteredResults.add(cxResult); + +// private List filterResultsByScannerType(List resultList, String scannerType) { +// +// List filteredResults = new ArrayList<>(); +// +// for (CxResult cxResult : resultList) { +// +// if (cxResult.getType().equalsIgnoreCase(scannerType)) { +// filteredResults.add(cxResult); +// } +// } +// return filteredResults; +// } + +// private Map> filterResultsByScannerType(List resultList) { +// +// Map> filteredMap = new HashMap<>(); +// +// for (CxResult cxResult : resultList) { +// +// String scanType = cxResult.getType(); +// +// if (filteredMap.containsKey(scanType)) { +// List mapResultList = filteredMap.get(scanType); +// mapResultList.add(cxResult); +// } else { +// List mapResultList = new ArrayList<>(); +// mapResultList.add(cxResult); +// filteredMap.put(scanType, mapResultList); +// } +// +// } +// return filteredMap; +// } + + private Map> filterResultsByScannerTypeV2(List allResultsTransformed) { + + Map> filteredMap = new HashMap<>(); + + for (DisplayModel transformedResult : allResultsTransformed) { + + String scanType = transformedResult.getType(); + + if (filteredMap.containsKey(scanType)) { + List mapResultList = filteredMap.get(scanType); + mapResultList.add(transformedResult); + } else { + List mapResultList = new ArrayList<>(); + mapResultList.add(transformedResult); + filteredMap.put(scanType, mapResultList); } + } - return filteredResults; + return filteredMap; } - - private List filterResultsBySeverity(List resultList ,String severity) { - - List filteredResult = new ArrayList<>(); - - for (CxResult cxResult : resultList) { - - if(cxResult.getSeverity().equalsIgnoreCase(severity)) - { - filteredResult.add(cxResult); + +// private List filterResultsBySeverity(List resultList, String severity) { +// +// List filteredResult = new ArrayList<>(); +// +// for (CxResult cxResult : resultList) { +// +// if (cxResult.getSeverity().equalsIgnoreCase(severity)) { +// filteredResult.add(cxResult); +// } +// } +// return filteredResult; +// } + + private Map> filterResultsBySeverityV2(List resultList) { + + Map> filteredMap = new HashMap<>(); + + for (DisplayModel result : resultList) { + + String severityType = result.getSeverity(); + + if (filteredMap.containsKey(severityType)) { + List mapResultList = filteredMap.get(severityType); + mapResultList.add(result); + } else { + List mapResultList = new ArrayList<>(); + mapResultList.add(result); + filteredMap.put(severityType, mapResultList); } + } - return filteredResult; + return filteredMap; } } diff --git a/src/com/checkmarx/eclipse/views/DisplayModel.java b/src/com/checkmarx/eclipse/views/DisplayModel.java index 8a1368e6..fe72f730 100644 --- a/src/com/checkmarx/eclipse/views/DisplayModel.java +++ b/src/com/checkmarx/eclipse/views/DisplayModel.java @@ -3,17 +3,17 @@ import java.util.ArrayList; import java.util.List; -import com.checkmarx.ast.results.structure.CxResultComments; -import com.checkmarx.ast.results.structure.CxResultData; -import com.checkmarx.ast.results.structure.CxResultVulnerabilityDetails; +import com.checkmarx.ast.results.result.Result; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @Builder +@Getter public class DisplayModel { public DisplayModel parent; @@ -23,14 +23,7 @@ public class DisplayModel { public String type; public String severity; - public String status; - public String state; - public String line; - public String column; - public String sourceNode; - public String sourceFile; - public String sinkNode; - public String sinkFile; + public Result result; diff --git a/src/com/checkmarx/eclipse/views/provider/TreeContentProvider.java b/src/com/checkmarx/eclipse/views/provider/TreeContentProvider.java index e8315a9d..83c5cd84 100644 --- a/src/com/checkmarx/eclipse/views/provider/TreeContentProvider.java +++ b/src/com/checkmarx/eclipse/views/provider/TreeContentProvider.java @@ -1,11 +1,9 @@ package com.checkmarx.eclipse.views.provider; -import java.util.ArrayList; import java.util.List; import org.eclipse.jface.viewers.ITreeContentProvider; -import com.checkmarx.ast.results.structure.CxResult; import com.checkmarx.eclipse.views.DisplayModel; public class TreeContentProvider implements ITreeContentProvider {