Skip to content

Commit 5f493fb

Browse files
Merge branch 'main' into fix-ubuntu-usn-importer
2 parents 4e1f52b + f76b1ce commit 5f493fb

7 files changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/upstream_test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ jobs:
3939
sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev
4040
python -m pip install --upgrade pip
4141
pip install -r requirements.txt
42+
pip install pytest-xdist
4243
4344
- name: Run tests
44-
run: pytest -v -m webtest
45+
run: |
46+
python -m pytest -v vulnerabilities/tests/test_upstream.py -n 2
4547
env:
4648
# The hostname, username used to communicate with the PostgreSQL service container
4749
POSTGRES_HOST: localhost

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ compose. For this you need to have the following installed.
106106
Use ``sudo docker-compose up`` to start VulnerableCode. Then access
107107
VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/
108108

109+
**Important**: Don't forget to run ``sudo docker-compose up -d --no-deps --build web`` to sync your instance after every ``git pull``.
110+
111+
109112
Use ``sudo docker-compose exec web bash`` to access the VulnerableCode
110113
container. From here you can access ``manage.py`` and run management commands
111114
to import data as specified below.

etc/nix/flake.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@
136136
checkPhase = ''
137137
# Run pytest on the installed version. A running postgres
138138
# database server is needed.
139-
(cd ${vulnerablecode} && pytest)
139+
(
140+
cd ${vulnerablecode}
141+
black -l 100 --check .
142+
pytest -m "not webtest"
143+
)
140144
141145
# Launch the webserver and call the API.
142146
${vulnerablecode}/manage.py runserver &

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ prompt-toolkit==3.0.5
3131
black==20.8b1
3232
psycopg2==2.8.4
3333
ptyprocess==0.6.0
34-
py==1.8.0
34+
py==1.10.0
3535
pycparser==2.20
3636
pygit2==1.5.0
3737
Pygments==2.7.4
3838
pyparsing==2.4.5
39-
pytest==5.3.2
39+
pytest==6.2.3
40+
pytest-django==4.1.0
4041
django-widget-tweaks==1.4.8
4142
pytest-dependency==0.4.0
42-
pytest-django==3.7.0
43+
pytest-django==4.1.0
4344
pytest-mock==1.13.0
4445
python-dateutil==2.8.1
4546
pytz==2019.3

vulnerabilities/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def create_etag(data_src, url, etag_key):
7979
return True
8080

8181

82-
is_cve = re.compile(r"CVE-\d+-\d+", re.IGNORECASE).match
82+
is_cve = re.compile(r"CVE-\d{4}-\d{4,7}", re.IGNORECASE).match
8383

8484

8585
def requests_with_5xx_retry(max_retries=5, backoff_factor=0.5):

vulnerabilities/importers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@
4747
from vulnerabilities.importers.suse_scores import SUSESeverityScoreDataSource
4848
from vulnerabilities.importers.ubuntu import UbuntuDataSource
4949
from vulnerabilities.importers.ubuntu_usn import UbuntuUSNDataSource
50-
from vulnerabilities.importers.apache_tomcat import ApacheTomcatDataSource
5150
from vulnerabilities.importers.istio import IstioDataSource

vulnerabilities/tests/test_importer_yielder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ class TestImporterYielder(TestCase):
5858
def setUpClass(cls):
5959
cls.importer_yielder = importer_yielder
6060

61+
def setUp(self):
62+
Importer.objects.all().delete()
63+
6164
@pytest.mark.django_db
6265
def test_load_importers_freshdb(self):
6366
assert Importer.objects.all().count() == 0
64-
6567
with patch(
6668
"vulnerabilities.importer_yielder.IMPORTER_REGISTRY", new=MOCK_IMPORTER_REGISTRY
6769
): # nopep8
@@ -71,7 +73,6 @@ def test_load_importers_freshdb(self):
7173
@pytest.mark.django_db
7274
def test_load_importers_setteddb(self):
7375
assert Importer.objects.all().count() == 0
74-
7576
mock_existing_importer = Importer.objects.create(**MOCK_IMPORTER_REGISTRY[1])
7677
mock_existing_importer.data_source_cfg["etags"] = {"url": "0x1234"}
7778
mock_existing_importer.save()

0 commit comments

Comments
 (0)