Skip to content

Commit 3c60b57

Browse files
Merge pull request #392 from Checkmarx/other/standalone
Other/standalone(AST-109612)
2 parents 26896ec + 66c1a95 commit 3c60b57

File tree

141 files changed

+11821
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+11821
-1181
lines changed

src/main/java/com/checkmarx/intellij/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ private Constants() {
9696
public static final String CONFIRMED = "CONFIRMED";
9797
public static final String TO_VERIFY = "TO_VERIFY";
9898
public static final String URGENT = "URGENT";
99+
public static final String ERROR = "Error";
100+
99101

100102
public static final String USE_LOCAL_BRANCH = "scan my local branch";
101103

src/main/java/com/checkmarx/intellij/CxIcons.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public static Icon getWelcomeMcpDisableIcon() {
2828
return IconLoader.getIcon("/icons/cxAIError.svg", CxIcons.class);
2929
}
3030

31+
public static Icon getCxOneAssistCubeIcon() {
32+
return IconLoader.getIcon("/icons/regular_dark.png", CxIcons.class);
33+
}
34+
3135
public static final Icon STAR_ACTION = IconLoader.getIcon("/icons/devassist/star-action.svg", CxIcons.class);
3236

3337
/**
@@ -84,4 +88,53 @@ private Small() {
8488
public static final Icon UNKNOWN = IconLoader.getIcon("/icons/devassist/severity_16/unknown.svg", CxIcons.class);
8589

8690
}
91+
92+
/**
93+
* Inner static final class for ignored tab icons with theme support.
94+
*/
95+
public static final class Ignored {
96+
97+
private Ignored() {
98+
}
99+
100+
public static final Icon REVIVE = IconLoader.getIcon("/icons/devassist/ignored/revive.svg", CxIcons.class);
101+
public static final Icon REVIVE_SELECTED = IconLoader.getIcon("/icons/devassist/ignored/revive-selected.svg", CxIcons.class);
102+
public static final Icon CLEAR_SELECTION = IconLoader.getIcon("/icons/devassist/ignored/clear-selection.svg", CxIcons.class);
103+
public static final Icon FILTER = IconLoader.getIcon("/icons/devassist/ignored/filter_icon.svg", CxIcons.class);
104+
public static final Icon SORT = IconLoader.getIcon("/icons/devassist/ignored/sort_icon.svg", CxIcons.class);
105+
public static final Icon FILE_ICON = IconLoader.getIcon("/icons/devassist/ignored/file-icon.svg", CxIcons.class);
106+
public static final Icon ENGINE_CHIP_CONTAINERS = IconLoader.getIcon("/icons/devassist/ignored/engine-chip-containers.svg", CxIcons.class);
107+
public static final Icon ENGINE_CHIP_SCA = IconLoader.getIcon("/icons/devassist/ignored/engine-chip-sca.svg", CxIcons.class);
108+
public static final Icon ENGINE_CHIP_SECRETS = IconLoader.getIcon("/icons/devassist/ignored/engine-chip-secrets.svg", CxIcons.class);
109+
public static final Icon ENGINE_CHIP_IAC = IconLoader.getIcon("/icons/devassist/ignored/engine-chip-iac.svg", CxIcons.class);
110+
public static final Icon ENGINE_CHIP_SAST = IconLoader.getIcon("/icons/devassist/ignored/engine-chip-sast.svg", CxIcons.class);
111+
112+
// Card icons - Containers
113+
public static final Icon CARD_CONTAINERS_CRITICAL = IconLoader.getIcon("/icons/devassist/ignored_card/card-containers-critical.svg", CxIcons.class);
114+
public static final Icon CARD_CONTAINERS_HIGH = IconLoader.getIcon("/icons/devassist/ignored_card/card-containers-high.svg", CxIcons.class);
115+
public static final Icon CARD_CONTAINERS_MEDIUM = IconLoader.getIcon("/icons/devassist/ignored_card/card-containers-medium.svg", CxIcons.class);
116+
public static final Icon CARD_CONTAINERS_LOW = IconLoader.getIcon("/icons/devassist/ignored_card/card-containers-low.svg", CxIcons.class);
117+
public static final Icon CARD_CONTAINERS_MALICIOUS = IconLoader.getIcon("/icons/devassist/ignored_card/card-containers-malicious.svg", CxIcons.class);
118+
119+
// Card icons - Package (OSS)
120+
public static final Icon CARD_PACKAGE_CRITICAL = IconLoader.getIcon("/icons/devassist/ignored_card/card-package-critical.svg", CxIcons.class);
121+
public static final Icon CARD_PACKAGE_HIGH = IconLoader.getIcon("/icons/devassist/ignored_card/card-package-high.svg", CxIcons.class);
122+
public static final Icon CARD_PACKAGE_MEDIUM = IconLoader.getIcon("/icons/devassist/ignored_card/card-package-medium.svg", CxIcons.class);
123+
public static final Icon CARD_PACKAGE_LOW = IconLoader.getIcon("/icons/devassist/ignored_card/card-package-low.svg", CxIcons.class);
124+
public static final Icon CARD_PACKAGE_MALICIOUS = IconLoader.getIcon("/icons/devassist/ignored_card/card-package-malicious.svg", CxIcons.class);
125+
126+
// Card icons - Secret
127+
public static final Icon CARD_SECRET_CRITICAL = IconLoader.getIcon("/icons/devassist/ignored_card/card-secret-critical.svg", CxIcons.class);
128+
public static final Icon CARD_SECRET_HIGH = IconLoader.getIcon("/icons/devassist/ignored_card/card-secret-high.svg", CxIcons.class);
129+
public static final Icon CARD_SECRET_MEDIUM = IconLoader.getIcon("/icons/devassist/ignored_card/card-secret-medium.svg", CxIcons.class);
130+
public static final Icon CARD_SECRET_LOW = IconLoader.getIcon("/icons/devassist/ignored_card/card-secret-low.svg", CxIcons.class);
131+
public static final Icon CARD_SECRET_MALICIOUS = IconLoader.getIcon("/icons/devassist/ignored_card/card-secret-malicious.svg", CxIcons.class);
132+
133+
// Card icons - Vulnerability (IAC/ASCA)
134+
public static final Icon CARD_VULNERABILITY_CRITICAL = IconLoader.getIcon("/icons/devassist/ignored_card/card-vulnerability-critical.svg", CxIcons.class);
135+
public static final Icon CARD_VULNERABILITY_HIGH = IconLoader.getIcon("/icons/devassist/ignored_card/card-vulnerability-high.svg", CxIcons.class);
136+
public static final Icon CARD_VULNERABILITY_MEDIUM = IconLoader.getIcon("/icons/devassist/ignored_card/card-vulnerability-medium.svg", CxIcons.class);
137+
public static final Icon CARD_VULNERABILITY_LOW = IconLoader.getIcon("/icons/devassist/ignored_card/card-vulnerability-low.svg", CxIcons.class);
138+
public static final Icon CARD_VULNERABILITY_MALICIOUS = IconLoader.getIcon("/icons/devassist/ignored_card/card-vulnerability-malicious.svg", CxIcons.class);
139+
}
87140
}

src/main/java/com/checkmarx/intellij/Resource.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,46 @@ public enum Resource {
154154
FAILED_OSS_SCAN_INITIALIZATION,
155155
DEV_ASSIST_COPY_FIX_PROMPT,
156156
DEV_ASSIST_COPY_VIEW_DETAILS_PROMPT,
157-
ASCA_LOGIN_REQUIRED
158-
}
157+
ASCA_LOGIN_REQUIRED,
158+
IGNORE_FAILED,
159+
IGNORE_SUCCESS,
160+
IGNORED_NO_FINDINGS,
161+
IGNORED_RISK_COLUMN,
162+
IGNORED_LAST_UPDATED_COLUMN,
163+
IGNORED_NO_FILES,
164+
IGNORED_MORE_FILES,
165+
IGNORED_LESS_FILES,
166+
IGNORED_FILE_NAV_ERROR,
167+
IGNORED_FILE_OPEN_ERROR,
168+
IGNORED_FILE_ERROR,
169+
IGNORED_UNKNOWN,
170+
IGNORED_TODAY,
171+
IGNORED_FILTER,
172+
IGNORED_VULNERABILITY_TYPE,
173+
IGNORED_SORT,
174+
IGNORED_SORT_BY,
175+
IGNORED_ORDER_BY,
176+
IGNORED_FILTER_SAST,
177+
IGNORED_FILTER_SCA,
178+
IGNORED_FILTER_SECRETS,
179+
IGNORED_FILTER_CONTAINERS,
180+
IGNORED_FILTER_IAC,
181+
IGNORED_SORT_SEVERITY_HIGH_LOW,
182+
IGNORED_SORT_SEVERITY_LOW_HIGH,
183+
IGNORED_SORT_LAST_UPDATED,
184+
IGNORED_ORDER_OLDEST_FIRST,
185+
IGNORED_ORDER_NEWEST_FIRST,
186+
IGNORED_DESCRIPTION_NOT_AVAILABLE,
187+
IGNORED_MALICIOUS_PACKAGE_DESC,
188+
REVIVE_FAILED,
189+
UPSELL_SCAN_RESULTS_TITLE,
190+
UPSELL_SCAN_RESULTS_DESCRIPTION,
191+
UPSELL_SCAN_RESULTS_BUTTON,
192+
UPSELL_DEV_ASSIST_TITLE,
193+
UPSELL_DEV_ASSIST_DESCRIPTION,
194+
UPSELL_DEV_ASSIST_CONTACT,
195+
FINDINGS_PROMO_TITLE,
196+
FINDINGS_PROMO_DESCRIPTION,
197+
FINDINGS_PROMO_LINK,
198+
DEVASSIST_DOC_LINK
199+
}

src/main/java/com/checkmarx/intellij/Utils.java

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55
import com.checkmarx.intellij.settings.global.GlobalSettingsState;
66
import com.intellij.dvcs.repo.Repository;
77
import com.intellij.dvcs.repo.VcsRepositoryManager;
8+
import com.intellij.ide.BrowserUtil;
9+
import com.intellij.icons.AllIcons;
10+
import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
811
import com.intellij.notification.Notification;
912
import com.intellij.notification.NotificationAction;
1013
import com.intellij.notification.NotificationGroupManager;
1114
import com.intellij.notification.NotificationType;
15+
import com.intellij.openapi.actionSystem.AnAction;
16+
import com.intellij.openapi.actionSystem.AnActionEvent;
1217
import com.intellij.openapi.application.ApplicationManager;
1318
import com.intellij.openapi.diagnostic.Logger;
1419
import com.intellij.openapi.project.Project;
1520
import com.intellij.openapi.project.ProjectManager;
1621
import com.intellij.openapi.ui.Messages;
1722
import com.intellij.util.messages.MessageBus;
1823
import org.apache.commons.collections.CollectionUtils;
24+
import org.jetbrains.annotations.NotNull;
1925
import org.jetbrains.annotations.Nullable;
2026

2127
import java.awt.*;
@@ -258,15 +264,64 @@ public static String getFileContentFromResource(String resourcePath) {
258264
* @param type - Notification type e.g., WARNING, ERROR, INFO etc.
259265
* @param project - Current project instance
260266
*/
261-
public static void showNotification(String title, String content, NotificationType type, Project project) {
262-
NotificationGroupManager.getInstance()
267+
public static void showNotification(String title, String content, NotificationType type, Project project,boolean displayDockLink, String dockLink) {
268+
Notification notification = NotificationGroupManager.getInstance()
263269
.getNotificationGroup(Constants.NOTIFICATION_GROUP_ID)
264270
.createNotification(title,
265271
content,
266-
type)
272+
type);
273+
274+
if(displayDockLink){
275+
notification.addAction(NotificationAction.createSimple("Go To documentation", () -> BrowserUtil.browse(dockLink)));
276+
}
277+
notification.notify(project);
278+
279+
}
280+
public static void showAppLevelNotification(
281+
String title,
282+
String content,
283+
NotificationType type,
284+
boolean displayDockLink,
285+
String dockLink
286+
) {
287+
Notification notification = NotificationGroupManager.getInstance()
288+
.getNotificationGroup(Constants.NOTIFICATION_GROUP_ID)
289+
.createNotification(title, content, type);
290+
291+
292+
if (displayDockLink) {
293+
notification.addAction(NotificationAction.createSimple(
294+
"Go To Documentation",
295+
() -> BrowserUtil.browse(dockLink)
296+
));
297+
}
298+
ApplicationManager.getApplication().invokeLater(() -> notification.notify(null));
299+
}
300+
301+
302+
public static String[] showUndoCloseNotification(String title, String content, NotificationType type, Project project) {
303+
final String[] result = {""};
304+
NotificationGroupManager.getInstance()
305+
.getNotificationGroup(Constants.NOTIFICATION_GROUP_ID)
306+
.createNotification(title, content, type)
307+
.addAction(new AnAction("Undo", "Undo the action", AllIcons.Actions.Undo) {
308+
@Override
309+
public void actionPerformed(@NotNull AnActionEvent e) {
310+
result[0] = "Undo";
311+
}
312+
})
313+
.addAction(new AnAction("Close", "Dismiss notification", AllIcons.Actions.Close) {
314+
@Override
315+
public void actionPerformed(@NotNull AnActionEvent e) {
316+
result[0] = "Close";
317+
318+
}
319+
})
267320
.notify(project);
321+
return result;
268322
}
269323

324+
270325
/**
271326
* Executing action with specified max retry attempts.
272327
* Before going for the every next retry attempt, it will increase delay time by specified delay milliseconds
@@ -322,7 +377,7 @@ public static void notifySessionExpired() {
322377
Utils.showNotification(Bundle.message(Resource.SESSION_EXPIRED_TITLE),
323378
Bundle.message(Resource.ERROR_SESSION_EXPIRED),
324379
NotificationType.ERROR,
325-
getCxProject())
380+
getCxProject(),false,"")
326381
);
327382
ApplicationManager.getApplication().invokeLater(() ->
328383
getMessageBus().syncPublisher(SettingsListener.SETTINGS_APPLIED).settingsApplied()

src/main/java/com/checkmarx/intellij/commands/TenantSetting.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.intellij.openapi.diagnostic.Logger;
88

99
import java.io.IOException;
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
1013

1114
/**
1215
* Handle tenant settings related operations with the wrapper
@@ -15,6 +18,20 @@ public class TenantSetting {
1518

1619
private static final Logger LOG = Logger.getInstance(TenantSetting.class);
1720

21+
/**
22+
* Check if the user is currently authenticated.
23+
*
24+
* @return true if user is authenticated, false otherwise
25+
*/
26+
public static boolean isAuthenticated() {
27+
try {
28+
return GlobalSettingsState.getInstance().isAuthenticated();
29+
} catch (Exception e) {
30+
LOG.warn("Failed to check authentication status", e);
31+
return false;
32+
}
33+
}
34+
1835
/**
1936
* Check if current tenant has permissions to scan from the IDE
2037
*
@@ -40,4 +57,29 @@ public static boolean isAiMcpServerEnabled(GlobalSettingsState state, GlobalSett
4057
return CxWrapperFactory.build(state, sensitiveState).aiMcpServerEnabled();
4158
}
4259

60+
/**
61+
* Get all tenant settings as a Map.
62+
* Uses the provided GlobalSettingsState and GlobalSettingsSensitiveState for authentication.
63+
*
64+
* @param state GlobalSettingsState object contains current plugin state
65+
* @param sensitiveState GlobalSettingsSensitiveState object contains encrypted credentials
66+
* @return Map of tenant setting keys to their values
67+
*/
68+
public static Map<String, String> getTenantSettingsMap(GlobalSettingsState state, GlobalSettingsSensitiveState sensitiveState) throws
69+
IOException,
70+
CxException,
71+
InterruptedException {
72+
LOG.debug("Fetching tenant settings map using provided credentials");
73+
List<com.checkmarx.ast.tenant.TenantSetting> settings = CxWrapperFactory.build(state, sensitiveState).tenantSettings();
74+
Map<String, String> settingsMap = new HashMap<>();
75+
for (com.checkmarx.ast.tenant.TenantSetting setting : settings) {
76+
settingsMap.put(setting.getKey(), setting.getValue());
77+
}
78+
LOG.debug("Fetched tenant settings map using provided credentials: " + settingsMap);
79+
return settingsMap;
80+
}
81+
82+
// Tenant setting keys for license flags - public for use in GlobalSettingsComponent
83+
public static final String KEY_DEV_ASSIST = "scan.config.plugins.cxdevassist";
84+
public static final String KEY_ONE_ASSIST = "scan.config.plugins.cxoneassist";
4385
}

src/main/java/com/checkmarx/intellij/devassist/basescanner/BaseScannerCommand.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
* managing a scanner's lifecycle for a given project. This class serves as a
2121
* base implementation for custom scanner commands.
2222
*/
23-
public class BaseScannerCommand implements ScannerCommand {
23+
public abstract class BaseScannerCommand implements ScannerCommand {
2424
private static final Logger LOGGER = Utils.getLogger(BaseScannerCommand.class);
2525
public ScannerConfig config;
2626

27-
public BaseScannerCommand(@NotNull Disposable parentDisposable, ScannerConfig config) {
27+
protected BaseScannerCommand(@NotNull Disposable parentDisposable, ScannerConfig config) {
2828
Disposer.register(parentDisposable, this);
2929
this.config = config;
3030
}
@@ -103,8 +103,11 @@ protected VirtualFile findVirtualFile(String path) {
103103
return LocalFileSystem.getInstance().findFileByPath(path);
104104
}
105105

106-
protected void initializeScanner() {
107-
}
106+
/**
107+
* Abstract method to initialize the scanner
108+
* This method is invoked when the scanner is registered for the project
109+
*/
110+
protected abstract void initializeScanner();
108111

109112
@Override
110113
public void dispose() {

src/main/java/com/checkmarx/intellij/devassist/configuration/ScannerLifeCycleManager.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.checkmarx.intellij.devassist.configuration;
22

3+
import com.checkmarx.intellij.devassist.inspection.CxOneAssistInspectionMgr;
34
import com.checkmarx.intellij.devassist.registry.ScannerRegistry;
5+
import com.checkmarx.intellij.devassist.utils.ScanEngine;
46
import com.intellij.openapi.Disposable;
57
import com.intellij.openapi.components.Service;
68
import com.intellij.openapi.project.Project;
7-
import com.checkmarx.intellij.devassist.utils.ScanEngine;
89
import lombok.Getter;
910
import org.jetbrains.annotations.NotNull;
1011

1112
/**
12-
* ScannerLifeCycleManager is Project level service i.e it is distinct for each project
13+
* ScannerLifeCycleManager is a Project level service i.e., it is distinct for each project
1314
* Manages the Lifecycle of Scanner for the project
14-
* Triggers the Start and Stop of the Scanner for Project based on global settings
15+
* Triggers the Start and Stop of the Scanner for Project based on global settings
1516
*/
1617

1718
@Getter
@@ -53,6 +54,7 @@ public synchronized void updateFromGlobal(@NotNull GlobalScannerController contr
5354
if (isEnabled) start(type);
5455
else stop(type);
5556
}
57+
startInspection();
5658
}
5759

5860
/**
@@ -80,10 +82,26 @@ public void stopAll() {
8082
for (ScanEngine type : ScanEngine.values()) {
8183
stop(type);
8284
}
85+
startInspection();
8386
}
8487

8588
@Override
8689
public void dispose() {
8790
stopAll();
8891
}
92+
93+
/**
94+
* Initiates the inspection process for the project by triggering an inspection
95+
* through the CxOneAssistInspectionMgr service.
96+
* <p>
97+
* This method acts as a utility to start a project-wide inspection
98+
* and is invoked during lifecycle changes such as starting or stopping
99+
* scanners to ensure the latest state is reflected in inspection results.
100+
* <p>
101+
* The inspection manager operates at the project scope and is
102+
* dependent on the current project's context.
103+
*/
104+
private void startInspection() {
105+
new CxOneAssistInspectionMgr().triggerInspection(project);
106+
}
89107
}

0 commit comments

Comments
 (0)