A graphql server for vulnerabilities powered by dgraph
Project description
Introduction
Development setup
git clone https://github.com/ngcloudsec/threat-db.git
cd threat-db
mkdir -p $HOME/dgraph $HOME/threatdb_data_dir
docker compose up
This would start a threat db api server (PORT: 9000) and an instance of dgraph standalone (PORTS: 8080, 9080).
Create schemas
To create the schemas and the first administrator user.
git clone https://github.com/ngcloudsec/threat-db.git
pip install poetry
poetry install
poetry run threat_db_admin --init --dgraph-host localhost:9080 --graphql-host http://localhost:8080/graphql
poetry run threat_db_admin --create-root-user --dgraph-host localhost:9080 --graphql-host http://localhost:8080/graphql
Copy the user id and password from the logs.
Import data
threat_db --data-dir
When invoked with docker compose, any json file present in the directory THREATDB_DATA_DIR
would be imported automatically.
Rest API
Generate access token
curl -X POST http://0.0.0.0:9000/login -d "username=user id&password=password" -H "Content-Type: application/json"
Useful one-liner for automation
export ACCESS_TOKEN=$(curl -X POST http://0.0.0.0:9000/login -d '{"username":"username","password":"password"}' -H "Content-Type: application/json" | jq -r '.access_token')
curl http://0.0.0.0:9000/healthcheck
whoami
curl http://0.0.0.0:9000/whoami -H "Authorization: Bearer $ACCESS_TOKEN"
Import data
curl -F 'file=@/tmp/bom.json' http://0.0.0.0:9000/import -H "Authorization: Bearer $ACCESS_TOKEN"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
threat_db-0.3.0.tar.gz
(19.5 kB
view hashes)
Built Distribution
threat_db-0.3.0-py3-none-any.whl
(22.3 kB
view hashes)
Close
Hashes for threat_db-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b194ee79fb5426d5c7bd1bf5d496a3226aca87a92dcf69db4e6e34f51ec2840 |
|
MD5 | 7336eacd09314ca8f32d9c7a60f219aa |
|
BLAKE2b-256 | 42f984716d5c14c0aff75111644bc469a99a4495ed6aa5dd15d6160852160690 |