Skip to content

Commit 1d6e67e

Browse files
committed
✏️ Add prefix to all the env variables required by VulnerableCode
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
1 parent b608624 commit 1d6e67e

3 files changed

Lines changed: 28 additions & 148 deletions

File tree

README.md

Lines changed: 23 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,43 @@
1-
21

32
<div align="center">
4-
53
<h1>VulnerableCode</h1>
64

7-
8-
95
[![Build Status](https://travis-ci.org/nexB/vulnerablecode.svg?branch=develop)](https://travis-ci.org/nexB/vulnerablecode)
10-
116
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
12-
137
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-360/)
14-
158
![stability-wip](https://img.shields.io/badge/stability-work_in_progress-lightgrey.svg)
16-
179
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/aboutcode-org/vulnerablecode)
18-
1910
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
2011

21-
22-
2312
![zz_comp](https://user-images.githubusercontent.com/28975399/89056138-2c8a8300-d379-11ea-882e-f28f38789cdc.png)
24-
2513
</div>
2614

27-
28-
29-
3015

31-
## The What
3216

33-
17+
## The What
3418

3519
VulnerableCode is a FOSS database of vulnerabilities and the FOSS packages they impact. It is made by the FOSS community to improve and secure the open source software ecosystem.
3620

37-
38-
3921
## The Why
4022

41-
42-
4323
The existing solutions are commercial proprietary vulnerability databases, which in itself does not make sense because the data is about FOSS.
4424

45-
46-
4725
National Vulnerability Database which is the primary data source for all things security, is not particulary catered to address FOSS security issues, because:
4826

49-
50-
51-
1. It predates explosion of FOSS software usage
52-
53-
2. It's data format reflects commercial vendor-centric point of view, this is due to the usage of [CPE](https://nvd.nist.gov/products/cpe) to map vulnerabilities and the packages.
54-
55-
3. CPEs are just not designed to map FOSS to vulnerabilities owing to their vendor-product centric semantics. This makes it really hard to answer the fundamental question "Is package foo vulnerable to vulnerability bar?"
56-
57-
27+
1. It predates explosion of FOSS software usage
28+
2. It's data format reflects commercial vendor-centric point of view, this is due to the usage of [CPE](https://nvd.nist.gov/products/cpe) to map vulnerabilities and the packages.
29+
3. CPEs are just not designed to map FOSS to vulnerabilities owing to their vendor-product centric semantics. This makes it really hard to answer the fundamental question "Is package foo vulnerable to vulnerability bar?"
5830

5931
## The How
6032

61-
62-
6333
VulnerableCode independently aggregates many software vulnerability data sources that can easily be recreated in a decentralized fashion. These data sources include security advisories published by distros, package managers etc. Due to this the data obtained is not generalized to apply for other ecosystems. This increases the accuracy as the same version of a package across different distros may or may not be vulnerable to some vulnerability.
6434

65-
66-
67-
The packages are identified using [PURL](https://github.com/package-url/purl-spec) rather than CPEs. This makes it really easy to answer questions like "Is package foo vulnerable to vulnerability bar ? ".
68-
69-
35+
The packages are identified using [PURL](https://github.com/package-url/purl-spec) rather than CPEs. This makes it really easy to answer questions like "Is package foo vulnerable to vulnerability bar ? ".
7036

7137
The web interface enables community curation of data by enabling addition of new packages, vulnerabilities and modifying the relationships between them as shown in GIF. Along with the web interface the API allows seamless consumption of the data.
7238

73-
74-
7539
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)
7640

77-
7841
## Setting up VulnerableCode
7942

8043
Clone the source code:
@@ -84,184 +47,101 @@ git clone https://github.com/nexB/vulnerablecode.git
8447
cd vulnerablecode
8548
```
8649

87-
8850
### Using Docker Compose
89-
9051
The easiest way to set up VulnerableCode is by using the docker containers.
9152
For this you need to have the following installed.
92-
93-
- Docker Engine. Find instructions to install it [here](https://docs.docker.com/get-docker/)
94-
- Docker Compose. Find instructions to install it [here](https://docs.docker.com/compose/install/#install-compose)
53+
- Docker Engine. Find instructions to install it here
54+
- Docker Compose. Find instructions to install it here
9555

9656
Use `sudo docker-compose up` to start VulnerableCode.
57+
Access VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/ .
9758

98-
Access VulnerableCode at `http://localhost:8000/` or at `http://127.0.0.1:8000/` .
99-
100-
Use `sudo docker-compose exec web bash` to access the VulnerableCode container. From here you can run access `manage.py` and run management commands to import data as specified below.
101-
102-
### Without docker
103-
59+
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.
10460

61+
### Without Docker Compose
10562
**System requirements**
106-
107-
- Python 3.8+
108-
109-
- PostgreSQL 9+ or [Docker](https://hub.docker.com/search/?type=edition&offering=community)
11063

64+
- Python 3.8+
65+
- PostgreSQL 9+
11166
- Compiler toolchain and development files for Python and PostgreSQL
11267

113-
114-
115-
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.
116-
117-
68+
On Debian-based distros, these can be installed with `sudo apt install python3-venv python3-dev postgresql libpq-dev build-essential`.
11869

11970
**Database configuration**
120-
121-
12271
- Create a user named `vulnerablecode`. Use `vulnerablecode` as password when prompted:
72+
`sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb --pwprompt vulnerablecode`
12373

124-
`sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb --pwprompt vulnerablecode`
125-
126-
127-
- Create a database named `vulnerablecode`:
128-
129-
`createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode --password --host=localhost --port=5432 vulnerablecode`
130-
131-
74+
- Create a databased named `vulnerablecode`:
75+
`createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode --password --host=localhost --port=5432 vulnerablecode`
13276

13377
**Application dependencies**
13478

135-
136-
137-
Activate a virtualenv, install dependencies, and run the database migrations:
138-
139-
79+
Create a virtualenv, install dependencies, and run the database migrations:
14080

14181
```
142-
14382
python3 -m venv venv
144-
14583
source venv/bin/activate
146-
14784
pip install -r requirements.txt
148-
14985
DJANGO_DEV=1 python manage.py migrate
150-
15186
```
15287

153-
154-
15588
The environment variable `DJANGO_DEV` is used to load settings suitable for development, defined in `vulnerablecode/dev.py`. If you don't want to type
156-
15789
it every time use `export DJANGO_DEV=1` instead.
15890

159-
160-
16191
When not running in development mode, an environment variable named `SECRET_KEY` needs to be set. The recommended way to generate this key is to use
162-
16392
the code Django includes for this purpose: `SECRET_KEY=$(python -c "from django.core.management import utils; print(utils.get_random_secret_key())")`.
16493

165-
166-
16794
## Tests
16895

169-
170-
17196
```
172-
17397
pycodestyle --exclude=migrations,settings.py,venv,lib_oval.py,test_ubuntu.py,test_suse.py,test_data_source.py --max-line-length=100 .
174-
175-
DJANGO_DEV=1 pytest
176-
98+
DJANGO_DEV=1 pytest
17799
```
178-
179100
## Data import
180101

181-
182-
183102
```
184-
185103
DJANGO_DEV=1 python manage.py import --all
186-
187104
```
188105

189-
190-
191106
If you want to run the import periodically, you can use a systemd timer:
192107

193-
194-
195108
```
196-
197109
$ cat ~/.config/systemd/user/vulnerablecode.service
198110
199-
200-
201111
[Unit]
202-
203112
Description=Update vulnerability database
204113
205-
206-
207114
[Service]
208-
209115
Type=oneshot
210-
211116
Environment="DJANGO_DEV=1"
212-
213117
ExecStart=/path/to/venv/bin/python /path/to/vulnerablecode/manage.py import --all
214118
215-
216-
217119
$ cat ~/.config/systemd/user/vulnerablecode.timer
218120
219-
220-
221121
[Unit]
222-
223122
Description=Periodically update vulnerability database
224123
225-
226-
227124
[Timer]
228-
229125
OnCalendar=daily
230126
231-
232-
233127
[Install]
234-
235128
WantedBy=multi-user.target
236-
237129
```
238130

239-
240-
241131
Start it with
242132

243-
244-
245133
```
246-
247134
systemctl --user daemon-reload && systemctl --user start vulnerablecode.timer
248-
249135
```
250136

251-
252-
253137
## API
254138

255-
256-
257-
Start the web server.
258-
259-
In your browser access:
260-
139+
Start the webserver
140+
```
141+
DJANGO_DEV=1 python manage.py runserver
142+
```
143+
In your browser access:
261144
```
262-
263145
http://127.0.0.1:8000/api/docs
264-
265146
```
266-
267147
For full documentation about API endpoints.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
web:
55
environment:
66
- DJANGO_DEV=1
7-
- DB_HOST=db
7+
- VC_DB_HOST=db
88
build: .
99
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
1010
container_name: "vulnerablecode"

vulnerablecode/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@
9191
DATABASES = {
9292
'default': {
9393
'ENGINE': 'django.db.backends.postgresql',
94-
'NAME': os.environ.get('DB_NAME','vulnerablecode'),
95-
'USER': os.environ.get('DB_USER','vulnerablecode'),
96-
'PASSWORD': os.environ.get('DB_PASSWORD','vulnerablecode'),
97-
'HOST': os.environ.get('DB_HOST', 'localhost'),
94+
'NAME': os.environ.get('VC_DB_NAME','vulnerablecode'),
95+
'USER': os.environ.get('VC_DB_USER','vulnerablecode'),
96+
'PASSWORD': os.environ.get('VC_DB_PASSWORD','vulnerablecode'),
97+
'HOST': os.environ.get('VC_DB_HOST', 'localhost'),
9898
'PORT': '5432',
9999
}
100100
}

0 commit comments

Comments
 (0)