File: test_latest_vulndb_data.py

package info (click to toggle)
python-vulndb 0.1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,032 kB
  • sloc: python: 446; sh: 196; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import shutil
import unittest
import subprocess

from vulndb.db_vuln import DBVuln

VULNDB_DATA = 'https://github.com/vulndb/data.git'
LATEST_COMMIT = 'git rev-parse HEAD'


class TestLatestDBUsed(unittest.TestCase):
    def test_latest_db_used(self):
        subprocess.check_output('git clone %s' % VULNDB_DATA,
                                shell=True,
                                cwd='/tmp/',
                                stderr=subprocess.PIPE)

        latest_commit = subprocess.check_output(LATEST_COMMIT,
                                                shell=True,
                                                cwd='/tmp/data/')
        latest_commit = latest_commit.decode('utf-8') 

        shutil.rmtree('/tmp/data/')

        latest_commit = latest_commit.strip()
        latest_saved_commit = DBVuln.get_db_version()

        self.assertEqual(latest_commit, latest_saved_commit,
                         msg='DB version mismatch, this usually gets fixed'
                             ' by running tools/update-db.sh')