Bug 13139 - Triage fails
Summary: Triage fails
Status: RESOLVED FIXED
Alias: None
Product: Security Response Tool
Classification: Yocto Project Subprojects
Component: General (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.7 M2
Assignee: David Reyna
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-01-14 11:57 UTC by Ross Burton
Modified: 2019-01-22 21:11 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2019-01-14 11:57:57 UTC
Go to triage, select some bugs and press Not Vulnerable.

error on request:
invalid literal for int() with base 10: ''
Traceback (most recent call last):
  File "/home/ross/Yocto/srtool/lib/srtgui/views.py", line 1061, in xhr_triage_commit
    cve.save()
  File "/home/ross/Yocto/srtool/lib/orm/models.py", line 64, in save
    return _base_save(self, *args, **kwargs)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/base.py", line 718, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/base.py", line 748, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/base.py", line 812, in _save_table
    forced_update)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/base.py", line 861, in _do_update
    return filtered._update(values) > 0
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/query.py", line 712, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1383, in execute_sql
    cursor = super().execute_sql(result_type)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1052, in execute_sql
    sql, params = self.as_sql()
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1349, in as_sql
    val = field.get_db_prep_save(val, connection=self.connection)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 790, in get_db_prep_save
    return self.get_db_prep_value(value, connection=connection, prepared=False)
  File "/home/ross/.local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 785, in get_db_prep_value
    value = self.get_prep_value(value)
Comment 1 David Reyna 2019-01-14 12:08:05 UTC
Hmm, this is not failing for me unfortunately.

1. In my source it is line 1064 that is the "cve.save()", not line 1061 as reported in the traceback. That is odd.

2. If you could add a "_log("FOO:CVE=%s" % cve)" before the "cve.save()", run the code, and then run "./tail()", we could perhaps see what value in the CVE record is off.
Comment 2 Ross Burton 2019-01-14 12:50:06 UTC
The line number difference is probably because I have a few changes locally.

However I now can't replicate.  If I break it again, I'll reopen with logs.
Comment 3 Ross Burton 2019-01-14 12:52:16 UTC
Okay did it again.  Will get more info
Comment 4 Ross Burton 2019-01-14 12:56:08 UTC
|TRIAGING:CVE=<Cve: Cve object (66202)>|

Need a better way to dump the contents than str() or repr().
Comment 5 Ross Burton 2019-01-14 13:18:59 UTC
It's just CVE-2019-6137
Comment 6 Ross Burton 2019-01-14 13:25:43 UTC
Ah.

From a manage shell:

>>> c = orm.models.Cve.objects.get(name='CVE-2019-6137')
>>> c.recommend
''

That's an integer field.
Comment 7 Ross Burton 2019-01-14 14:07:48 UTC
c.recommend = 0; c.save() fixed it.  Iterating through the entire database shows this has happened more than once for some reason.
Comment 8 Ross Burton 2019-01-14 14:14:13 UTC
More than one == lots.

>>> counter = 0
>>> broken = 0
>>> for c in orm.models.Cve.objects.iterator():
...   counter+=1
...   if not isinstance(c.recommend, type(1)):
...     broken+=1
...
>>> counter
66334
>>> broken
20168
Comment 9 David Reyna 2019-01-14 19:28:08 UTC
Ah, it will be fixed today.

These problem records are ones that have not been scored yet. I had the idea of leaving these field empty to indicate that had not been scored (the processing which I moved to a second asynchronous data source because of the time overhead). The problem is that this is an invalid integer which fails if you try to triage, as you observed.

I had not hit this problem because (a) I was always manually executing the scoring routine, and (b) the new auto-updater code I am finishing resolves the scoring.

I had already created the 'score_date' field to better track the scoring. I just have to fix the creation default value (to 0) and this is done.
Comment 10 David Reyna 2019-01-14 23:45:44 UTC
commit 959cc8196aab2231b7f6f05c7e0151f8de46ea48

The error was in the "srtool_mitre.py" script that was creating 'reserved' CVEs.

I have added a database fix routine (./bin/common/srtool_common.py --fix-cve-recommend) and attached it to the SRTool startup (via ./bin/common/srtool_common.py --generate-schema-header) so that existing databases can be automatically repaired:

  $ ./stop.sh
  $ git pull
  $ ./start.sh