fix(TUP-36082):DetectCVE in Studio (#6471)
* fix(TUP-36082):DetectCVE in Studio https://jira.talendforge.org/browse/TUP-36082 * fix(TUP-36082):DetectCVE in Studio https://jira.talendforge.org/browse/TUP-36082 * fix(TUP-36082):DetectCVE in Studio https://jira.talendforge.org/browse/TUP-36082 * fix(TUP-36082):DetectCVE in Studio https://jira.talendforge.org/browse/TUP-36082
This commit is contained in:
@@ -6,6 +6,7 @@ Bundle-Version: 8.0.1.qualifier
|
||||
Bundle-Localization: plugin
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Export-Package: org.talend.analysistask,
|
||||
org.talend.commons.report,
|
||||
org.talend.commons.utils.generation,
|
||||
org.talend.commons.utils.io,
|
||||
org.talend.commons.utils.workbench.resources,
|
||||
|
||||
@@ -26,26 +26,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.widgets.WidgetFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.report.ItemsReportUtil;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.report.ReportAccessDialog;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
@@ -175,8 +161,10 @@ public class ItemAnalysisReportManager {
|
||||
boolean generateSuccess = ItemsReportUtil.generateReportFile(reportFile, ANALYSIS_REPORT_HEAD, recordLines);
|
||||
if (generateSuccess) {
|
||||
Display.getDefault().asyncExec(() -> {
|
||||
AnalysisReportAccessDialog accessDialog = new AnalysisReportAccessDialog(
|
||||
ReportAccessDialog accessDialog = new ReportAccessDialog(
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
|
||||
Messages.getString("AnalysisReportAccessDialog.shellTitle"),
|
||||
Messages.getString("AnalysisReportAccessDialog.generateSuccess"),
|
||||
reportFile.getAbsolutePath());
|
||||
accessDialog.open();
|
||||
});
|
||||
@@ -240,76 +228,3 @@ public class ItemAnalysisReportManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AnalysisReportAccessDialog extends Dialog {
|
||||
|
||||
private String reportGeneratedFile;
|
||||
|
||||
protected AnalysisReportAccessDialog(Shell parentShell, String reportGeneratedFile) {
|
||||
super(parentShell);
|
||||
this.reportGeneratedFile = reportGeneratedFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureShell(Shell newShell) {
|
||||
super.configureShell(newShell);
|
||||
newShell.setText(Messages.getString("AnalysisReportAccessDialog.shellTitle"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeBounds() {
|
||||
getShell().setSize(700, 190);
|
||||
Point location = getInitialLocation(getShell().getSize());
|
||||
getShell().setLocation(location.x, location.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
Composite container = WidgetFactory.composite(SWT.NONE).layout(layout).layoutData(new GridData(GridData.FILL_BOTH))
|
||||
.create(parent);
|
||||
applyDialogFont(container);
|
||||
|
||||
Composite composite = new Composite(container, SWT.NONE);
|
||||
GridLayout compositeLayout = new GridLayout();
|
||||
compositeLayout.numColumns = 1;
|
||||
compositeLayout.marginWidth = 0;
|
||||
compositeLayout.marginTop = 8;
|
||||
compositeLayout.marginLeft = 10;
|
||||
composite.setLayout(compositeLayout);
|
||||
Label successMsgLabel = new Label(composite, SWT.NONE);
|
||||
successMsgLabel.setText(Messages.getString("AnalysisReportAccessDialog.generateSuccess"));
|
||||
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_VERTICAL);
|
||||
successMsgLabel.setLayoutData(gridData);
|
||||
|
||||
Link accessLink = new Link(composite, SWT.NONE);
|
||||
accessLink.setText(Messages.getString("AnalysisReportAccessDialog.completeReportAvailable") + " <a>"
|
||||
+ Messages.getString("AnalysisReportAccessDialog.accessReport") + "</a> ");
|
||||
accessLink.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_VERTICAL));
|
||||
accessLink.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
File reportFile = new File(reportGeneratedFile);
|
||||
if (reportFile != null && reportFile.exists()) {
|
||||
try {
|
||||
FilesUtils.selectFileInSystemExplorer(reportFile);
|
||||
} catch (Exception excep) {
|
||||
ExceptionHandler.process(excep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.report;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.widgets.WidgetFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.layout.FormLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class ReportAccessDialog extends Dialog {
|
||||
|
||||
private String shellTitle;
|
||||
|
||||
private String message;
|
||||
|
||||
private String reportGeneratedFile;
|
||||
|
||||
public ReportAccessDialog(Shell parentShell, String shellTitle, String message, String reportGeneratedFile) {
|
||||
super(parentShell);
|
||||
this.shellTitle = shellTitle;
|
||||
this.message = message;
|
||||
this.reportGeneratedFile = reportGeneratedFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureShell(Shell newShell) {
|
||||
super.configureShell(newShell);
|
||||
newShell.setText(shellTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeBounds() {
|
||||
getShell().setSize(700, 190);
|
||||
Point location = getInitialLocation(getShell().getSize());
|
||||
getShell().setLocation(location.x, location.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
Composite container = WidgetFactory.composite(SWT.NONE).layout(layout).layoutData(new GridData(GridData.FILL_BOTH))
|
||||
.create(parent);
|
||||
applyDialogFont(container);
|
||||
|
||||
Composite composite = new Composite(container, SWT.NONE);
|
||||
GridLayout compositeLayout = new GridLayout();
|
||||
compositeLayout.numColumns = 1;
|
||||
compositeLayout.marginWidth = 0;
|
||||
compositeLayout.marginTop = 8;
|
||||
compositeLayout.marginLeft = 10;
|
||||
composite.setLayout(compositeLayout);
|
||||
Label successMsgLabel = new Label(composite, SWT.NONE);
|
||||
successMsgLabel.setText(message);
|
||||
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_VERTICAL);
|
||||
successMsgLabel.setLayoutData(gridData);
|
||||
|
||||
Composite noteComp = new Composite(composite, SWT.NONE);
|
||||
noteComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
||||
noteComp.setLayout(new FormLayout());
|
||||
Label noteLabel = new Label(noteComp, SWT.NONE);
|
||||
noteLabel.setText(Messages.getString("AnalysisReportAccessDialog.completeReportAvailable"));
|
||||
FormData noteLabelFormData = new FormData();
|
||||
noteLabelFormData.bottom = new FormAttachment(100, -5);
|
||||
noteLabelFormData.left = new FormAttachment(0, 0);
|
||||
noteLabel.setLayoutData(noteLabelFormData);
|
||||
Button browseBtn = new Button(noteComp, SWT.NONE);
|
||||
browseBtn.setText(Messages.getString("AnalysisReportAccessDialog.accessBrowse"));
|
||||
FormData linkFormData = new FormData();
|
||||
linkFormData.top = new FormAttachment(0, 0);
|
||||
linkFormData.left = new FormAttachment(noteLabel, 5);
|
||||
browseBtn.setLayoutData(linkFormData);
|
||||
browseBtn.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
File reportFile = new File(reportGeneratedFile);
|
||||
if (reportFile != null && reportFile.exists()) {
|
||||
try {
|
||||
FilesUtils.selectFileInSystemExplorer(reportFile);
|
||||
} catch (Exception excep) {
|
||||
ExceptionHandler.process(excep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -640,7 +640,7 @@ TalendLibsServerManager.cannotGetUserLibraryServer=Cannot get the user library s
|
||||
MigrationReportAccessDialog.title=Project items migration
|
||||
MigrationReportAccessDialog.migrateSuccess=Project items migrated successfully.
|
||||
MigrationReportAccessDialog.completeReportAvailable=Check the report
|
||||
MigrationReportAccessDialog.accessReport=here
|
||||
MigrationReportAccessDialog.accessBrowse=Browse...
|
||||
MigrationReportAccessDialog.provideAnalysisTool=You can run project analysis now to analyze your migrated project. This experimental tool will generate a report containing:
|
||||
MigrationReportAccessDialog.listOfProblems=- List of items to fix manually.
|
||||
MigrationReportAccessDialog.listItems=- List of items to check.
|
||||
@@ -655,7 +655,7 @@ ItemAnalysisReportManager.Warning.message=Can't run a new analysis now. Wait for
|
||||
AnalysisReportAccessDialog.shellTitle=Project analysis
|
||||
AnalysisReportAccessDialog.generateSuccess=Project analysis completed successfully.
|
||||
AnalysisReportAccessDialog.completeReportAvailable=Check the report
|
||||
AnalysisReportAccessDialog.accessReport=here
|
||||
AnalysisReportAccessDialog.accessBrowse=Browse...
|
||||
AbstractPomTemplateProjectSettingPage.defaultTabLabel=Default
|
||||
AbstractPomTemplateProjectSettingPage.customTabLabel=Custom
|
||||
AbstractPomTemplateProjectSettingPage.previewButton=Preview
|
||||
|
||||
@@ -24,7 +24,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
@@ -88,6 +90,13 @@ public interface IDetectCVEService extends IService {
|
||||
*/
|
||||
void clearCache();
|
||||
|
||||
public static IDetectCVEService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDetectCVEService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IDetectCVEService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mavenUri2GAV(String uri) {
|
||||
if (MavenUrlHelper.isMvnUrl(uri)) {
|
||||
MavenArtifact art = MavenUrlHelper.parseMvnUrl(uri);
|
||||
@@ -1009,7 +1018,7 @@ public interface IDetectCVEService extends IService {
|
||||
this.version = ver;
|
||||
}
|
||||
|
||||
private Date parseVersion() {
|
||||
public Date parseVersion() {
|
||||
String ver = version;
|
||||
if (ver != null) {
|
||||
if (ver.startsWith("R")) {
|
||||
@@ -1019,7 +1028,10 @@ public interface IDetectCVEService extends IService {
|
||||
try {
|
||||
return df.parse(ver);
|
||||
} catch (ParseException e) {
|
||||
ExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
// avoid too much log
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -21,13 +21,15 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.layout.FormLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.analysistask.ItemAnalysisReportManager;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -84,11 +86,23 @@ public class MigrationReportAccessDialog extends Dialog {
|
||||
migrationInfoLayout.marginLeft = 10;
|
||||
migrationInfoArea.setLayout(migrationInfoLayout);
|
||||
createMessageLabel(migrationInfoArea, Messages.getString("MigrationReportAccessDialog.migrateSuccess"));
|
||||
Link accessLink = new Link(migrationInfoArea, SWT.NONE);
|
||||
accessLink.setText(Messages.getString("MigrationReportAccessDialog.completeReportAvailable") + " <a>"
|
||||
+ Messages.getString("MigrationReportAccessDialog.accessReport") + "</a> .");
|
||||
accessLink.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_VERTICAL));
|
||||
accessLink.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
Composite noteComp = new Composite(migrationInfoArea, SWT.NONE);
|
||||
noteComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
||||
noteComp.setLayout(new FormLayout());
|
||||
Label noteLabel = new Label(noteComp, SWT.NONE);
|
||||
noteLabel.setText(Messages.getString("MigrationReportAccessDialog.completeReportAvailable"));
|
||||
FormData noteLabelFormData = new FormData();
|
||||
noteLabelFormData.bottom = new FormAttachment(100, -5);
|
||||
noteLabelFormData.left = new FormAttachment(0, 0);
|
||||
noteLabel.setLayoutData(noteLabelFormData);
|
||||
Button browseBtn = new Button(noteComp, SWT.NONE);
|
||||
browseBtn.setText(Messages.getString("MigrationReportAccessDialog.accessBrowse"));
|
||||
FormData linkFormData = new FormData();
|
||||
linkFormData.top = new FormAttachment(0, 0);
|
||||
linkFormData.left = new FormAttachment(noteLabel, 5);
|
||||
browseBtn.setLayoutData(linkFormData);
|
||||
browseBtn.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
Reference in New Issue
Block a user