aboutsummaryrefslogtreecommitdiffstats
path: root/bin/nist/srtool_nist.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/nist/srtool_nist.py')
-rwxr-xr-xbin/nist/srtool_nist.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bin/nist/srtool_nist.py b/bin/nist/srtool_nist.py
index c05e65d0..807afbc1 100755
--- a/bin/nist/srtool_nist.py
+++ b/bin/nist/srtool_nist.py
@@ -170,7 +170,11 @@ def update_nist(is_init,datasource_description, url_file, url_meta, cve_file, in
# trim the UTC offset to avoid time zone and day light savings glitches
content = content[:content.rfind('-')]
date_new = datetime.strptime(content, 'lastModifiedDate:%Y-%m-%dT%H:%M:%S')
- date_past = datetime.strptime(ds[ORM.DATASOURCE_LASTMODIFIEDDATE], '%Y-%m-%d %H:%M:%S')
+ if not ds[ORM.DATASOURCE_LASTMODIFIEDDATE]:
+ # Force update if no registed modified date for datasource (e.g. Init)
+ date_past = date_new-timedelta(days=1)
+ else:
+ date_past = datetime.strptime(ds[ORM.DATASOURCE_LASTMODIFIEDDATE], '%Y-%m-%d %H:%M:%S')
log.write("BEGINNING NIST %s\n" % ('INITS' if is_init else 'UPDATES'))
#determine if we are out of date and apply updates if true
@@ -194,8 +198,8 @@ def update_nist(is_init,datasource_description, url_file, url_meta, cve_file, in
log.write("\n")
print("NO %s NEEDED" % ('INIT' if is_init else 'UPDATE'))
- # Reset datasource's update_time as today
- sql = "UPDATE orm_datasource SET update_time = ? WHERE id='%s'" % ds[ORM.DATASOURCE_ID]
+ # Reset datasource's lastModifiedDate as today
+ sql = "UPDATE orm_datasource SET lastModifiedDate = ? WHERE id='%s'" % ds[ORM.DATASOURCE_ID]
c.execute(sql, (datetime.today().strftime('%Y-%m-%d %H:%M:%S'),) )
conn.commit()
@@ -408,7 +412,6 @@ def sql_cve_query(conn, cve, is_init, log):
if exists is None:
# Get the default CVE status
status = get_cve_default_status(is_init,cve.publishedDate)
- print("BAR:%s=%s" % (cve.name,status))
sql = ''' INSERT into orm_cve (name, name_sort, priority, status, comments, comments_private, cve_data_type, cve_data_format, cve_data_version, public, publish_state, publish_date, description, publishedDate, lastModifiedDate, recommend, recommend_list, cvssV3_baseScore, cvssV3_baseSeverity, cvssV2_baseScore, cvssV2_severity, srt_updated, packages)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'''