-
-
Notifications
You must be signed in to change notification settings - Fork 264
Improve error handling and other misc. updates #267
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
19 commits
Select commit
Hold shift + click to select a range
7d6d31b
Add missing arg and disable doctests.
pombredanne 28e81a0
Disable doctests
pombredanne 50f5614
Ignore misc artifacts
pombredanne bf3cb2e
Add minimal setup.py
pombredanne f0077cc
Add basic setup.cfg and remove pytest.ini
pombredanne 1304093
Improve ReST doc
pombredanne 321c0c7
Convert README to ReST
pombredanne 480c419
Add basic configure script
pombredanne 97be6ec
Improve error handling during imports
pombredanne 8ef1ca2
Add more logging
pombredanne 3eebea8
Run code style tests only after tests proper
pombredanne 535bc14
Also install self with the new setup.py
pombredanne fb321e8
Run pycodestyle only on own code
pombredanne a014c3b
Remove unused import
pombredanne cab316f
Fix code style
pombredanne 2f1d394
Improve pytest configuration
pombredanne e7739d1
Disable failing safetyDB import #244
pombredanne 61490a2
Remove README.md now that we have a ReST version
pombredanne 4145c3b
Add animated GIF to version control and README
pombredanne 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 |
|---|---|---|
|
|
@@ -109,3 +109,13 @@ ENV/ | |
|
|
||
| # Staticfiles | ||
| staticfiles/ | ||
|
|
||
| # virtualenv | ||
| bin | ||
| include | ||
| lib64 | ||
| share | ||
|
|
||
|
|
||
| # pytest | ||
| .pytest_cache | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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,208 @@ | ||
| VulnerableCode | ||
| ============== | ||
|
|
||
| |Build Status| |License| |Python 3.8| |stability-wip| |Gitter chat| |PRs | ||
| Welcome| | ||
|
|
||
| .. image:: README.gif | ||
|
|
||
|
|
||
| The What | ||
| -------- | ||
|
|
||
| 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. | ||
|
|
||
| The Why | ||
| ------- | ||
|
|
||
| The existing solutions are commercial proprietary vulnerability | ||
| databases, which in itself does not make sense because the data is about | ||
| FOSS. | ||
|
|
||
| National Vulnerability Database which is the primary data source for all | ||
| things security, is not particulary catered to address FOSS security | ||
| issues, because: | ||
|
|
||
| 1. It predates explosion of FOSS software usage | ||
| 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. | ||
| 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?" | ||
|
|
||
|
|
||
| The How | ||
| ------- | ||
|
|
||
| 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. | ||
|
|
||
| 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 ? ". | ||
|
|
||
| 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. | ||
|
|
||
| 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>`__ | ||
|
|
||
| Setting up VulnerableCode | ||
| ------------------------- | ||
|
|
||
| Clone the source code: | ||
|
|
||
| :: | ||
|
|
||
| git clone https://github.com/nexB/vulnerablecode.git | ||
| cd vulnerablecode | ||
|
|
||
| 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 <https://docs.docker.com/get-docker/>`__ - Docker Compose. Find | ||
| instructions to install it | ||
| `here <https://docs.docker.com/compose/install/#install-compose>`__ | ||
|
|
||
| Use ``sudo docker-compose up`` to start VulnerableCode. Access | ||
| VulnerableCode at http://localhost:8000/ or at http://127.0.0.1:8000/ . | ||
|
|
||
| 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. | ||
|
|
||
| Without Docker Compose | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| **System requirements** | ||
|
|
||
| - Python 3.8+ | ||
| - PostgreSQL 9+ | ||
| - Compiler toolchain and development files for Python and PostgreSQL | ||
|
|
||
| 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** | ||
|
|
||
| Create a virtualenv, install dependencies, and run the database | ||
| migrations: | ||
|
|
||
| :: | ||
|
|
||
| python3 -m venv venv | ||
| source venv/bin/activate | ||
| pip install -r requirements.txt | ||
| DJANGO_DEV=1 python manage.py migrate | ||
|
|
||
| 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 it every time use ``export DJANGO_DEV=1`` instead. | ||
|
|
||
| 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 the code Django includes for this purpose: | ||
| ``SECRET_KEY=$(python -c "from django.core.management import utils; print(utils.get_random_secret_key())")``. | ||
|
|
||
| Tests | ||
| ----- | ||
|
|
||
| :: | ||
|
|
||
| pycodestyle --exclude=migrations,settings.py,venv,lib_oval.py,test_ubuntu.py,test_suse.py,test_data_source.py --max-line-length=100 . | ||
| DJANGO_DEV=1 pytest | ||
|
|
||
| Data import | ||
| ----------- | ||
|
|
||
| :: | ||
|
|
||
| DJANGO_DEV=1 python manage.py import --all | ||
|
|
||
| If you want to run the import periodically, you can use a systemd timer: | ||
|
|
||
| :: | ||
|
|
||
| $ cat ~/.config/systemd/user/vulnerablecode.service | ||
|
|
||
| [Unit] | ||
| Description=Update vulnerability database | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| Environment="DJANGO_DEV=1" | ||
| ExecStart=/path/to/venv/bin/python /path/to/vulnerablecode/manage.py import --all | ||
|
|
||
| $ cat ~/.config/systemd/user/vulnerablecode.timer | ||
|
|
||
| [Unit] | ||
| Description=Periodically update vulnerability database | ||
|
|
||
| [Timer] | ||
| OnCalendar=daily | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
|
|
||
| Start it with | ||
|
|
||
| :: | ||
|
|
||
| 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 | ||
|
|
||
| For full documentation about API endpoints. | ||
|
|
||
| .. |Build Status| image:: https://travis-ci.org/nexB/vulnerablecode.svg?branch=develop | ||
| :target: https://travis-ci.org/nexB/vulnerablecode | ||
| .. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg | ||
| :target: https://opensource.org/licenses/Apache-2.0 | ||
| .. |Python 3.8| image:: https://img.shields.io/badge/python-3.8-blue.svg | ||
| :target: https://www.python.org/downloads/release/python-360/ | ||
| .. |stability-wip| image:: https://img.shields.io/badge/stability-work_in_progress-lightgrey.svg | ||
| .. |Gitter chat| image:: https://badges.gitter.im/gitterHQ/gitter.png | ||
| :target: https://gitter.im/aboutcode-org/vulnerablecode | ||
| .. |PRs Welcome| image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square | ||
| :target: http://makeapullrequest.com | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for ReSTification. Why have both
README.mdandREADME.rst? Also they both don't look same. I don't care about alignment but please make the GIF work :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to remove the README.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I also need the gif to be in the repo to make things work.... this https://user-images.githubusercontent.com/28975399/89056138-2c8a8300-d379-11ea-882e-f28f38789cdc.png is not right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this is done now.