Skip to content
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/ui/*.java"
./mvnw verify -Dtest.includes="**/ui/*.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/integration/*Test.java"
./mvnw verify -Dtest.includes="**/integration/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn clean verify -Dtest.includes="**/unit/**/*Test.java"
./mvnw clean verify -Dtest.includes="**/unit/**/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ jobs:
- name: Update the POM version
env:
VERSION: ${{ inputs.tag }}
run: mvn -B org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="${VERSION}" --file pom.xml
run: ./mvnw -B org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="${VERSION}" --file pom.xml

- name: Create release
run: mvn -B clean install --file pom.xml -DskipTests -pl "!checkmarx-ast-eclipse-plugin-tests"
run: ./mvnw -B clean install --file pom.xml -DskipTests -pl "!checkmarx-ast-eclipse-plugin-tests"

- name: Extract CLI version
id: extract_cli_version
Expand Down
20 changes: 20 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
distributionSha256Sum=4ec3f26fb1a692473aea0235c300bd20f0f9fe741947c82c1234cefd76ac3a3c
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,14 @@ void testEnumOrdinal_correctSequence() {
@Test
void testValues_returnsAllConstants() {
Severity[] values = Severity.values();
assertEquals(8, values.length);
assertEquals(6, values.length);
}

@Test
void testValues_containsAllExpected() {
Severity[] values = Severity.values();
boolean hasCritical = false;
boolean hasHigh = false;
boolean hasLow = false;
boolean hasGroupBy = false;

for (Severity s : values) {
if (s == Severity.CRITICAL) hasCritical = true;
if (s == Severity.HIGH) hasHigh = true;
if (s == Severity.LOW) hasLow = true;
}

assertTrue(hasCritical);
assertTrue(hasHigh);
assertTrue(hasLow);
assertTrue(hasGroupBy);
// Grouping modes live in GroupingMode; Severity holds only real severity levels
assertArrayEquals(new Severity[] { Severity.CRITICAL, Severity.HIGH, Severity.MEDIUM, Severity.LOW,
Severity.INFO, Severity.MALICIOUS }, Severity.values());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ void testGetSeverity_roundTrip_allValues() {

@Test
void testEnumValues_count() {
assertEquals(8, Severity.values().length);
assertEquals(6, Severity.values().length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,49 @@

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.jface.preference.IPreferenceStore;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.MockitoAnnotations;

import com.checkmarx.eclipse.Activator;
import com.checkmarx.eclipse.common.preferences.Preferences;

class PreferencesTest {

@Mock
private IPreferencesService mockPreferencesService;

@Mock
private IPreferenceStore mockPreferenceStore;

@Mock
private Activator mockActivator;
private static final String KEY_PREFIX = "preferencesTest.";

private MockedStatic<Platform> platformMock;
private MockedStatic<Activator> activatorMock;

@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
platformMock = mockStatic(Platform.class);
activatorMock = mockStatic(Activator.class);
}

@AfterEach
void tearDown() {
if (platformMock != null) {
platformMock.close();
}
if (activatorMock != null) {
activatorMock.close();
for (String key : new String[] { "testKey", "key1", "key2" }) {
Preferences.STORE.setToDefault(KEY_PREFIX + key);
}
}

/**
* Preferences.store writes to the real ScopedPreferenceStore, which reads
* through Platform.getPreferencesService(), so the Platform mock must be released.
*/
private void useRealPlatform() {
platformMock.close();
platformMock = null;
}

@Test
void testGetPref_returnsValue() {
platformMock.when(Platform::getPreferencesService).thenReturn(mockPreferencesService);
Expand Down Expand Up @@ -118,33 +119,29 @@ void testGetAdditionalOptions_returnNull_whenNotSet() {

@Test
void testStore_setsValueInPreferenceStore() {
activatorMock.when(Activator::getDefault).thenReturn(mockActivator);
when(mockActivator.getPreferenceStore()).thenReturn(mockPreferenceStore);
useRealPlatform();

Preferences.store("testKey", "testValue");
Preferences.store(KEY_PREFIX + "testKey", "testValue");

verify(mockActivator).getPreferenceStore();
verify(mockPreferenceStore).setValue("testKey", "testValue");
assertEquals("testValue", Preferences.STORE.getString(KEY_PREFIX + "testKey"));
}

@Test
void testStore_withEmptyValue() {
activatorMock.when(Activator::getDefault).thenReturn(mockActivator);
when(mockActivator.getPreferenceStore()).thenReturn(mockPreferenceStore);
useRealPlatform();
Preferences.store(KEY_PREFIX + "testKey", "testValue");

Preferences.store("testKey", "");
Preferences.store(KEY_PREFIX + "testKey", "");

verify(mockPreferenceStore).setValue("testKey", "");
assertEquals("", Preferences.STORE.getString(KEY_PREFIX + "testKey"));
}

@Test
void testStore_withNullValue() {
activatorMock.when(Activator::getDefault).thenReturn(mockActivator);
when(mockActivator.getPreferenceStore()).thenReturn(mockPreferenceStore);

Preferences.store("testKey", null);
void testStore_withNullValue_throws() {
useRealPlatform();

verify(mockPreferenceStore).setValue("testKey", null);
// Eclipse preference nodes reject null values
assertThrows(NullPointerException.class, () -> Preferences.store(KEY_PREFIX + "testKey", null));
}

@Test
Expand Down Expand Up @@ -179,13 +176,12 @@ void testGetPref_multipleCallsWithDifferentKeys() {

@Test
void testStore_multipleValuesSequentially() {
activatorMock.when(Activator::getDefault).thenReturn(mockActivator);
when(mockActivator.getPreferenceStore()).thenReturn(mockPreferenceStore);
useRealPlatform();

Preferences.store("key1", "value1");
Preferences.store("key2", "value2");
Preferences.store(KEY_PREFIX + "key1", "value1");
Preferences.store(KEY_PREFIX + "key2", "value2");

verify(mockPreferenceStore).setValue("key1", "value1");
verify(mockPreferenceStore).setValue("key2", "value2");
assertEquals("value1", Preferences.STORE.getString(KEY_PREFIX + "key1"));
assertEquals("value2", Preferences.STORE.getString(KEY_PREFIX + "key2"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
import com.checkmarx.eclipse.enums.ActionName;
import com.checkmarx.eclipse.views.DataProvider;

import com.checkmarx.eclipse.enums.GroupingMode;
import com.checkmarx.eclipse.enums.PluginListenerType;
import com.checkmarx.eclipse.common.enums.Severity;
import com.checkmarx.eclipse.views.DisplayModel;
import com.checkmarx.eclipse.views.PluginListenerDefinition;
import com.checkmarx.eclipse.views.actions.ToolBarActions;
import com.checkmarx.eclipse.views.GlobalSettings;
import com.checkmarx.eclipse.views.filters.FilterState;
import com.google.common.eventbus.EventBus;

Expand Down Expand Up @@ -137,6 +139,9 @@ void testRefreshToolbarRecreatesActions() {
void testGroupBySeverityAction() {
// createGroupByActions() runs inside a background Job so we test the toggle directly.
FilterState.groupBySeverity = false;
try (MockedStatic<GlobalSettings> gs = Mockito.mockStatic(GlobalSettings.class)) {
FilterState.setGroupingMode(GroupingMode.SEVERITY);
}
assertTrue(FilterState.groupBySeverity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.mockito.MockitoAnnotations;

import com.checkmarx.eclipse.common.enums.Severity;
import com.checkmarx.eclipse.enums.GroupingMode;
import com.checkmarx.eclipse.enums.State;
import com.checkmarx.eclipse.views.GlobalSettings;
import com.checkmarx.eclipse.views.filters.FilterState;
Expand Down Expand Up @@ -87,6 +88,7 @@ void testSetState_groupBySeverityToggle() {
boolean beforeState = FilterState.groupBySeverity;

try (MockedStatic<GlobalSettings> mockSettings = mockStatic(GlobalSettings.class)) {
FilterState.setGroupingMode(GroupingMode.SEVERITY);
assertNotEquals(beforeState, FilterState.groupBySeverity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.mockito.Mockito;

import com.checkmarx.eclipse.common.enums.Severity;
import com.checkmarx.eclipse.enums.GroupingMode;
import com.checkmarx.eclipse.enums.State;
import com.checkmarx.eclipse.views.GlobalSettings;
import com.checkmarx.eclipse.views.filters.FilterState;
Expand Down Expand Up @@ -136,6 +137,7 @@ void testSetState_info_togglesFromFalse() {
void testSetState_groupBySeverity_toggles() {
FilterState.groupBySeverity = true;
try (MockedStatic<GlobalSettings> gs = Mockito.mockStatic(GlobalSettings.class)) {
FilterState.setGroupingMode(GroupingMode.SEVERITY);
}
assertFalse(FilterState.groupBySeverity);
}
Expand All @@ -144,6 +146,7 @@ void testSetState_groupBySeverity_toggles() {
void testSetState_groupByQueryName_toggles() {
FilterState.groupByQueryName = false;
try (MockedStatic<GlobalSettings> gs = Mockito.mockStatic(GlobalSettings.class)) {
FilterState.setGroupingMode(GroupingMode.QUERY_NAME);
}
assertTrue(FilterState.groupByQueryName);
}
Expand All @@ -152,6 +155,7 @@ void testSetState_groupByQueryName_toggles() {
void testSetState_groupByStateName_toggles() {
FilterState.groupByStateName = false;
try (MockedStatic<GlobalSettings> gs = Mockito.mockStatic(GlobalSettings.class)) {
FilterState.setGroupingMode(GroupingMode.STATE_NAME);
}
assertTrue(FilterState.groupByStateName);
}
Expand Down
2 changes: 1 addition & 1 deletion checkmarx-ast-eclipse-plugin/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</classpathentry>
<classpathentry exported="true" kind="lib" path="../common-lib/lib/ast-cli-java-wrapper-2.4.31.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/commons-lang3-3.18.0.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-core-2.21.4.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-core-2.21.7.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-databind-2.21.5.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-annotations-2.21.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/slf4j-api-2.0.17.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion common-lib/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/ast-cli-java-wrapper-2.4.31.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.18.0.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.21.4.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.21.7.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.21.5.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.21.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-2.0.17.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion common-lib/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Checkmarx
Bundle-ClassPath: .,
lib/ast-cli-java-wrapper-2.4.31.jar,
lib/jackson-core-2.21.4.jar,
lib/jackson-core-2.21.7.jar,
lib/jackson-databind-2.21.5.jar,
lib/jackson-annotations-2.21.jar,
lib/slf4j-api-2.0.17.jar,
Expand Down
2 changes: 1 addition & 1 deletion common-lib/build.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
output.. = bin/
bin.includes = META-INF/,\
lib/ast-cli-java-wrapper-2.4.31.jar,\
lib/jackson-core-2.21.4.jar,\
lib/jackson-core-2.21.7.jar,\
lib/jackson-databind-2.21.5.jar,\
lib/jackson-annotations-2.21.jar,\
lib/slf4j-api-2.0.17.jar,\
Expand Down
3 changes: 0 additions & 3 deletions common-lib/lib/jackson-core-2.21.4.jar

This file was deleted.

3 changes: 3 additions & 0 deletions common-lib/lib/jackson-core-2.21.7.jar
Git LFS file not shown
2 changes: 1 addition & 1 deletion devassist-lib/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="../common-lib/lib/ast-cli-java-wrapper-2.4.31.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/commons-lang3-3.18.0.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-core-2.21.4.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-core-2.21.7.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-databind-2.21.5.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/jackson-annotations-2.21.jar"/>
<classpathentry kind="lib" path="../common-lib/lib/slf4j-api-2.0.17.jar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
Expand Down Expand Up @@ -54,6 +56,7 @@ public final class McpSettingsInjector {
private static final String LOG_TAG = "[MCP-INJECTOR]";
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final String FALLBACK_BASE = "https://ast-master-components.dev.cxast.net";
private static final Pattern IAM_HOST_LABEL = Pattern.compile("(^|\\.)iam\\.");
private static final String SERVER_KEY = "checkmarx";
public static final String MCP_ENDPOINT = "/api/security-mcp/mcp";

Expand Down Expand Up @@ -297,7 +300,7 @@ private static String tryExtractIssuer(String rawToken) {
/**
* Derives AST base URL from issuer claim.
* If issuer is like https://iam.checkmarx.com, converts to
* https://ast.checkmarx.com
* https://ast.checkmarx.com; otherwise (single-tenant) uses the issuer host.
*/
private static String deriveBaseUrlFromIssuer(String issuer) {
if (issuer == null || issuer.isBlank()) {
Expand All @@ -309,15 +312,15 @@ private static String deriveBaseUrlFromIssuer(String issuer) {
CxLogger.info(LOG_TAG + " Deriving base URL from issuer: " + issuer);
String host = URI.create(issuer).getHost();

if (host != null && host.contains("iam.checkmarx")) {
String newHost = host.replace("iam", "ast");
String baseUrl = "https://" + newHost;
CxLogger.info(LOG_TAG + "Derived base URL: " + baseUrl);
return baseUrl;
if (host == null || host.isBlank()) {
CxLogger.info(LOG_TAG + " Issuer has no host, using fallback");
return FALLBACK_BASE;
}

CxLogger.info(LOG_TAG + " Host does not match iam.checkmarx pattern, using fallback");
return FALLBACK_BASE;
// Multi-tenant: swap only the "iam" host label (e.g. eu.iam.checkmarx.net -> eu.ast.checkmarx.net).
// Single-tenant: the issuer host is the tenant base URL.
Matcher iamLabel = IAM_HOST_LABEL.matcher(host);
return "https://" + (iamLabel.find() ? iamLabel.replaceFirst("$1ast.") : host);
} catch (Exception e) {
CxLogger.warning(LOG_TAG + " Failed to derive base URL from issuer: " + e.getMessage());
return FALLBACK_BASE;
Expand Down
Loading
Loading