Skip to content

Commit

Permalink
change: cve.js for new data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng committed Jan 16, 2025
1 parent 0f2dc42 commit 87faa4e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/gmp/models/cve.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,39 @@ class Cve extends Info {
ret.references = [];
}

if (isDefined(element.cve?.references?.reference)) {
ret.references = map(element.cve.references.reference, ref => {
let tags = [];
if (isArray(ref.tags.tag)) {
tags = ref.tags.tag;
} else if (isDefined(ref.tags.tag)) {
tags = [ref.tags.tag];
}
return {
name: ref.url,
tags: tags,
};
});
}

if (isDefined(element.cve?.configuration_nodes?.node)) {
const nodes = isArray(element.cve.configuration_nodes.node)
? element.cve.configuration_nodes.node
: [element.cve.configuration_nodes.node];
nodes.forEach(node => {
if (isDefined(node.match_string?.matched_cpes?.cpe)) {
const cpes = isArray(node.match_string.matched_cpes.cpe)
? node.match_string.matched_cpes.cpe
: [node.match_string.matched_cpes.cpe];
cpes.forEach(cpe => {
if (isDefined(cpe._id)) {
ret.products.push(cpe._id);
}
});
}
});
}

return ret;
}
}
Expand Down

0 comments on commit 87faa4e

Please sign in to comment.