Skip to content

Commit 74a1afa

Browse files
authored
Merge branch 'main' into gitpython
2 parents 9be7cee + cac1aa3 commit 74a1afa

82 files changed

Lines changed: 7116 additions & 10127 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/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
pip install -r requirements.txt
3939
4040
- name: Run tests
41-
run: python -m pytest
41+
run: python -m pytest -v -m "not webtest"
4242
env:
4343
# The hostname, username used to communicate with the PostgreSQL service container
4444
POSTGRES_HOST: localhost

.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
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
workflow_dispatch: # allow manual execution
3+
schedule:
4+
# run on every 9 o'clock
5+
- cron: '0 9 * * *'
6+
7+
jobs:
8+
unit_tests:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
# Label used to access the service container
13+
postgres:
14+
image: postgres
15+
env:
16+
POSTGRES_PASSWORD: vulnerablecode
17+
POSTGRES_DB: vulnerablecode
18+
# Set health checks to wait until postgres has started
19+
options: >-
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
ports:
25+
# Maps tcp port 5432 on service container to the host
26+
- 5432:5432
27+
steps:
28+
- name: Check out repository code
29+
uses: actions/checkout@v2
30+
31+
- name: Set up Python 3.8
32+
uses: actions/setup-python@v2
33+
with:
34+
python-version: 3.8
35+
36+
- name: Install dependencies
37+
run: |
38+
sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev
39+
python -m pip install --upgrade pip
40+
pip install -r requirements.txt
41+
pip install pytest-xdist
42+
43+
- name: Run tests
44+
run: |
45+
python -m pytest -v vulnerabilities/tests/test_upstream.py -n 2
46+
env:
47+
# The hostname, username used to communicate with the PostgreSQL service container
48+
POSTGRES_HOST: localhost
49+
VC_DB_USER: postgres
50+
POSTGRES_PORT: 5432
51+
DJANGO_DEV: 1
52+
GH_TOKEN: 1

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ before_script:
1818

1919
script:
2020
- ./manage.py collectstatic
21-
- python -m pytest
21+
- python -m pytest -v -m "not webtest"
2222

2323
notifications:
2424
email: false

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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
# mach-nix release) is usually insufficient. Use
5454
# ./get-latest-pypi-deps-db.sh to obtain the data rev & hash.
5555
pypiDataRev =
56-
"499750266bb4b2840cbe856c2cc0e3297685e362"; # 2021-03-06T08:13:08Z
56+
"e9b0fc6b92cd6efbca7ba3b3d4a551bcc13a73c5"; # 2021-03-27T08:13:04Z
5757
pypiDataSha256 =
58-
"188g24k8pk4lgqybywimkvwjwh8014v6l2mrkvzv309882i9p5gc";
58+
"1ssa48l2iz8kncby1gfrbds79mg114dkhpxrridwcq6q2c37p62s";
5959
});
6060

6161
in {
@@ -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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +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
66
binaryornot==0.4.4
77
cached-property==1.5.1
88
cffi==1.14.0
99
contextlib2==0.5.5
1010
decorator==4.4.2
11-
dephell-specifier==0.2.1
11+
univers==21.4.16.6
1212
dj-database-url==0.4.2
13-
Django==3.0.13
13+
Django==3.0.14
1414
django-filter==2.2.0
1515
djangorestframework==3.11.2
1616
django-widget-tweaks==1.4.8
@@ -20,10 +20,10 @@ importlib-metadata==1.3.0
2020
ipython==7.13.0
2121
ipython-genutils==0.2.0
2222
jedi==0.17.0
23-
lxml==4.6.2
23+
lxml==4.6.3
2424
more-itertools==8.0.2
2525
packageurl-python==0.9.3
26-
packaging==19.2
26+
packaging==20.9
2727
parso==0.7.0
2828
pexpect==4.8.0
2929
pickleshare==0.7.5
@@ -32,15 +32,16 @@ prompt-toolkit==3.0.5
3232
black==20.8b1
3333
psycopg2==2.8.4
3434
ptyprocess==0.6.0
35-
py==1.8.0
35+
py==1.10.0
3636
pycparser==2.20
3737
gitpython==3.1.14
3838
Pygments==2.7.4
3939
pyparsing==2.4.5
40-
pytest==5.3.2
40+
pytest==6.2.3
41+
pytest-django==4.1.0
4142
django-widget-tweaks==1.4.8
4243
pytest-dependency==0.4.0
43-
pytest-django==3.7.0
44+
pytest-django==4.1.0
4445
pytest-mock==1.13.0
4546
python-dateutil==2.8.1
4647
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

0 commit comments

Comments
 (0)