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

IDEs - Support ignore URL and vuln references #611

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,10 +1,10 @@
package org.jfrog.build.extractor.scan;

import javax.swing.tree.DefaultMutableTreeNode;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;

import javax.swing.tree.DefaultMutableTreeNode;
import java.util.*;

/**
Expand Down Expand Up @@ -193,4 +193,21 @@ public void collectAllScopesAndLicenses(Set<Scope> allScopes, Set<License> allLi
allLicenses.addAll(child.getLicenses());
}
}

/**
* Recursively find a node contains the input component ID.
*
* @param componentId - The component ID to search
* @return a node contains the input component ID or null.
*/
public DependencyTree find(String componentId) {
if (StringUtils.equals(toString(), componentId)) {
return this;
}
return getChildren().stream()
.map(child -> child.find(componentId))
.filter(Objects::nonNull)
.findAny()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ public class Issue implements Comparable<Issue> {

private Severity severity = Severity.Normal;
private List<String> fixedVersions;
private List<String> references;
private String component = "";
private List<String> cves;
private String ignoreUrl;
yahavi marked this conversation as resolved.
Show resolved Hide resolved
private String summary;
private String issueId;
private String cve;

public Issue() {
}

@SuppressWarnings("unused")
public Issue(String issueId, Severity severity, String summary, List<String> fixedVersions, String cve) {
public Issue(String issueId, Severity severity, String summary, List<String> fixedVersions, List<String> cves, List<String> references, String ignoreUrl) {
this.issueId = issueId;
this.severity = severity;
this.summary = summary;
this.fixedVersions = fixedVersions;
this.cve = cve;
this.cves = cves;
this.references = references;
this.ignoreUrl = ignoreUrl;
yahavi marked this conversation as resolved.
Show resolved Hide resolved
}

public String getIssueId() {
Expand Down Expand Up @@ -65,8 +69,18 @@ public void setFixedVersions(List<String> fixedVersions) {
}

@SuppressWarnings("unused")
public String getCve() {
return cve;
public List<String> getCves() {
return cves;
}

@SuppressWarnings("unused")
public List<String> getReferences() {
return references;
}

@SuppressWarnings("unused")
public String getIgnoreUrl() {
yahavi marked this conversation as resolved.
Show resolved Hide resolved
return ignoreUrl;
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,26 @@ public void testFixedVersions() {
one.setIssues(Sets.newHashSet());
}

@Test
public void testFind() {
assertNotNull(root.find("0"));
assertNotNull(root.find("1"));
assertNotNull(root.find("2"));
assertNotNull(root.find("3"));
assertNotNull(root.find("4"));
assertNotNull(root.find("5"));
assertNull(root.find("non-existent"));
}

/**
* Create a random issue
*
* @param severity the issue severity
* @return the random issue
*/
private Issue createIssue(Severity severity) {
return new Issue(generateUID(), severity, generateUID(), Lists.newArrayList(), generateUID());
return new Issue(generateUID(), severity, generateUID(), Lists.newArrayList(),
Lists.newArrayList(), Lists.newArrayList(), generateUID());
}

/**
Expand Down