Skip to content

Commit f282192

Browse files
committed
Initial Documentation
We're forking from ScancodeIO docs <scancodeio.readthedocs.io/> Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 28f5659 commit f282192

18 files changed

+925
-496
lines changed

README.rst

Lines changed: 23 additions & 246 deletions
Original file line numberDiff line numberDiff line change
@@ -23,267 +23,44 @@ ecosystem.
2323

2424
.. image:: README.gif
2525

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:
36-
37-
1. It predates the explosion of FOSS software usage
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.
72-
73-
We also plan to mine for vulnerabilities which didn't receive any
74-
exposure due to various reasons like but not limited to the complicated
75-
procedure to receive CVE ID or not able to classify a bug as a security
76-
compromise.
77-
78-
Recent presentations:
79-
80-
- `Open Source Summit 2020 <docs/Why-Is-There-No-Free-Software-Vulnerability-Database-v1.0.pdf>`__
81-
82-
83-
84-
Setting up VulnerableCode
85-
-------------------------
86-
87-
First clone the source code::
88-
89-
git clone https://github.com/nexB/vulnerablecode.git
90-
cd vulnerablecode
91-
92-
93-
Using Docker Compose
94-
~~~~~~~~~~~~~~~~~~~~~~
95-
96-
Please find the docker documentation in `Docker Installation <https://vulnerablecode.readthedocs.io/en/latest/getting-started/docker_installation.html>`__
26+
Getting started
27+
---------------
9728

98-
TL;DR
99-
""""""
29+
Run with Docker
30+
^^^^^^^^^^^^^^^^
10031

10132
.. code-block:: bash
10233
10334
git clone https://github.com/nexB/vulnerablecode.git && cd vulnerablecode
10435
make envfile
10536
docker-compose build
10637
docker-compose up
38+
docker-compose run vulnerablecode ./manage.py import --list
10739
108-
Go to http://localhost:8000/ on a web browser to access the web UI.
109-
110-
111-
Without Docker Compose
112-
~~~~~~~~~~~~~~~~~~~~~~
113-
114-
**System requirements**
115-
116-
- Python 3.8+
117-
- PostgreSQL 9+
118-
- Compiler toolchain and development files for Python and PostgreSQL
119-
120-
On Debian-based distros, these can be installed with::
121-
122-
sudo apt-get install python3-venv python3-dev postgresql libpq-dev build-essential
123-
124-
125-
**Database configuration**
126-
127-
- Create a user named ``vulnerablecode``. Use ``vulnerablecode`` as password
128-
when prompted::
129-
130-
sudo -u postgres createuser --no-createrole --no-superuser --login \
131-
--inherit --createdb --pwprompt vulnerablecode``
132-
133-
- Create a databased named ``vulnerablecode``::
134-
135-
createdb --encoding=utf-8 --owner=vulnerablecode --user=vulnerablecode \
136-
--password --host=localhost --port=5432 vulnerablecode
137-
138-
139-
**Application dependencies**
140-
141-
Create a virtualenv, install dependencies, generate static files and run the database migrations::
142-
143-
make envfile
144-
python3 -m venv venv
145-
source venv/bin/activate
146-
pip install -r requirements.txt
147-
python manage.py collectstatic
148-
python manage.py migrate
149-
150-
151-
For a production mode, an environment variable named ``SECRET_KEY`` needs to be
152-
set. The recommended way to generate this key is to use the code Django includes
153-
for this purpose::
154-
155-
SECRET_KEY=$(python -c "from django.core.management import utils; print(utils.get_random_secret_key())")
156-
157-
You will also need to setup the `ALLOWED_HOSTS` array inside `vulnerablecode/settings.py` according to
158-
[django specifications](https://docs.djangoproject.com/en/3.2/ref/settings/#allowed-hosts). One example would be:
159-
.. code-block:: python
160-
161-
ALLOWED_HOSTS = ['vulnerablecode.your.domain.example.com']
162-
163-
You can specify several hosts by separating them with a comma (`,`)
164-
165-
Using Nix
166-
~~~~~~~~~
167-
168-
You can install VulnerableCode with `Nix <https://nixos.org/download.html>`__
169-
(`Flake <https://nixos.wiki/wiki/Flakes>`__ support is needed)::
40+
At this point, the VulnerableCode app should be running at port ``8000`` on your Docker host.
17041

171-
cd etc/nix
172-
nix-shell -p nixFlakes --run "nix --print-build-logs flake check " # build & run tests
42+
Local development installation
43+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17344

174-
There are several options to use the Nix version::
175-
176-
# Enter an interactive environment with all dependencies set up.
177-
cd etc/nix
178-
nix develop
179-
> ../../manage.py ... # invoke the local checkout
180-
> vulnerablecode-manage.py ... # invoke manage.py as installed in the nix store
181-
182-
# Test the import prodecure using the Nix version.
183-
etc/nix/test-import-using-nix.sh --all # import everything
184-
# Test the import using the local checkout.
185-
INSTALL_DIR=. etc/nix/test-import-using-nix.sh ruby # import ruby only
186-
187-
188-
**Keeping the Nix setup in sync**
189-
190-
The Nix installation uses `mach-nix <https://github.com/DavHau/mach-nix>`__ to
191-
handle Python dependencies because some dependencies are currently not available
192-
as Nix packages. All Python dependencies are automatically fetched from
193-
``./requirements.txt``. If the ``mach-nix``-based installation fails, you might
194-
need to update ``mach-nix`` itself and the `pypi-deps-db
195-
<https://github.com/DavHau/pypi-deps-db>`_ version in use (see
196-
``etc/nix/flake.nix:inputs.machnix`` and ``machnixFor.pypiDataRev``).
197-
198-
Non-Python dependencies are curated in::
199-
200-
etc/nix/flake.nix:vulnerablecode.propagatedBuildInputs
201-
202-
203-
204-
Run Tests
205-
---------
206-
Make sure to install dev dependencies by running ``pip install -r requirements-dev.txt``
207-
Use these commands to run code style checks and the test suite::
208-
209-
black -l 100 --check .
210-
python -m pytest
211-
212-
213-
.. _Data import:
214-
215-
Data import
216-
-----------
217-
218-
Some data importers use the GitHub APIs. For this, export the ``GH_TOKEN``
219-
environment variable with::
220-
221-
export GH_TOKEN=yourgithubtoken
222-
223-
If you are running behind a proxy, you will need to setup the standard ``https_proxy`` variable.
224-
225-
export https_proxy=https?://<proxy>:<port>
226-
227-
See `GitHub docs
228-
<https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token>`_
229-
for instructions on how to obtain your GitHub token.
230-
231-
To run all data importers use::
232-
233-
python manage.py import --all
234-
235-
To list available importers use::
236-
237-
python manage.py import --list
238-
239-
To run specific importers::
240-
241-
python manage.py import rust npm
242-
243-
244-
REST API access
245-
---------------
246-
247-
Start the webserver::
248-
249-
python manage.py runserver
250-
251-
252-
For full documentation about API endpoints use this URL::
253-
254-
http://127.0.0.1:8000/api/docs
255-
256-
257-
258-
Continuous periodic Data import
259-
-------------------------------
260-
261-
262-
If you want to run the import periodically, you can use a systemd timer::
263-
264-
$ cat ~/.config/systemd/user/vulnerablecode.service
265-
266-
[Unit]
267-
Description=Update vulnerability database
268-
269-
[Service]
270-
Type=oneshot
271-
ExecStart=/path/to/venv/bin/python /path/to/vulnerablecode/manage.py import --all
272-
273-
$ cat ~/.config/systemd/user/vulnerablecode.timer
45+
.. code-block:: bash
27446
275-
[Unit]
276-
Description=Periodically update vulnerability database
47+
sudo apt-get install \
48+
python3-venv python3-dev postgresql libpq-dev build-essential
49+
git clone https://github.com/nexB/vulnerablecode.git && cd vulnerablecode
50+
make dev envfile postgres
51+
make test
52+
make run
27753
278-
[Timer]
279-
OnCalendar=daily
54+
At this point, the VulnerableCode app should be running at port ``8000`` on your machine.
28055

281-
[Install]
282-
WantedBy=multi-user.target
56+
Populate VulnerableCode data
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28358

59+
To run all importers and improvers use:
28460

285-
Start this "timer" with::
61+
.. code-block:: bash
28662
287-
systemctl --user daemon-reload
288-
systemctl --user start vulnerablecode.timer
63+
./manage.py import --all
64+
./manage.py improve --all
28965
66+
Read more about VulnerableCode here: https://vulnerablecode.readthedocs.org/

SOURCES.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
2-
|Importer Name: | Data Source |Ecosystems Covered |
3-
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
2+
|Importer Name | Data Source |Ecosystems Covered |
3+
+================+======================================================================================================+====================================================+
44
|rust | https://github.com/RustSec/advisory-db |rust crates |
55
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
66
|alpine | https://secdb.alpinelinux.org/ |alpine packages |
@@ -48,6 +48,6 @@
4848
|suse_scores | https://ftp.suse.com/pub/projects/security/yaml/suse-cvss-scores.yaml |vulnerability severity scores by SUSE |
4949
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
5050
|mozilla | https://github.com/mozilla/foundation-security-advisories |mozilla |
51-
+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------+
51+
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
5252
|mattermost | https://mattermost.com/security-updates/ |mattermost server, desktop and mobile apps |
5353
+----------------+------------------------------------------------------------------------------------------------------+----------------------------------------------------+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. _command_line_interface:
2+
3+
Command Line Interface
4+
======================
5+
6+
The main entry point is Django's :guilabel:`manage.py` management commands.
7+
8+
``$ ./manage.py --help``
9+
-----------------------
10+
11+
Lists all sub-commands available, including Django built-in commands.
12+
VulnerableCode's own commands are listed under the ``[vulnerabilities]`` section::
13+
14+
$ ./mange.py --help
15+
...
16+
[vulnerabilities]
17+
create_cpe_to_purl_map
18+
importer
19+
improver
20+
21+
``$ ./manage.py <subcommand> --help``
22+
---------------------------------------
23+
24+
Displays help for the provided sub-command.
25+
26+
For example::
27+
28+
$ ./manage.py import --help
29+
usage: manage.py import [-h] [--list] [--all] [--version] [-v {0,1,2,3}]
30+
[--settings SETTINGS] [--pythonpath PYTHONPATH]
31+
[--traceback] [--no-color] [--force-color]
32+
[--skip-checks]
33+
[sources [sources ...]]
34+
35+
Import vulnerability data
36+
37+
positional arguments:
38+
sources Fully qualified importer name to run
39+
40+
41+
``$ ./manage.py import <importer-name>``
42+
------------------------------------------
43+
44+
Import vulnerability data using the given importer name.
45+
46+
Other variations:
47+
48+
* ``--list`` List all available importers
49+
* ``--all`` Run all available importers
50+
51+
``$ ./manage.py improve <improver-name>``
52+
------------------------------------------
53+
54+
Improve the imported vulnerability data using the given improver name.
55+
56+
Other variations:
57+
58+
* ``--list`` List all available improvers
59+
* ``--all`` Run all available improvers

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = "vulnerablecode"
20+
project = "VulnerableCode"
2121
copyright = "nexb Inc. and others"
2222
author = "nexb Inc. and others"
2323

docs/source/contribute/index.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)