Skip to content

Commit

Permalink
Merge pull request #252 from yzainee/latest_version
Browse files Browse the repository at this point in the history
Added cecosystem to CVE
  • Loading branch information
miteshvp authored Mar 12, 2019
2 parents 01ee9df + 7bbf400 commit 7d93d83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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);\
Expand All @@ -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}');\
Expand All @@ -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();\
"""
Expand Down
6 changes: 6 additions & 0 deletions src/schema.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -646,6 +651,7 @@
'email',
//'cve_id',
//'fixed_in',
'cecosystem',
'nvd_status',
'cvedb_version',
//'summary',
Expand Down

0 comments on commit 7d93d83

Please sign in to comment.