From 7bbf400f6ed1649db2602a212aa861ba591f3a27 Mon Sep 17 00:00:00 2001 From: Yusuf Zainee Date: Tue, 12 Mar 2019 13:44:27 +0530 Subject: [PATCH] Added cecosystem to CVE --- src/cve.py | 8 ++++---- src/schema.groovy | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cve.py b/src/cve.py index 4c75a736..a37f27d4 100644 --- a/src/cve.py +++ b/src/cve.py @@ -232,11 +232,11 @@ def put(payload): # add or replace CVE node cve_node_replace_script_template = """\ -cve_v=g.V().has('cve_id',cve_id).tryNext().orElseGet{\ +cve_v=g.V().has('cve_id',cve_id).has('cecosystem', ecosystem).tryNext().orElseGet{\ graph.addVertex(label, 'CVE',\ 'vertex_label', 'CVE',\ 'cve_id', cve_id)};\ -cve_v.property('ecosystem', ecosystem);\ +cve_v.property('cecosystem', ecosystem);\ cve_v.property('description', description);\ cve_v.property('cvss_v2', cvss_v2);\ cve_v.property('modified_date', modified_date);\ @@ -249,7 +249,7 @@ def put(payload): # add edge between CVE node and Version node if it does not exist previously add_affected_edge_script_template = """\ -cve_v=g.V().has('cve_id',cve_id).next();\ +cve_v=g.V().has('cve_id',cve_id).has('cecosystem', '{ecosystem}').next();\ version_v=g.V().has('pecosystem','{ecosystem}')\ .has('pname','{name}')\ .has('version','{version}');\ @@ -270,7 +270,7 @@ def put(payload): # get CVEs for ecosystem cve_nodes_for_ecosystem_script_template = """\ g.V().has("vertex_label", "CVE")\ -.has("ecosystem",ecosystem)\ +.has("cecosystem",ecosystem)\ .values("cve_id")\ .dedup();\ """ diff --git a/src/schema.groovy b/src/schema.groovy index 52b9da52..321bf737 100644 --- a/src/schema.groovy +++ b/src/schema.groovy @@ -123,6 +123,11 @@ // for CVEs + cecosystem = mgmt.getPropertyKey('cecosystem'); + if(cecosystem == null) { + cecosystem = mgmt.makePropertyKey('cecosystem').dataType(String.class).make(); + } + cve_ids = mgmt.getPropertyKey('cve_ids'); if(cve_ids == null) { cve_ids = mgmt.makePropertyKey('cve_ids').dataType(String.class).cardinality(Cardinality.SET).make(); @@ -646,6 +651,7 @@ 'email', //'cve_id', //'fixed_in', + 'cecosystem', 'nvd_status', 'cvedb_version', //'summary',