Skip to content

Commit 36872e6

Browse files
Add ignoredFilePath parameter to ScanAsca method
1 parent 13c6f10 commit 36872e6

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public List<Project> projectList(String filter) throws IOException, InterruptedE
248248
return Execution.executeCommand(withConfigArguments(arguments), logger, Project::listFromLine);
249249
}
250250

251-
public ScanResult ScanAsca(String fileSource, boolean ascaLatestVersion, String agent) throws IOException, InterruptedException, CxException {
251+
public ScanResult ScanAsca(String fileSource, boolean ascaLatestVersion, String agent, String ignoredFilePath) throws IOException, InterruptedException, CxException {
252252
this.logger.info("Fetching ASCA scanResult");
253253

254254
List<String> arguments = new ArrayList<>();
@@ -259,6 +259,10 @@ public ScanResult ScanAsca(String fileSource, boolean ascaLatestVersion, String
259259
if (ascaLatestVersion) {
260260
arguments.add(CxConstants.ASCA_LATEST_VERSION);
261261
}
262+
if (StringUtils.isNotBlank(ignoredFilePath)) {
263+
arguments.add(CxConstants.IGNORED_FILE_PATH);
264+
arguments.add(ignoredFilePath);
265+
}
262266

263267
appendAgentToArguments(agent, arguments);
264268

@@ -540,8 +544,8 @@ public MaskResult maskSecrets(@NonNull String filePath) throws CxException, IOEx
540544
/**
541545
* Executes telemetry AI command to collect telemetry data for user interactions related to AI features.
542546
*
543-
* @param aiProvider AI provider name (e.g., "Cursor")
544-
* @param agent Agent name
547+
* @param aiProvider AI provider name (e.g., "Copilot")
548+
* @param agent Agent name (e.g., "Jetbrains")
545549
* @param eventType Event type (e.g., "click")
546550
* @param subType Event subtype (e.g., "ast-results.viewPackageDetails")
547551
* @param engine Engine type (e.g., "secrets")

src/test/java/com/checkmarx/ast/ScanTest.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void testScanShow() throws Exception {
2525

2626
@Test
2727
void testScanAsca_WhenFileWithVulnerabilitiesIsSentWithAgent_ReturnSuccessfulResponseWithCorrectValues() throws Exception {
28-
ScanResult scanResult = wrapper.ScanAsca("src/test/resources/python-vul-file.py", true, "vscode");
28+
ScanResult scanResult = wrapper.ScanAsca("src/test/resources/python-vul-file.py", true, "vscode", null);
2929

3030
// Assertions for the scan result
3131
Assertions.assertNotNull(scanResult.getRequestId(), "Request ID should not be null");
@@ -46,7 +46,7 @@ void testScanAsca_WhenFileWithVulnerabilitiesIsSentWithAgent_ReturnSuccessfulRes
4646

4747
@Test
4848
void testScanAsca_WhenFileWithoutVulnerabilitiesIsSent_ReturnSuccessfulResponseWithCorrectValues() throws Exception {
49-
ScanResult scanResult = wrapper.ScanAsca("src/test/resources/csharp-no-vul.cs", true, null);
49+
ScanResult scanResult = wrapper.ScanAsca("src/test/resources/csharp-no-vul.cs", true, null, null);
5050
Assertions.assertNotNull(scanResult.getRequestId());
5151
Assertions.assertTrue(scanResult.isStatus());
5252
Assertions.assertNull(scanResult.getError());
@@ -55,12 +55,25 @@ void testScanAsca_WhenFileWithoutVulnerabilitiesIsSent_ReturnSuccessfulResponseW
5555

5656
@Test
5757
void testScanAsca_WhenMissingFileExtension_ReturnFileExtensionIsRequiredFailure() throws Exception {
58-
ScanResult scanResult = wrapper.ScanAsca("CODEOWNERS", true, null);
58+
ScanResult scanResult = wrapper.ScanAsca("CODEOWNERS", true, null, null);
5959
Assertions.assertNotNull(scanResult.getRequestId());
6060
Assertions.assertNotNull(scanResult.getError());
6161
Assertions.assertEquals("The file name must have an extension.", scanResult.getError().getDescription());
6262
}
6363

64+
@Test
65+
void testScanAsca_WithIgnoreFilePath_ShouldWorkCorrectly() throws Exception {
66+
String ignoreFile = "src/test/resources/ignored-packages.json";
67+
68+
// Test with ignore file - should not break the scanning process
69+
ScanResult scanResult = wrapper.ScanAsca("src/test/resources/python-vul-file.py", true, "test-agent", ignoreFile);
70+
71+
// Verify the scan completes successfully
72+
Assertions.assertNotNull(scanResult.getRequestId(), "Request ID should not be null");
73+
Assertions.assertTrue(scanResult.isStatus(), "Status should be true");
74+
Assertions.assertNull(scanResult.getError(), "Error should be null when scan is successful");
75+
}
76+
6477
@Test
6578
void testScanList() throws Exception {
6679
List<Scan> cxOutput = wrapper.scanList("limit=10");

0 commit comments

Comments
 (0)