canonical / ubuntu-com-security-api

The API for CVEs and USNs data.
16 stars 9 forks source link
web-and-design

ubuntu.com security API

API functions under ubuntu.com for querying CVEs and security notices.

Local development

The simplest way to run the API locally is using the dotrun snap:

dotrun  # In the root of the project folder

This will start a database, import some sample data and run the server. Exiting the server with ctrl + c should automatically stop the database again.

Once the server has started, you can query CVEs, Notices or Releases from the API:

Or view the API documentation at http://0.0.0.0:8030/security/api/docs.

Managing the project

It's best to run and manage the project using dotrun if possible. This will install pip dependencies automatically, and will also include any expected system level dependencies.

Dotrun commands

A number of "scripts" are defined in package.json for running with dotrun. These could usually also be run with yarn run {scriptname}.

API and database management scripts

There are also some extra Python scripts to help with manipulating the API and database. There can also be run through dotrun:

dotrun exec scripts/create-cves.py scripts/payloads/cves.json  # Create a new CVE through the API
dotrun exec scripts/create-notice.py scripts/payloads/usn-4414-2.json  # Create a Notice through the API
dotrun exec scripts/create-release.py scripts/payloads/testy.json  # Create a Release through the API
dotrun exec scripts/delete-cves.py CVE-2019-20504  # Delete a CVE
dotrun exec scripts/delete-notices.py USN-4414-2  # Delete a notice
dotrun exec scripts/delete-release.py testy  # Delete a release
dotrun exec scripts/generate-sample-security-data.py  # Fill the database with thousands of fake records

Flask scripts

There are additionally some flask scripts to run needed database modifications.

flask insert_numerical_cve_ids # For each cve in the database, update the numerical_id column. Can be run repeatedly.