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

Checking all CVEs in applicability scan #487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -90,16 +90,14 @@ public List<FileTreeNode> applicabilityScan(ProgressIndicator indicator, Collect
return Collections.emptyList();
}
List<JFrogSecurityWarning> scanResults = new ArrayList<>();
Map<String, List<VulnerabilityNode>> issuesMap = mapDirectIssuesByCve(fileTreeNodes);

Map<String, List<VulnerabilityNode>> issuesMap = mapIssuesByCve(fileTreeNodes);
try {
if (applicability.isPackageTypeSupported(packageType)) {
indicator.setText("Running applicability scan");
indicator.setFraction(0.25);
Set<String> directIssuesCVEs = issuesMap.keySet();
// If no direct dependencies with issues are found by Xray, the applicability scan is irrelevant.
if (!directIssuesCVEs.isEmpty()) {
List<JFrogSecurityWarning> applicabilityResults = applicability.execute(createBasicScannerInput().cves(List.copyOf(directIssuesCVEs)), checkCanceled, indicator);
Set<String> issuesCVEs = issuesMap.keySet();
if (!issuesCVEs.isEmpty()) {
List<JFrogSecurityWarning> applicabilityResults = applicability.execute(createBasicScannerInput().cves(List.copyOf(issuesCVEs)), checkCanceled, indicator);
scanResults.addAll(applicabilityResults);
}
}
Expand Down Expand Up @@ -294,14 +292,11 @@ public static List<String> convertToSkippedFolders(String excludePattern) {
* @param fileTreeNodes collection of FileTreeNodes.
* @return a map of CVE IDs to lists of issues with them.
*/
private Map<String, List<VulnerabilityNode>> mapDirectIssuesByCve(Collection<FileTreeNode> fileTreeNodes) {
private Map<String, List<VulnerabilityNode>> mapIssuesByCve(Collection<FileTreeNode> fileTreeNodes) {
Map<String, List<VulnerabilityNode>> issues = new HashMap<>();
for (FileTreeNode fileTreeNode : fileTreeNodes) {
for (TreeNode treeNode : fileTreeNode.getChildren()) {
DependencyNode dep = (DependencyNode) treeNode;
if (dep.isIndirect()) {
continue;
}
Enumeration<TreeNode> treeNodeEnumeration = dep.children();
while (treeNodeEnumeration.hasMoreElements()) {
TreeNode node = treeNodeEnumeration.nextElement();
Expand Down
Loading