Skip to content

Commit c585f02

Browse files
authored
Merge pull request #2 from nexB/main
Pulling changes
2 parents 9ee950b + 254cb96 commit c585f02

84 files changed

Lines changed: 7358 additions & 10460 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-import-using-nix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ jobs:
2525
- name: run checks & test import
2626
run: |
2727
cd etc/nix
28+
./get-latest-pypi-deps-db.sh --in-place
2829
nix --print-build-logs flake check
2930
./test-import-using-nix.sh alpine

.github/workflows/upstream_test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
on:
22
workflow_dispatch: # allow manual execution
3-
push:
43
schedule:
54
# run on every 9 o'clock
65
- cron: '0 9 * * *'
@@ -39,9 +38,11 @@ jobs:
3938
sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev
4039
python -m pip install --upgrade pip
4140
pip install -r requirements.txt
41+
pip install pytest-xdist
4242
4343
- name: Run tests
44-
run: pytest -v -m webtest
44+
run: |
45+
python -m pytest -v vulnerabilities/tests/test_upstream.py -n 2
4546
env:
4647
# The hostname, username used to communicate with the PostgreSQL service container
4748
POSTGRES_HOST: localhost

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
name = "vulnerablecode-${version}";
7575
src = vulnerablecode-src;
7676
dontConfigure = true; # do not use ./configure
77-
propagatedBuildInputs = [ pythonEnv postgresql ];
77+
propagatedBuildInputs = [ pythonEnv postgresql gitMinimal];
7878

7979
postPatch = ''
8080
# Make sure the pycodestyle binary in $PATH is used.
@@ -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 &

etc/nix/get-latest-pypi-deps-db.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ COMMIT=$(sed '1q;d' <<< "$DATA")
77
DATE=$(sed '2q;d' <<< "$DATA")
88
SHA256=$(nix-prefetch-url --unpack --type sha256 "https://github.com/$USER_SLASH_REPO/tarball/$COMMIT" | tail -n 1)
99

10+
NIX_REV_ATTR="pypiDataRev = \"$COMMIT\"; # $DATE"
11+
NIX_SHA_ATTR="pypiDataSha256 = \"$SHA256\";"
12+
1013
echo ""
11-
echo "pypiDataRev = \"$COMMIT\"; # $DATE"
12-
echo "pypiDataSha256 = \"$SHA256\";"
14+
echo $NIX_REV_ATTR
15+
echo $NIX_SHA_ATTR
16+
17+
if [[ "$1" = "--in-place" ]] ; then
18+
# Replace the values in the flake.
19+
PATTERN="\s*\n?\s*\"[^\n]+" # <space><newline><space>"content...<newline>
20+
perl -i.bak1 -0777 -pe "s/pypiDataRev =$PATTERN/$NIX_REV_ATTR/" flake.nix
21+
perl -i.bak2 -0777 -pe "s/pypiDataSha256 =$PATTERN/$NIX_SHA_ATTR/" flake.nix
22+
fi

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
DJANGO_SETTINGS_MODULE = vulnerablecode.settings

requirements.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
aiohttp==3.7.4
22
asgiref==3.2.7
3-
attrs==19.3.0
3+
attrs==20.3.0
44
backcall==0.1.0
55
beautifulsoup4==4.7.1
6+
binaryornot==0.4.4
67
cached-property==1.5.1
78
cffi==1.14.0
89
contextlib2==0.5.5
910
decorator==4.4.2
10-
dephell-specifier==0.2.1
11+
univers==21.4.16.6
1112
dj-database-url==0.4.2
12-
Django==3.0.13
13+
Django==3.0.14
1314
django-filter==2.2.0
1415
djangorestframework==3.11.2
1516
django-widget-tweaks==1.4.8
@@ -22,7 +23,7 @@ jedi==0.17.0
2223
lxml==4.6.3
2324
more-itertools==8.0.2
2425
packageurl-python==0.9.3
25-
packaging==19.2
26+
packaging==20.9
2627
parso==0.7.0
2728
pexpect==4.8.0
2829
pickleshare==0.7.5
@@ -31,15 +32,16 @@ prompt-toolkit==3.0.5
3132
black==20.8b1
3233
psycopg2==2.8.4
3334
ptyprocess==0.6.0
34-
py==1.8.0
35+
py==1.10.0
3536
pycparser==2.20
36-
pygit2==1.5.0
37+
gitpython==3.1.14
3738
Pygments==2.7.4
3839
pyparsing==2.4.5
39-
pytest==5.3.2
40+
pytest==6.2.3
41+
pytest-django==4.1.0
4042
django-widget-tweaks==1.4.8
4143
pytest-dependency==0.4.0
42-
pytest-django==3.7.0
44+
pytest-django==4.1.0
4345
pytest-mock==1.13.0
4446
python-dateutil==2.8.1
4547
pytz==2019.3

vulnerabilities/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class PackageAdmin(admin.ModelAdmin):
5151

5252
@admin.register(PackageRelatedVulnerability)
5353
class PackageRelatedVulnerabilityAdmin(admin.ModelAdmin):
54-
list_filter = ("is_vulnerable", "package__type", "package__namespace")
54+
list_filter = ("package__type", "package__namespace")
5555
search_fields = ["vulnerability__vulnerability_id", "package__name"]
5656

5757

vulnerabilities/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class VulnerabilityReferenceSerializer(serializers.ModelSerializer):
5353

5454
class Meta:
5555
model = VulnerabilityReference
56-
fields = ["source", "reference_id", "url", "scores"]
56+
fields = ["reference_id", "url", "scores"]
5757

5858

5959
class MinimalPackageSerializer(serializers.HyperlinkedModelSerializer):

0 commit comments

Comments
 (0)