Skip to content

Commit

Permalink
Merge branch 'main' into fix/auth-wizard-cancel-button
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrobinsonhodges-snyk authored Dec 19, 2024
2 parents a766ea2 + 6d52e62 commit d281c12
Show file tree
Hide file tree
Showing 52 changed files with 581 additions and 624 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Snyk Security Changelog

## [Unreleased]
## [3.0.0]
### Changes
- process api URL from hasAuthenticated message
- add release channel preference to select which CLI is downloaded
- added plugin installed event and analytics sender
- added new UI view to display issue details for all scan types
- removed legacy UI view
- added Snyk Code consistent ignores support
- added Net new issues support

## [2.2.0] - v20241024.154007
### Changes
Expand Down
46 changes: 13 additions & 33 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</extension>
<extension point="org.eclipse.ui.commands">
<command
defaultHandler="io.snyk.eclipse.plugin.views.MenuHandler"
defaultHandler="io.snyk.eclipse.plugin.views.ScanWorkspaceFolderHandler"
id="io.snyk.eclipse.plugin.commands.execute"
name="%command.name">
</command>
Expand Down Expand Up @@ -102,7 +102,7 @@
</command>
<command
id="io.snyk.eclipse.plugin.commands.enableIAC"
name="Infrastructure as Code"
name="Configuration"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableIacProductHandler">
</command>
<command
Expand All @@ -117,44 +117,34 @@
</command>
<command
id="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
name="Net New Issues"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaNewIssuesHandler">
name="Show only Net New Issues"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterNetNewIssuesHandler">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresOpenIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykShowOpenIgnored"
name="Open Issues">
name="Show open Issues">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykShowIgnored"
name="Ignored Issues">
name="Show ignored Issues">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterFixableIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykFilterFixableIssues"
name="AI Fixable">
name="Show only fixable issues">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterOssFixableIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykFilterOssFixableIssues"
name="Fixable">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableAllAiFixHandler"
id="io.snyk.eclipse.plugin.snykShowAllSeverities"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableAllSeveritiesHandler"
id="io.snyk.eclipse.plugin.commands.snykShowAllSeverities"
name="Show All Severities">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableAllProductHandler"
id="io.snyk.eclipse.plugin.command.snykShowAllProducts"
name="Show All Products">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableAllIssuesHandler"
id="io.snyk.eclipse.plugin.command.snykShowAllIssuesStatus"
name="Show All Issues">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
Expand Down Expand Up @@ -284,7 +274,7 @@
visible="true">
</separator>
<command
commandId="io.snyk.eclipse.plugin.snykShowAllSeverities"
commandId="io.snyk.eclipse.plugin.commands.snykShowAllSeverities"
icon="icons/enabled.png"
style="push"
tooltip="Show Issues of all Severities">
Expand Down Expand Up @@ -351,23 +341,13 @@
</command>
</menu>
<menu
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersAiFixMenu"
label="Open Source Fixability">
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterOssFixableIssues"
icon="icons/enabled.png"
style="push"
tooltip="Show only issues with Open Source Upgrade suggestions">
</command>
</menu>
<menu
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersOssMenu"
label="Code AI Fixability">
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersFixability"
label="Fixability">
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterFixableIssues"
icon="icons/enabled.png"
style="push"
tooltip="Show only issues with AIFix or Fix suggestions">
tooltip="Show only issues that can be automatically fixed">
</command>
</menu>
</menuContribution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import java.util.Map;
import java.util.Random;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.themes.ITheme;
import org.eclipse.ui.themes.IThemeManager;
import org.osgi.framework.Bundle;

import io.snyk.eclipse.plugin.preferences.Preferences;
import io.snyk.eclipse.plugin.utils.ResourceUtils;

public class BaseHtmlProvider {
private final Random random = new Random();
Expand Down Expand Up @@ -42,6 +45,55 @@ public String getNonce() {
nonce = nonceBuilder.toString();
return nonce;
}

public String getNoDescriptionHtml() {
String snykWarningText = Platform.getResourceString(Platform.getBundle("io.snyk.eclipse.plugin"),
"%snyk.trust.dialog.warning.text");

Bundle bundle = Platform.getBundle("io.snyk.eclipse.plugin");
String base64Image = ResourceUtils.getBase64Image(bundle, "logo_snyk.png");

var html = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: var(--default-font);
background-color: var(--background-color);
color: var(--text-color);
}
.container {
display: flex;
align-items: center;
}
.logo {
margin-right: 20px;
}
a {
color: var(--link-color)
}
div {
padding: 20px
}
</style>
</head>
<body>
<div class="container">
<img src='data:image/png;base64,%s' alt='Snyk Logo'>
<div>
<p><strong>Please rescan to see the issue description.</strong></p>
</div>
</div>
</body>
</html>
""".formatted(base64Image, snykWarningText);
return html;
}


public String replaceCssVariables(String html) {
// Build the CSS with the nonce
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static StaticPageHtmlProvider getInstance() {
}
return instance;
}

public String getInitHtml() {
String snykWarningText = Platform.getResourceString(Platform.getBundle("io.snyk.eclipse.plugin"),
"%snyk.trust.dialog.warning.text");
Expand Down Expand Up @@ -71,4 +71,6 @@ public String getInitHtml() {
""".formatted(base64Image, snykWarningText);
return replaceCssVariables(html);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
public static final String LSP_VERSION = "LSP_VERSION";
public static final String USE_TOKEN_AUTH = "useTokenAuth";
public static final String ANALYTICS_PLUGIN_INSTALLED_SENT = "analyticsPluginInstalledSent";
public static final String FILTER_CRITICAL = "FILTER_SNYK_CRITICAL";
public static final String FILTER_HIGH = "FILTER_SNYK_HIGH";
public static final String FILTER_MEDIUM = "FILTER_SNYK_MEDIUM";
public static final String FILTER_LOW = "FILTER_SNYK_LOW";
public static final String FILTER_DELTA_NEW_ISSUES = "FILTER_SNYK_NEW_ISSUES";
public static final String FILTER_IGNORES_SHOW_OPEN_ISSUES = "FILTER_IGNORES_OPEN_ISSUES";
public static final String FILTER_IGNORES_SHOW_IGNORED_ISSUES = "FILTER_IGNORES_IGNORED_ISSUES";
public static final String FILTER_FIXABLE_ISSUES = "FILTER_FIXABLE_ISSUES";
public static final String FILTER_OSS_FIXABLE_ISSUES = "FILTER_OSS_FIXABLE_ISSUES";
public static final String ENABLE_DELTA = "ENABLE_DELTA";


// all filter preferences are positive: SHOW = true, HIDE = false
public static final String FILTER_SHOW_CRITICAL = "FILTER_SHOW_CRITICAL";
public static final String FILTER_SHOW_HIGH = "FILTER_SHOW_HIGH";
public static final String FILTER_SHOW_MEDIUM = "FILTER_SHOW_MEDIUM";
public static final String FILTER_SHOW_LOW = "FILTER_SHOW_LOW";

public static final String FILTER_IGNORES_SHOW_OPEN_ISSUES = "FILTER_IGNORES_SHOW_OPEN_ISSUES";
public static final String FILTER_IGNORES_SHOW_IGNORED_ISSUES = "FILTER_IGNORES_SHOW_IGNORED_ISSUES";
public static final String FILTER_SHOW_ONLY_FIXABLE = "FILTER_SHOW_FIXABLE_AND_UNFIXABLE_ISSUES";

// Feature flags
public static final String IS_GLOBAL_IGNORES_FEATURE_ENABLED = "IS_GLOBAL_IGNORES_FEATURE_ENABLED";
Expand Down Expand Up @@ -87,32 +90,29 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
if (getPref(ACTIVATE_SNYK_IAC) == null) {
store(ACTIVATE_SNYK_IAC, "true");
}
if (getPref(FILTER_CRITICAL) == null) {
store(FILTER_CRITICAL, "false");
if (getPref(FILTER_SHOW_CRITICAL) == null) {
store(FILTER_SHOW_CRITICAL, "true");
}
if (getPref(FILTER_HIGH) == null) {
store(FILTER_HIGH, "false");
if (getPref(FILTER_SHOW_HIGH) == null) {
store(FILTER_SHOW_HIGH, "true");
}
if (getPref(FILTER_MEDIUM) == null) {
store(FILTER_MEDIUM, "false");
if (getPref(FILTER_SHOW_MEDIUM) == null) {
store(FILTER_SHOW_MEDIUM, "true");
}
if (getPref(FILTER_LOW) == null) {
store(FILTER_LOW, "false");
if (getPref(FILTER_SHOW_LOW) == null) {
store(FILTER_SHOW_LOW, "true");
}
if (getPref(FILTER_DELTA_NEW_ISSUES) == null) {
store(FILTER_DELTA_NEW_ISSUES, "false");
if (getPref(ENABLE_DELTA) == null) {
store(ENABLE_DELTA, "false");
}
if (getPref(FILTER_IGNORES_SHOW_OPEN_ISSUES) == null) {
store(FILTER_IGNORES_SHOW_OPEN_ISSUES, "true");
}
if (getPref(FILTER_IGNORES_SHOW_IGNORED_ISSUES) == null) {
store(FILTER_IGNORES_SHOW_IGNORED_ISSUES, "true");
}
if (getPref(FILTER_FIXABLE_ISSUES) == null) {
store(FILTER_FIXABLE_ISSUES, "false");
store(FILTER_IGNORES_SHOW_IGNORED_ISSUES, "false");
}
if (getPref(FILTER_OSS_FIXABLE_ISSUES) == null) {
store(FILTER_OSS_FIXABLE_ISSUES, "false");
if (getPref(FILTER_SHOW_ONLY_FIXABLE) == null) {
store(FILTER_SHOW_ONLY_FIXABLE, "false");
}

if (getPref(SEND_ERROR_REPORTS) == null) {
Expand Down Expand Up @@ -262,7 +262,7 @@ public boolean isTest() {
}

public static boolean isDeltaEnabled() {
return Preferences.getInstance().getBooleanPref(Preferences.FILTER_DELTA_NEW_ISSUES);
return Preferences.getInstance().getBooleanPref(Preferences.ENABLE_DELTA);
}

public static void setCurrentPreferences(Preferences prefs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.snyk.eclipse.plugin.utils.ResourceUtils;
import io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient;

public class MenuHandler extends AbstractHandler {
public class ScanWorkspaceFolderHandler extends AbstractHandler {

@SuppressWarnings("restriction")
public Object execute(ExecutionEvent event) throws ExecutionException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.snyk.eclipse.plugin.views.snyktoolview;

import static org.apache.commons.lang3.StringUtils.isEmpty;

import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4j.Location;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void changed(LocationEvent event) {
browser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
if (!StringUtils.isEmpty(initScript)) {
if (!isEmpty(initScript)) {
browser.execute(initScript);
}
}
Expand Down Expand Up @@ -116,9 +117,14 @@ public CompletableFuture<Void> updateBrowserContent(TreeNode node) {
return CompletableFuture.supplyAsync(() -> {
return generateHtmlContent(node);
}).thenAccept(htmlContent -> {
var content = htmlProvider.replaceCssVariables(htmlContent);
if (isEmpty(htmlContent)) {
htmlContent = htmlProvider.getNoDescriptionHtml();
}

final var browserContent = htmlProvider.replaceCssVariables(htmlContent);

Display.getDefault().syncExec(() -> {
browser.setText(content);
browser.setText(browserContent);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public void selectionChanged(SelectionChangedEvent event) {

if (Preferences.isDeltaEnabled())
this.enableDelta();

// initialize the filters
TreeFilterManager.getInstance();
}

private void registerTreeContextMenu(Control control) {
Expand Down Expand Up @@ -406,10 +409,6 @@ public void disableDelta() {
}
}
}

CompletableFuture.runAsync(() -> {
SnykExtendedLanguageClient.getInstance().triggerScan(null);
});
}

// Helper method to add a command if it's not already present
Expand Down
Loading

0 comments on commit d281c12

Please sign in to comment.