Skip to content

feat: add support for IAW command #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Snyk Security Changelog

## [3.2.0]
### Changes
- Added support for submitting Ignore Requests.

## [3.1.0]
### Changes
- add option for using a folder as reference instead of a branch in net-new scanning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,31 @@ public String replaceCssVariables(String html) {
super.getColorAsHex("DELETION_COLOR", "#ff0000"));
htmlStyled = htmlStyled.replace("var(--example-line-added-color)",
super.getColorAsHex("ADDITION_COLOR", "#00ff00"));
htmlStyled = htmlStyled.replace("var(--generated-ai-fix-button-background-color)",
htmlStyled = htmlStyled.replace("var(--button-background-color)",
super.getColorAsHex("BUTTON_COLOR", "#375578"));
htmlStyled = htmlStyled.replace("var(--button-text-color)",
super.getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_SELECTED_TEXT_COLOR", "#F5F5F5"));
htmlStyled = htmlStyled.replace("var(--disabled-background-color)",
super.getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR", "#CCCCCC"));
htmlStyled = htmlStyled.replace("var(--vscode-input-border)", super.getColorAsHex("BUTTON_COLOR", "#375578"));
htmlStyled = htmlStyled.replace("var(--warning-text)", super.getColorAsHex("WARNING_TEXT_COLOR", "#000000"));
htmlStyled = htmlStyled.replace("var(--warning-background)", super.getColorAsHex("WARNING_BACKGROUND_COLOR", "#c8a000"));
htmlStyled = htmlStyled.replace("var(--warning-background)",
super.getColorAsHex("WARNING_BACKGROUND_COLOR", "#c8a000"));

String htmlWithScripts = replaceAIFixScripts(htmlStyled);
String htmlWithIgnoreRequest = replaceIgnoreRequestScript(htmlWithScripts);

return htmlWithScripts;
return htmlWithIgnoreRequest;
}

private String replaceIgnoreRequestScript(String htmlWithScripts) {
String htmlWithIgnoreRequest = htmlWithScripts.replace("${ideSubmitIgnoreRequest}",
ideSubmitIgnoreRequestScript());
return htmlWithIgnoreRequest;
}

private CharSequence ideSubmitIgnoreRequestScript() {
return "window.ideSubmitIgnoreRequest(issueId + '@|@' + ignoreType + '@|@' + ignoreExpirationDate + '@|@' + ignoreReason);\n";
}

private String replaceAIFixScripts(String html) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ public Object function(Object[] arguments) {
}
};

new BrowserFunction(browser, "ideSubmitIgnoreRequest") {
@Override
public Object function(Object[] arguments) {
String params = (String) arguments[0];
String[] parts = params.split("@\\|@", 4);
String issueId = (String) parts[0];
String ignoreType = (String) parts[1];
String ignoreExpirationDate = (String) parts[2];
String ignoreReason = (String) parts[3];

SnykExtendedLanguageClient.getInstance().submitIgnoreRequestCommands("create", issueId, ignoreType, ignoreReason, ignoreExpirationDate);

return Collections.emptyList();
}
};

new BrowserFunction(browser, "ideGenAIFix") {
@Override
public Object function(Object[] arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ private LsConstants() {
public static final String COMMAND_CODE_FIX_APPLY_AI_EDIT = "snyk.code.fixApplyEdit";
public static final String COMMAND_CODE_SUBMIT_FIX_FEEDBACK = "snyk.code.submitFixFeedback";
public static final String COMMAND_SNYK_CLI = "snyk.executeCLI";
public static final String COMMAND_SUBMIT_IGNORE_REQUEST = "snyk.submitIgnoreRequest";
public static final String SNYK_HAS_AUTHENTICATED = "$/snyk.hasAuthenticated";
public static final String SNYK_IS_AVAILABLE_CLI = "$/snyk.isAvailableCli";
public static final String SNYK_ADD_TRUSTED_FOLDERS = "$/snyk.addTrustedFolders";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ public void sendCodeApplyAiFixEditCommand(String fixId) {
executeCommand(LsConstants.COMMAND_CODE_FIX_APPLY_AI_EDIT, List.of(fixId));
}

public void submitIgnoreRequestCommands(String workflow, String issueId, String ignoreType, String ignoreReason, String ignoreExpirationDate) {
executeCommand(LsConstants.COMMAND_SUBMIT_IGNORE_REQUEST, List.of(workflow, issueId, ignoreType, ignoreReason, ignoreExpirationDate));
}

@JsonNotification(value = LsConstants.SNYK_HAS_AUTHENTICATED)
public void hasAuthenticated(HasAuthenticatedParam param) {
var prefs = Preferences.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/resources/code_issue_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@
button.generate-ai-fix,
button.sn-apply-fix {
border-radius: 3px;
background-color: var(--generated-ai-fix-button-background-color);
background-color: var(--button-background-color);
color: white;
cursor: pointer;
}
Expand Down