Skip to content

Commit

Permalink
#3330 Fix NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
nhumblot committed Apr 27, 2021
1 parent c01867e commit 6c85195
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
*/
package org.owasp.dependencycheck.data.nvd.ecosystem;

import java.util.Objects;
import java.util.Optional;
import java.util.TreeMap;

import javax.annotation.concurrent.NotThreadSafe;

import org.owasp.dependencycheck.data.nvd.json.CVEJSON40Min11;
import org.owasp.dependencycheck.data.nvd.json.DefCveItem;
import org.owasp.dependencycheck.data.nvd.json.Reference;
import org.owasp.dependencycheck.data.nvd.json.References;

import com.hankcs.algorithm.AhoCorasickDoubleArrayTrie;
import com.hankcs.algorithm.AhoCorasickDoubleArrayTrie.Hit;
Expand Down Expand Up @@ -65,8 +69,13 @@ public UrlEcosystemMapper() {
* @return the ecosystem
*/
public String getEcosystem(DefCveItem cve) {
if (cve.getCve().getReferences() != null) {
for (Reference r : cve.getCve().getReferences().getReferenceData()) {
References references = Optional.ofNullable(cve)
.map(DefCveItem::getCve)
.map(CVEJSON40Min11::getReferences)
.orElse(null);

if (Objects.nonNull(references)) {
for (Reference r : references.getReferenceData()) {

final Hit<String> ecosystem = search.findFirst(r.getUrl());
if (ecosystem != null) {
Expand Down

0 comments on commit 6c85195

Please sign in to comment.