Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EOS entities #130

Merged
merged 9 commits into from
Aug 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class ApplicableIssueNode extends FileIssueNode {
private ApplicableIssueNode() {
}

public ApplicableIssueNode(String name, int rowStart, int colStart, int rowEnd, int colEnd, String filePath, String reason, String lineSnippet, String scannerSearchTarget, VulnerabilityNode issue) {
super(name, filePath, rowStart, colStart, rowEnd, colEnd, reason, lineSnippet, SourceCodeScanType.CONTEXTUAL, issue.getSeverity());
public ApplicableIssueNode(String name, int rowStart, int colStart, int rowEnd, int colEnd, String filePath, String reason, String lineSnippet, String scannerSearchTarget, VulnerabilityNode issue, String ruleID) {
super(name, filePath, rowStart, colStart, rowEnd, colEnd, reason, lineSnippet, SourceCodeScanType.CONTEXTUAL, issue.getSeverity(), ruleID);
this.scannerSearchTarget = scannerSearchTarget;
this.issue = issue;
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/jfrog/ide/common/nodes/EosIssueNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.jfrog.ide.common.nodes;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.jfrog.ide.common.nodes.subentities.FindingInfo;
import com.jfrog.ide.common.nodes.subentities.Severity;
import com.jfrog.ide.common.nodes.subentities.SourceCodeScanType;
import lombok.Getter;

@Getter
public class EosIssueNode extends FileIssueNode {
@JsonProperty()
private FindingInfo[][] codeFlows;

// Empty constructor for deserialization
@SuppressWarnings("unused")
private EosIssueNode() {
}

public EosIssueNode(String name, String filePath, int rowStart, int colStart, int rowEnd, int colEnd, String reason, String lineSnippet, FindingInfo[][] codeFlows, Severity severity, String ruleID) {
super(name, filePath, rowStart, colStart, rowEnd, colEnd, reason, lineSnippet, SourceCodeScanType.EOS, severity, ruleID);
this.codeFlows = codeFlows;
}
}
61 changes: 21 additions & 40 deletions src/main/java/com/jfrog/ide/common/nodes/FileIssueNode.java
Original file line number Diff line number Diff line change
@@ -1,93 +1,72 @@
package com.jfrog.ide.common.nodes;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.jfrog.ide.common.nodes.subentities.FindingInfo;
import com.jfrog.ide.common.nodes.subentities.SourceCodeScanType;
import com.jfrog.ide.common.nodes.subentities.Severity;
import lombok.Getter;

import java.util.Objects;

@Getter
public class FileIssueNode extends IssueNode implements SubtitledTreeNode {
@JsonProperty()
private String title;
@JsonProperty()
private String reason;
@JsonProperty()
private String lineSnippet;
@JsonProperty()
private int rowStart;
@JsonProperty()
private int colStart;
@JsonProperty()
private int rowEnd;
@JsonProperty()
private int colEnd;
@JsonProperty()
private String filePath;
private FindingInfo findingInfo;
@JsonProperty()
private Severity severity;
@JsonProperty()
private SourceCodeScanType reporterType;
@JsonProperty()
private String ruleID;

// Empty constructor for deserialization
@SuppressWarnings("unused")
protected FileIssueNode() {
}

public FileIssueNode(String title, String filePath, int rowStart, int colStart, int rowEnd, int colEnd, String reason, String lineSnippet, SourceCodeScanType reportType, Severity severity) {
public FileIssueNode(String title, String filePath, int rowStart, int colStart, int rowEnd, int colEnd, String reason, String lineSnippet, SourceCodeScanType reportType, Severity severity, String ruleID) {
this.title = title;
this.filePath = filePath;
this.rowStart = rowStart;
this.colStart = colStart;
this.rowEnd = rowEnd;
this.colEnd = colEnd;
this.findingInfo = new FindingInfo(filePath, rowStart, colStart, rowEnd, colEnd, lineSnippet);
this.reason = reason;
this.lineSnippet = lineSnippet;
this.reporterType = reportType;
this.severity = severity;
this.ruleID = ruleID;
}

@SuppressWarnings("unused")
public String getFilePath() {
return filePath;
return findingInfo.getFilePath();
}

@SuppressWarnings("unused")
public int getRowStart() {
return rowStart;
return findingInfo.getRowStart();
}

@SuppressWarnings("unused")
public int getColStart() {
return colStart;
return findingInfo.getColStart();
}

@SuppressWarnings("unused")
public int getRowEnd() {
return rowEnd;
return findingInfo.getRowEnd();
}

@SuppressWarnings("unused")
public int getColEnd() {
return colEnd;
}

public String getReason() {
return reason;
return findingInfo.getColEnd();
}

public String getLineSnippet() {
return lineSnippet;
}

@SuppressWarnings("unused")
public SourceCodeScanType getReporterType() {
return reporterType;
return findingInfo.getLineSnippet();
}

@Override
public String getSubtitle() {
// The indexes ranges start form 0, for user readability convert the range to start from 1.
return "row: " + (rowStart + 1) + " col: " + (colStart + 1);
// Indexes are zero-based. To enhance user readability, the range is converted to start from 1.
return "row: " + (getRowStart() + 1) + " col: " + (getColStart() + 1);
}

@Override
Expand All @@ -110,11 +89,13 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileIssueNode that = (FileIssueNode) o;
return rowStart == that.rowStart && colStart == that.colStart && rowEnd == that.rowEnd && colEnd == that.colEnd && Objects.equals(title, that.title) && Objects.equals(reason, that.reason) && Objects.equals(lineSnippet, that.lineSnippet) && Objects.equals(filePath, that.filePath) && severity == that.severity && reporterType == that.reporterType;
return Objects.equals(findingInfo, that.findingInfo) && Objects.equals(title, that.title)
&& Objects.equals(reason, that.reason) && severity == that.severity && reporterType == that.reporterType
&& Objects.equals(ruleID, that.ruleID);
}

@Override
public int hashCode() {
return Objects.hash(title, reason, lineSnippet, rowStart, colStart, rowEnd, colEnd, filePath, severity, reporterType);
return Objects.hash(title, reason, findingInfo, severity, reporterType, ruleID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.jfrog.ide.common.nodes.subentities;

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

import java.util.Objects;

@Getter
public class FindingInfo {
@JsonProperty()
private String lineSnippet;
@JsonProperty()
private int rowStart;
@JsonProperty()
private int colStart;
@JsonProperty()
private int rowEnd;
@JsonProperty()
private int colEnd;
@JsonProperty()
private String filePath;

public FindingInfo() {
}

public FindingInfo(String filePath, int rowStart, int colStart, int rowEnd, int colEnd, String lineSnippet) {
this.filePath = filePath;
this.rowStart = rowStart;
this.colStart = colStart;
this.rowEnd = rowEnd;
this.colEnd = colEnd;
this.lineSnippet = lineSnippet;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FindingInfo that = (FindingInfo) o;
return Objects.equals(lineSnippet, that.lineSnippet) && rowStart == that.rowStart && colStart == that.colStart && rowEnd == that.rowEnd && colEnd == that.colEnd && Objects.equals(filePath, that.filePath);
}

@Override
public int hashCode() {
return Objects.hash(lineSnippet, rowStart, colStart, rowEnd, colEnd, filePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
public enum SourceCodeScanType {
CONTEXTUAL("analyze-applicability"),
SECRETS("secrets-scan"),
IAC("iac-scan-modules");
IAC("iac-scan-modules"),
EOS("analyze-codebase");

private final String param;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ private static List<FileTreeNode> getFileTreeNode() {
"reason",
"lineSnippet",
"scannerSearchTarget",
vulnerabilityNode
vulnerabilityNode,
"ruleID"
);
vulnerabilityNode.updateApplicableInfo(applicableIssueNode);
fileTreeNode.addIssue(applicableIssueNode);
Expand Down