Skip to content

Commit

Permalink
Fix PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
talarian1 committed Oct 3, 2023
1 parent 9b47eeb commit 7c8ee3a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
public class SastScannerExecutor extends ScanBinaryExecutor {
private static final List<String> SCANNER_ARGS = List.of("zd");
// This variable is used to indicate that this scanner support only the new config (input) format.
// This variable is used to indicate that this scanner supports only the new config (input) format.
// In the near future, when all scanners will use only the new input file structure this variable as well
// as the ScanConfig and ScanConfigs classes can be safely removed.
private static final boolean RUN_WITH_NEW_CONFIG_FILE = true;
Expand Down Expand Up @@ -60,7 +60,7 @@ List<FileTreeNode> createSpecificFileIssueNodes(List<JFrogSecurityWarning> warni

@Override
public Feature getScannerFeatureName() {
// TODO: change to SASST feature when Xray entitlement service support it.
// TODO: change to SAST feature when Xray entitlement service supports it.
return Feature.CONTEXTUAL_ANALYSIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class SourceCodeScannerManager {

public SourceCodeScannerManager(Project project) {
this.project = project;
jfrogApplictionsConfigPath = getProjectBasePath(project).resolve(".jfrog").resolve("jfrog-apps-config.yml");
this.jfrogApplictionsConfigPath = getProjectBasePath(project).resolve(".jfrog").resolve("jfrog-apps-config.yml");
}

public SourceCodeScannerManager(Project project, PackageManagerType packageType) {
Expand Down Expand Up @@ -154,12 +154,8 @@ private void sourceCodeScanAndUpdate(ProgressIndicator indicator, Runnable check
indicator.setText("Running advanced source code scanning");
JFrogApplicationsConfig projectConfig = parseJFrogApplicationsConfig();

if (projectConfig != null) {
for (ModuleConfig moduleConfig : projectConfig.getModules()) {
scan(moduleConfig, indicator, checkCanceled, log);
}
} else {
scan(null, indicator, checkCanceled, log);
for (ModuleConfig moduleConfig : projectConfig.getModules()) {
scan(moduleConfig, indicator, checkCanceled, log);
}
}

Expand Down Expand Up @@ -196,7 +192,7 @@ private JFrogApplicationsConfig parseJFrogApplicationsConfig() throws IOExceptio
if (config.exists()) {
return mapper.readValue(config, JFrogApplicationsConfig.class);
}
return null;
return new JFrogApplicationsConfig(true);
}

private void addSourceCodeScanResults(List<FileTreeNode> fileTreeNodes) {
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/jfrog/ide/idea/scan/data/NewScansConfig.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package com.jfrog.ide.idea.scan.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class NewScansConfig {
@JsonProperty("scans")
private List<NewScanConfig> scans;

@SuppressWarnings("unused")
public NewScansConfig() {
}

public NewScansConfig(NewScanConfig scan) {
this.scans = List.of(scan);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package com.jfrog.ide.idea.scan.data.applications;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Getter
@NoArgsConstructor
public class JFrogApplicationsConfig {
@JsonProperty("version")
private String version;
@JsonProperty("modules")
private List<ModuleConfig> modules;
@JsonProperty("version")
private String version;
@JsonProperty("modules")
private List<ModuleConfig> modules;

public String getVersion() {
return this.version;
}
public JFrogApplicationsConfig(boolean createEmptyModules) {
if (createEmptyModules) {
modules = new ArrayList<>();
modules.add(new ModuleConfig());
}
}

public List<ModuleConfig> getModules() {
return this.modules;
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
package com.jfrog.ide.idea.scan.data.applications;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

import java.util.List;
import java.util.Map;

@Getter
public class ModuleConfig {
@JsonProperty("name")
private String name;
@JsonProperty("source_root")
private String sourceRoot;
@JsonProperty("exclude_patterns")
private List<String> excludePatterns;
@JsonProperty("exclude_scanners")
private List<String> excludeScanners;
@JsonProperty("scanners")
private Map<String, ScannerConfig> scanners;

public String getName() {
return this.name;
}

public String getSourceRoot() {
return this.sourceRoot;
}

public List<String> getExcludePatterns() {
return this.excludePatterns;
}

public List<String> getExcludeScanners() {
return this.excludeScanners;
}
@JsonProperty("name")
private String name;
@JsonProperty("source_root")
private String sourceRoot;
@JsonProperty("exclude_patterns")
private List<String> excludePatterns;
@JsonProperty("exclude_scanners")
private List<String> excludeScanners;
@JsonProperty("scanners")
private Map<String, ScannerConfig> scanners;

public Map<String, ScannerConfig> getScanners() {
return this.scanners;
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
package com.jfrog.ide.idea.scan.data.applications;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

import java.util.List;

@Getter
public class ScannerConfig {
@JsonProperty("language")
private String language;
@JsonProperty("working_dirs")
private List<String> workingDirs;
@JsonProperty("exclude_patterns")
private List<String> excludePatterns;
@JsonProperty("excluded_rules")
private List<String> excludedRules;

public String getLanguage() {
return this.language;
}

public List<String> getWorkingDirs() {
return this.workingDirs;
}

public List<String> getExcludePatterns() {
return this.excludePatterns;
}
@JsonProperty("language")
private String language;
@JsonProperty("working_dirs")
private List<String> workingDirs;
@JsonProperty("exclude_patterns")
private List<String> excludePatterns;
@JsonProperty("excluded_rules")
private List<String> excludedRules;

public List<String> getExcludedRules() {
return this.excludedRules;
}
}

0 comments on commit 7c8ee3a

Please sign in to comment.