aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2020-01-31 02:09:27 -0800
committerDavid Reyna <David.Reyna@windriver.com>2020-01-31 02:09:27 -0800
commitfb78272da52429f4db258169e39cfac750b0884c (patch)
tree7d5db9ee986a9c2d26a0997462d64b828161ee2e
parentbdc472e483523aa5c10eb2fef2c34eb16f62b039 (diff)
downloadsrtool-fb78272da52429f4db258169e39cfac750b0884c.tar.gz
srtool-fb78272da52429f4db258169e39cfac750b0884c.tar.bz2
srtool-fb78272da52429f4db258169e39cfac750b0884c.zip
srtool: preset foreign keys in object creation
The model for vulnerabilities and investigation is more stringent in defining the foreign keys when creating records. Set these values when creating a record to avoid a 'null-constraint' error. Signed-off-by: David Reyna <David.Reyna@windriver.com>
-rw-r--r--lib/srtgui/views.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/srtgui/views.py b/lib/srtgui/views.py
index 079fc670..7fdfad98 100644
--- a/lib/srtgui/views.py
+++ b/lib/srtgui/views.py
@@ -1398,7 +1398,7 @@ def _create_defect(investigation,reason,defect_reason,domain_components,affected
d_name = "DEFECT-%s-%d" % (investigation.product.get_defect_tag('key'),index)
d_url = "%s%s" % (SrtSetting.objects.get(name='SRTOOL_DEFECT_URLBASE').value,d_name)
# create new defect entry
- d = Defect.objects.create(name=d_name)
+ d = Defect.objects.create(name=d_name,product=investigation.product)
d.summary = summary
d.priority = investigation.priority
d.status = Defect.DEFECT_STATUS_OPEN
@@ -1406,7 +1406,6 @@ def _create_defect(investigation,reason,defect_reason,domain_components,affected
d.srt_priority = investigation.priority
d.srt_status = Defect.VULNERABLE
d.srt_outcome = Defect.OPEN
- d.product = investigation.product
d.url = d_url
d.save()
_log("NEW_DEFECT:%s|%s|%s|%s" % (d.name,summary,components,priority))
@@ -1643,9 +1642,7 @@ def xhr_triage_commit(request):
if not investigation:
i_name = Investigation.new_investigation_name()
- investigation = Investigation.objects.create(name=i_name)
- investigation.vulnerability = vulnerability
- investigation.product = product
+ investigation = Investigation.objects.create(name=i_name,product=product,vulnerability = vulnerability)
investigation.priority = cve_priority
investigation.outcome = Investigation.OPEN
# Check to see if product is active