Skip to content

Commit

Permalink
added the jas scanner
Browse files Browse the repository at this point in the history
directed the common to local
added jas to the scan factory
  • Loading branch information
eyalk007 committed Aug 25, 2024
1 parent ce0eb4a commit 17039a9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def idePluginsCommonVersion = '2.3.6'
dependencies {
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.15.2'
implementation group: 'org.jfrog.buildinfo', name: 'build-info-extractor', version: buildInfoVersion
implementation group: 'com.jfrog.ide', name: 'ide-plugins-common', version: idePluginsCommonVersion
implementation files('../ide-plugins-common/build/libs/ide-plugins-common-2.3.x-SNAPSHOT.jar')
implementation group: 'org.jfrog.buildinfo', name: 'build-info-client', version: buildInfoVersion
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.2'
implementation group: 'org.jfrog.buildinfo', name: 'build-info-api', version: buildInfoVersion
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/jfrog/ide/idea/scan/JasScanExecutor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.jfrog.ide.idea.scan;

import com.jfrog.ide.common.log.ProgressIndicator;
import com.jfrog.ide.common.nodes.FileIssueNode;
import com.jfrog.ide.common.nodes.FileTreeNode;
import com.jfrog.ide.common.nodes.subentities.SourceCodeScanType;
import com.jfrog.ide.idea.inspections.JFrogSecurityWarning;
import com.jfrog.ide.idea.scan.data.ScanConfig;
import com.jfrog.xray.client.services.entitlements.Feature;
import org.jfrog.build.api.util.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class JasScanExecutor extends ScanBinaryExecutor {
private static final List<String> SCANNER_ARGS = List.of("jas");

public JasScanExecutor(Log log) {
super(SourceCodeScanType.valueOf("jas"), log);
}

@Override
Feature getScannerFeatureName() {
return Feature.CONTEXTUAL_ANALYSIS;
}

@Override
public List<JFrogSecurityWarning> execute(ScanConfig.Builder inputFileBuilder, Runnable checkCanceled, ProgressIndicator indicator) throws IOException, InterruptedException {
return super.execute(inputFileBuilder, SCANNER_ARGS, checkCanceled, indicator);
}

@Override
List<FileTreeNode> createSpecificFileIssueNodes(List<JFrogSecurityWarning> warnings) {
HashMap<String, FileTreeNode> results = new HashMap<>();
for (JFrogSecurityWarning warning : warnings) {
// Create FileTreeNodes for files with found issues
FileTreeNode fileNode = results.get(warning.getFilePath());
if (fileNode == null) {
fileNode = new FileTreeNode(warning.getFilePath());
results.put(warning.getFilePath(), fileNode);
}

FileIssueNode issueNode = new FileIssueNode("jas scanner",
warning.getFilePath(), warning.getLineStart(), warning.getColStart(), warning.getLineEnd(), warning.getColEnd(),
warning.getScannerSearchTarget(), warning.getLineSnippet(), warning.getReporter(), warning.getSeverity(), warning.getRuleID());
fileNode.addIssue(issueNode);
}
return new ArrayList<>(results.values()); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class ScanBinaryExecutor {
private static final int USER_NOT_ENTITLED = 31;
private static final int NOT_SUPPORTED = 13;
private static final String SCANNER_BINARY_NAME = "analyzerManager";
private static final String SCANNER_BINARY_VERSION = "1.6.3";
private static final String SCANNER_BINARY_VERSION = "1.8.13";
private static final String BINARY_DOWNLOAD_URL = "xsc-gen-exe-analyzer-manager-local/v1/" + SCANNER_BINARY_VERSION;
private static final String DOWNLOAD_SCANNER_NAME = "analyzerManager.zip";
private static final String MINIMAL_XRAY_VERSION_SUPPORTED_FOR_ENTITLEMENT = "3.66.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ private Map<SourceCodeScanType, ScanBinaryExecutor> initScannersCollection() {
scanners.put(SourceCodeScanType.SECRETS, new SecretsScannerExecutor(Logger.getInstance()));
scanners.put(SourceCodeScanType.IAC, new IACScannerExecutor(Logger.getInstance()));
scanners.put(SourceCodeScanType.SAST, new SastScannerExecutor(Logger.getInstance()));
scanners.put(SourceCodeScanType.JAS, new JasScanExecutor(Logger.getInstance()));
return scanners;
}

Expand Down

0 comments on commit 17039a9

Please sign in to comment.