-
-
Notifications
You must be signed in to change notification settings - Fork 328
Dockerize vulnerablecode #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
460b5c0
:rocket: Dockerize vulnerablecode
sbs2001 149932e
:ok_hand: Add compatibility to local set up
sbs2001 65dd215
:memo: Update documentation to include setup instructions using docker
sbs2001 b608624
:sparkles: Allow users to specify which database to use using env var…
sbs2001 e6941e6
:pencil2: Add prefix to all the env variables required by Vulnerable…
sbs2001 81167ab
Add metadata in the Dockerfile
sbs2001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| FROM python@sha256:e9b7e3b4e9569808066c5901b8a9ad315a9f14ae8d3949ece22ae339fff2cad0 | ||
|
|
||
| # PYTHONUNBUFFERED=1 ensures that the python output is set straight | ||
| # to the terminal without buffering it first | ||
| ENV PYTHONUNBUFFERED 1 | ||
| RUN mkdir /vulnerablecode | ||
| WORKDIR /vulnerablecode | ||
| ADD . /vulnerablecode/ | ||
| RUN pip install -r requirements.txt | ||
|
|
||
| LABEL "base_image": "pkg:docker/python@sha256%3Ae9b7e3b4e9569808066c5901b8a9ad315a9f14ae8d3949ece22ae339fff2cad0" | ||
| LABEL "dockerfile_url": "https://github.com/nexB/vulnerablecode/blob/develop/Dockerfile" | ||
| LABEL "homepage_url": "https://github.com/nexB/vulnerablecode" | ||
| LABEL "license": "Apache-2.0" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is awesome :) |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,40 +38,45 @@ The web interface enables community curation of data by enabling addition of new | |||||||||||
|
|
||||||||||||
| We also plan to mine for vulnerabilities which didn't receive any exposure due to various reasons like but not limited to the complicated procedure to receive CVE ID or not able to classify a bug as a security compromise. Check VulnerableCode at [Open Source Summit 2020](https://ossna2020.sched.com/event/c46p/why-is-there-no-free-software-vulnerability-database-philippe-ombredanne-aboutcodeorg-and-nexb-inc-michael-herzog-nexb-inc) | ||||||||||||
|
|
||||||||||||
| ## Setup | ||||||||||||
| ## Setting up VulnerableCode | ||||||||||||
|
|
||||||||||||
| Clone the source code: | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| git clone https://github.com/nexB/vulnerablecode.git && cd vulnerablecode | ||||||||||||
| git clone https://github.com/nexB/vulnerablecode.git | ||||||||||||
| cd vulnerablecode | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ### System requirements | ||||||||||||
| ### Using Docker Compose | ||||||||||||
| An easy way to set up VulnerableCode is with docker containers and docker compose. | ||||||||||||
| For this you need to have the following installed. | ||||||||||||
| - Docker Engine. Find instructions to install it here | ||||||||||||
| - Docker Compose. Find instructions to install it here | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this:
Suggested change
|
||||||||||||
|
|
||||||||||||
| - Python 3.8+ | ||||||||||||
|
|
||||||||||||
| - PostgreSQL 9+ or [Docker](https://hub.docker.com/search/?type=edition&offering=community) | ||||||||||||
| Use `sudo docker-compose up` to start VulnerableCode. | ||||||||||||
|
pombredanne marked this conversation as resolved.
|
||||||||||||
| Access VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/ . | ||||||||||||
|
|
||||||||||||
| - Compiler toolchain and development files for Python and PostgreSQL | ||||||||||||
| Use `sudo docker-compose exec web bash` to access the VulnerableCode container. From here you can access `manage.py` and run management commands to import data as specified below. | ||||||||||||
|
|
||||||||||||
| On Debian-based distros, these can be installed with `sudo apt install python3-venv python3-dev postgresql libpq-dev build-essential`. Leave out `postgresql` if you want to run it in Docker. | ||||||||||||
| ### Without Docker Compose | ||||||||||||
| **System requirements** | ||||||||||||
|
|
||||||||||||
| ### Database configuration | ||||||||||||
|
|
||||||||||||
| Either run PostgreSQL in Docker: | ||||||||||||
| `docker run --name pg-vulnerablecode -e POSTGRES_USER=vulnerablecode -e POSTGRES_PASSWORD=vulnerablecode -e POSTGRES_DB=vulnerablecode -p 5432:5432 postgres` | ||||||||||||
| - Python 3.8+ | ||||||||||||
| - PostgreSQL 9+ | ||||||||||||
| - Compiler toolchain and development files for Python and PostgreSQL | ||||||||||||
|
|
||||||||||||
| Or without: | ||||||||||||
| On Debian-based distros, these can be installed with `sudo apt install python3-venv python3-dev postgresql libpq-dev build-essential`. | ||||||||||||
|
|
||||||||||||
| **Database configuration** | ||||||||||||
| - Create a user named `vulnerablecode`. Use `vulnerablecode` as password when prompted: | ||||||||||||
| `sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb --pwprompt vulnerablecode` | ||||||||||||
|
|
||||||||||||
| - Create a databased named `vulnerablecode`: | ||||||||||||
| `createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode --password --host=localhost --port=5432 vulnerablecode` | ||||||||||||
|
|
||||||||||||
| ### Application dependencies | ||||||||||||
| **Application dependencies** | ||||||||||||
|
|
||||||||||||
| Activate a virtualenv, install dependencies, and run the database migrations: | ||||||||||||
| Create a virtualenv, install dependencies, and run the database migrations: | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| python3 -m venv venv | ||||||||||||
|
|
@@ -132,13 +137,10 @@ systemctl --user daemon-reload && systemctl --user start vulnerablecode.timer | |||||||||||
| ## API | ||||||||||||
|
|
||||||||||||
| Start the webserver | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| DJANGO_DEV=1 python manage.py runserver | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| In your browser access: | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| http://127.0.0.1:8000/api/docs | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| version: '3' | ||
|
sbs2001 marked this conversation as resolved.
|
||
|
|
||
| services: | ||
| web: | ||
| environment: | ||
| - DJANGO_DEV=1 | ||
| - VC_DB_HOST=db | ||
| build: . | ||
| command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000" | ||
| container_name: "vulnerablecode" | ||
| volumes: | ||
| - .:/vulnerablecode | ||
| ports: | ||
| - "8000:8000" | ||
| depends_on: | ||
| - db | ||
| db: | ||
| image: postgres | ||
| environment: | ||
| - POSTGRES_DB=vulnerablecode | ||
| - POSTGRES_USER=vulnerablecode | ||
| - POSTGRES_PASSWORD=vulnerablecode | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.