Skip to content

Commit

Permalink
Update SecuCheck notification with action to open SARIF file
Browse files Browse the repository at this point in the history
  • Loading branch information
oshando committed May 7, 2024
1 parent 3d6fb24 commit 8081d8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.intellij.notification.*;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.*;
Expand Down Expand Up @@ -54,6 +55,7 @@
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.text.DecimalFormat;
import java.util.*;

Expand Down Expand Up @@ -389,8 +391,23 @@ public void launchSwan(HashMap<String, String> values) {
bus.connect().subscribe(SecucheckNotifier.END_SECUCHECK_PROCESS_TOPIC, new SecucheckNotifier() {
@Override
public void launchSecuCheck() {
String notificationContent = "SecuCheck results exported to "+PropertiesComponent.getInstance(project).getValue(Constants.OUTPUT_DIRECTORY);
NotificationGroupManager.getInstance().getNotificationGroup("Process_Completed").createNotification(notificationContent, NotificationType.INFORMATION).notify(project);
String notificationContent = "Taint analysis results exported successfully.";
NotificationGroupManager.getInstance()
.getNotificationGroup("Analysis Notification")
.createNotification(notificationContent, NotificationType.INFORMATION)
.addAction(new NotificationAction("Open Results") {
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent, @NotNull Notification notification) {

File results = new File(Objects.requireNonNull(PropertiesComponent.getInstance(project).getValue(Constants.LAST_SARIF_FILE)));
Optional<VirtualFile> file = FilenameIndex
.getVirtualFilesByName(results.getName(),
GlobalSearchScope.projectScope(project)).stream().findFirst();

file.ifPresent(virtualFile -> new OpenFileDescriptor(project, virtualFile).navigate(true));
}
})
.notify(project);
}
});

Expand Down
2 changes: 1 addition & 1 deletion dev-assist/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<codeInsight.lineMarkerProvider language="JAVA"
implementationClass="de.fraunhofer.iem.devassist.ui.markers.ErrorLineMarker"/>
<toolWindow id="Dev-Assist" anchor="right" factoryClass="de.fraunhofer.iem.devassist.ui.SummaryToolWindow" icon="PluginIcons.DEV_ASSIST"/>
<notificationGroup id="Process_Completed" displayType="TOOL_WINDOW"/>
<notificationGroup id="SRM Notification" displayType="BALLOON"/>
<notificationGroup id="Analysis Notification" displayType="STICKY_BALLOON"/>
</extensions>

<actions>
Expand Down

0 comments on commit 8081d8d

Please sign in to comment.