Skip to content

Commit 242ac17

Browse files
authored
Merge pull request #316 from nexB/improve-docs
Improve docs
2 parents 84fcee0 + 029f259 commit 242ac17

2 files changed

Lines changed: 153 additions & 133 deletions

File tree

README.rst

Lines changed: 153 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,115 @@
11
VulnerableCode
22
==============
33

4-
|Build Status| |License| |Python 3.8| |stability-wip| |Gitter chat| |PRs
5-
Welcome|
4+
|Build Status| |License| |Python 3.8| |stability-wip| |Gitter chat|
65

7-
.. image:: README.gif
86

7+
.. |Build Status| image:: https://travis-ci.org/nexB/vulnerablecode.svg?branch=develop
8+
:target: https://travis-ci.org/nexB/vulnerablecode
9+
.. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
10+
:target: https://opensource.org/licenses/Apache-2.0
11+
.. |Python 3.8| image:: https://img.shields.io/badge/python-3.8-blue.svg
12+
:target: https://www.python.org/downloads/release/python-380/
13+
.. |stability-wip| image:: https://img.shields.io/badge/stability-work_in_progress-lightgrey.svg
14+
.. |Gitter chat| image:: https://badges.gitter.im/gitterHQ/gitter.png
15+
:target: https://gitter.im/aboutcode-org/vulnerablecode
916

10-
The What
11-
--------
1217

13-
VulnerableCode is a FOSS database of vulnerabilities and the FOSS
14-
packages they impact. It is made by the FOSS community to improve and
15-
secure the open source software ecosystem.
18+
VulnerableCode is a free and open database of FOSS software package
19+
vulnerabilities and the tools to create and keep the data current.
1620

17-
The Why
18-
-------
21+
It is made by the FOSS community to improve and secure the open source software
22+
ecosystem.
1923

20-
The existing solutions are commercial proprietary vulnerability
21-
databases, which in itself does not make sense because the data is about
22-
FOSS.
24+
.. image:: README.gif
2325

24-
National Vulnerability Database which is the primary data source for all
25-
things security, is not particularly catered to address FOSS security
26-
issues, because:
26+
Why?
27+
----
28+
29+
The existing solutions are commercial proprietary vulnerability databases, which
30+
in itself does not make sense because the data is about FOSS (Free and Open
31+
Source Software).
32+
33+
The National Vulnerability Database which is a primary centralized data source
34+
for known vulnerabilities is not particularly well suited to address FOSS
35+
security issues because:
2736

2837
1. It predates the explosion of FOSS software usage
29-
2. It's data format reflects a commercial vendor-centric point of view,
30-
this is due to the usage of
31-
`CPE <https://nvd.nist.gov/products/cpe>`__ to map vulnerabilities
32-
and the packages.
33-
3. CPEs are just not designed to map FOSS to vulnerabilities owing to
34-
their vendor-product centric semantics. This makes it really hard to
35-
answer the fundamental question "Is package foo vulnerable to
36-
vulnerability bar?"
37-
38-
39-
The How
40-
-------
41-
42-
VulnerableCode independently aggregates many software vulnerability data
43-
sources that can easily be recreated in a decentralized fashion. These
44-
data sources (see complete list `here <./SOURCES.rst>`_) include security
45-
advisories published by distros, package managers, etc. Due to this, the
46-
data obtained is not generalized to apply for other ecosystems. This
47-
increases the accuracy as the same version of a package across different distros
48-
may or may not be vulnerable to some vulnerability.
49-
50-
The packages are identified using
51-
`PURL <https://github.com/package-url/purl-spec>`__ rather than CPEs.
52-
This makes it really easy to answer questions like "Is package foo
53-
vulnerable to vulnerability bar ? ".
54-
55-
The web interface enables community curation of data by enabling
56-
the addition of new packages, vulnerabilities, and modifying the
57-
relationships between them as shown in GIF. Along with the web interface
58-
the API allows seamless consumption of the data.
38+
2. It's data format reflects a commercial vendor-centric point of view in part
39+
due to the usage of `CPE <https://nvd.nist.gov/products/cpe>`__ to map
40+
vulnerabilities to existing packages.
41+
3. CPEs are just not designed to map FOSS to vulnerabilities owing to their
42+
vendor-product centric semantics. This makes it really hard to answer the
43+
fundamental questions "Is package foo vulnerable" and "Is package foo
44+
vulnerable to vulnerability bar?"
45+
46+
How
47+
---
48+
49+
VulnerableCode independently aggregates many software vulnerability data sources
50+
and supports data re-creation in a decentralized fashion. These data sources
51+
(see complete list `here <./SOURCES.rst>`_) include security advisories
52+
published by Linux and BSD distributions, application software package managers
53+
and package repositories, FOSS projects, GitHub and more. Thanks to this
54+
approach, the data is focused on specific ecosystems yet aggregated in a single
55+
database that enables querying a richer graph of relations between multiple
56+
incarnations of a package. Being specific increases the accuracy and validity
57+
of the data as the same version of an upstream package across different
58+
ecosystems may or may not be vulnerable to the same vulnerability.
59+
60+
The packages are identified using Package URL `PURL
61+
<https://github.com/package-url/purl-spec>`__ as primary identifiers rather than
62+
CPEs. This makes answers to questions such as "Is package foo vulnerable
63+
to vulnerability bar?" much more accurate and easy to interpret.
64+
65+
66+
The primary access to the data is through a REST API.
67+
68+
In addition, an emerging web interface goal is to support vulnerabilities data
69+
browsing and search and progressively to enable community curation of the data
70+
with the addition of new packages and vulnerabilities, and reviewing and
71+
updating their relationships.
5972

6073
We also plan to mine for vulnerabilities which didn't receive any
6174
exposure due to various reasons like but not limited to the complicated
6275
procedure to receive CVE ID or not able to classify a bug as a security
6376
compromise.
6477

65-
Check VulnerableCode at `Open Source Summit 2020
66-
<https://ossna2020.sched.com/event/c46p/why-is-there-no-free-software-vulnerability-database-philippe-ombredanne-aboutcodeorg-and-nexb-inc-michael-herzog-nexb-inc>`__
78+
Recent presentations:
79+
80+
- `Open Source Summit 2020 <docs/Why-Is-There-No-Free-Software-Vulnerability-Database-v1.0.pdf>`__
81+
82+
6783

6884
Setting up VulnerableCode
6985
-------------------------
7086

71-
Clone the source code:
72-
73-
::
87+
First clone the source code::
7488

7589
git clone https://github.com/nexB/vulnerablecode.git
7690
cd vulnerablecode
7791

92+
93+
94+
7895
Using Docker Compose
7996
~~~~~~~~~~~~~~~~~~~~
8097

81-
An easy way to set up VulnerableCode is with docker containers and
82-
docker compose. For this you need to have the following installed.
98+
An easy way to set up VulnerableCode is with docker containers and docker
99+
compose. For this you need to have the following installed.
83100

84-
- Docker Engine. Find instructions to install it `here <https://docs.docker.com/get-docker/>`__
85-
- Docker Compose. Find instructions to install it `here <https://docs.docker.com/compose/install/#install-compose>`__
101+
- Docker Engine. Find instructions to install it
102+
`here <https://docs.docker.com/get-docker/>`__
103+
- Docker Compose. Find instructions to install it
104+
`here <https://docs.docker.com/compose/install/#install-compose>`__
86105

87-
Use ``sudo docker-compose up`` to start VulnerableCode. Access
88-
VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/ .
106+
Use ``sudo docker-compose up`` to start VulnerableCode. Then access
107+
VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/
89108

90109
Use ``sudo docker-compose exec web bash`` to access the VulnerableCode
91-
container. From here you can access ``manage.py`` and run management
92-
commands to import data as specified below.
110+
container. From here you can access ``manage.py`` and run management commands
111+
to import data as specified below.
112+
93113

94114
Without Docker Compose
95115
~~~~~~~~~~~~~~~~~~~~~~
@@ -100,50 +120,57 @@ Without Docker Compose
100120
- PostgreSQL 9+
101121
- Compiler toolchain and development files for Python and PostgreSQL
102122

103-
On Debian-based distros, these can be installed with
104-
``sudo apt install python3-venv python3-dev postgresql libpq-dev build-essential``.
123+
On Debian-based distros, these can be installed with::
105124

106-
**Database configuration** - Create a user named ``vulnerablecode``. Use
107-
``vulnerablecode`` as password when prompted:
108-
``sudo -u postgres createuser --no-createrole --no-superuser --login --inherit --createdb --pwprompt vulnerablecode``
125+
sudo apt-get install python3-venv python3-dev postgresql libpq-dev build-essential
109126

110-
- Create a databased named ``vulnerablecode``:
111-
``createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode --password --host=localhost --port=5432 vulnerablecode``
112127

113-
**Application dependencies**
128+
**Database configuration**
129+
130+
- Create a user named ``vulnerablecode``. Use ``vulnerablecode`` as password
131+
when prompted::
114132

115-
Create a virtualenv, install dependencies, and run the database
116-
migrations:
133+
sudo -u postgres createuser --no-createrole --no-superuser --login \
134+
--inherit --createdb --pwprompt vulnerablecode``
117135

118-
::
136+
- Create a databased named ``vulnerablecode``::
137+
138+
createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode \
139+
--password --host=localhost --port=5432 vulnerablecode
140+
141+
142+
**Application dependencies**
143+
144+
Create a virtualenv, install dependencies, and run the database migrations::
119145

120146
python3 -m venv venv
121147
source venv/bin/activate
122148
pip install -r requirements.txt
123149
DJANGO_DEV=1 python manage.py migrate
124150

125-
The environment variable ``DJANGO_DEV`` is used to load settings
126-
suitable for development, defined in ``vulnerablecode/dev.py``. If you
151+
The environment variable ``DJANGO_DEV`` is used to load settings suitable for
152+
development, defined in ``vulnerablecode/dev.py``. If you
127153
don't want to type it every time use ``export DJANGO_DEV=1`` instead.
154+
Do not use `DJANGO_DEV` in a production environment.
155+
156+
157+
For a production mode, an environment variable named ``SECRET_KEY`` needs to be
158+
set. The recommended way to generate this key is to use the code Django includes
159+
for this purpose::
160+
161+
SECRET_KEY=$(python -c "from django.core.management import utils; print(utils.get_random_secret_key())")
128162

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

134164
Using Nix
135165
~~~~~~~~~
136166

137-
You can install VulnerableCode with `Nix <https://nixos.org/download.html>`__ (`Flake <https://nixos.wiki/wiki/Flakes>`__ support is needed).
138-
139-
::
167+
You can install VulnerableCode with `Nix <https://nixos.org/download.html>`__
168+
(`Flake <https://nixos.wiki/wiki/Flakes>`__ support is needed)::
140169

141170
cd etc/nix
142171
nix --print-build-logs flake check # build & run tests
143172

144-
There are several options to use the Nix version
145-
146-
::
173+
There are several options to use the Nix version::
147174

148175
# Enter an interactive environment with all dependencies set up.
149176
cd etc/nix
@@ -159,53 +186,74 @@ There are several options to use the Nix version
159186

160187
**Keeping the Nix setup in sync**
161188

162-
The Nix installation uses `mach-nix <https://github.com/DavHau/mach-nix>`__ to handle Python dependencies because some dependencies are currently not available as Nix packages.
163-
All Python dependencies are automatically fetched from ``./requirements.txt``.
164-
If the ``mach-nix``-based installation fails, you might need to update ``mach-nix`` itself and the `pypi-deps-db <https://github.com/DavHau/pypi-deps-db>`_ version in use (see ``etc/nix/flake.nix:inputs.machnix`` and ``machnixFor.pypiDataRev``).
189+
The Nix installation uses `mach-nix <https://github.com/DavHau/mach-nix>`__ to
190+
handle Python dependencies because some dependencies are currently not available
191+
as Nix packages. All Python dependencies are automatically fetched from
192+
``./requirements.txt``. If the ``mach-nix``-based installation fails, you might
193+
need to update ``mach-nix`` itself and the `pypi-deps-db
194+
<https://github.com/DavHau/pypi-deps-db>`_ version in use (see
195+
``etc/nix/flake.nix:inputs.machnix`` and ``machnixFor.pypiDataRev``).
196+
197+
Non-Python dependencies are curated in::
198+
199+
etc/nix/flake.nix:vulnerablecode.propagatedBuildInputs
165200

166-
Non-Python dependencies are curated in ``etc/nix/flake.nix:vulnerablecode.propagatedBuildInputs``.
167201

168202

169-
Tests
170-
-----
203+
Run Tests
204+
---------
171205

172-
::
206+
Use these commands to run code style checks and the test suite::
173207

174208
pycodestyle --exclude=migrations,settings.py,venv,lib_oval.py,test_ubuntu.py,test_suse.py,test_data_source.py --max-line-length=100 .
175209
DJANGO_DEV=1 pytest
176210

211+
177212
Data import
178213
-----------
179214

180-
Many data importers use GitHub APIs. For this, first set up value of the ``GH_TOKEN`` environment variable by running :
181-
182-
::
215+
Some data importers use the GitHub APIs. For this, export the ``GH_TOKEN``
216+
environment variable with::
183217

184218
export GH_TOKEN=yourgithubtoken
185219

186220

187-
See `GitHub docs <https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token>`_ for instructions on how to obtain your GitHub token.
221+
See `GitHub docs
222+
<https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token>`_
223+
for instructions on how to obtain your GitHub token.
188224

189-
190-
To run all data importers use :
191-
::
225+
To run all data importers use::
192226

193227
DJANGO_DEV=1 python manage.py import --all
194228

195-
To list available importers use :
196-
::
229+
To list available importers use::
197230

198231
DJANGO_DEV=1 python manage.py import --list
199232

200-
To run specific importers :
201-
::
233+
To run specific importers::
202234

203235
DJANGO_DEV=1 python manage.py import rust npm
204236

205237

206-
If you want to run the import periodically, you can use a systemd timer:
238+
REST API access
239+
---------------
240+
241+
Start the webserver::
242+
243+
DJANGO_DEV=1 python manage.py runserver
244+
245+
246+
For full documentation about API endpoints use this URL::
247+
248+
http://127.0.0.1:8000/api/docs
249+
207250

208-
::
251+
252+
Continuous periodic Data import
253+
-------------------------------
254+
255+
256+
If you want to run the import periodically, you can use a systemd timer::
209257

210258
$ cat ~/.config/systemd/user/vulnerablecode.service
211259

@@ -228,37 +276,9 @@ If you want to run the import periodically, you can use a systemd timer:
228276
[Install]
229277
WantedBy=multi-user.target
230278

231-
Start it with
232-
233-
::
234279

235-
systemctl --user daemon-reload && systemctl --user start vulnerablecode.timer
280+
Start this "timer" with::
236281

237-
API
238-
---
239-
240-
Start the webserver
241-
242-
::
243-
244-
DJANGO_DEV=1 python manage.py runserver
245-
246-
In your browser access:
247-
248-
::
249-
250-
http://127.0.0.1:8000/api/docs
282+
systemctl --user daemon-reload
283+
systemctl --user start vulnerablecode.timer
251284

252-
For full documentation about API endpoints.
253-
254-
.. |Build Status| image:: https://travis-ci.org/nexB/vulnerablecode.svg?branch=develop
255-
:target: https://travis-ci.org/nexB/vulnerablecode
256-
.. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
257-
:target: https://opensource.org/licenses/Apache-2.0
258-
.. |Python 3.8| image:: https://img.shields.io/badge/python-3.8-blue.svg
259-
:target: https://www.python.org/downloads/release/python-360/
260-
.. |stability-wip| image:: https://img.shields.io/badge/stability-work_in_progress-lightgrey.svg
261-
.. |Gitter chat| image:: https://badges.gitter.im/gitterHQ/gitter.png
262-
:target: https://gitter.im/aboutcode-org/vulnerablecode
263-
.. |PRs Welcome| image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
264-
:target: http://makeapullrequest.com
Binary file not shown.

0 commit comments

Comments
 (0)