Library to manipulate and create Sourcetrail databases
Project description
Numbat
Numbat is an API to create and manipulate Sourcetrail databases. Sourcetrail is a code source explorer which allows users to navigate through the different components (functions, classes, types, etc.) easily.
Numbat main goal is to offer a full-python SDK given the fact that the current one, SourcetrailDB cannot be used anymore efficiently. It is not user-friendly at first sight, need to be compiled to provide Python bindings and, moreover, it is no longer maintained. Finally, we have added some little new features as finding an element in the database.
With Numbat, you will be able to visualize your data quickly with the nice graphical Sourcetrail interface. For example, Pyrrha uses Numbat to map firmware structure.
Installation
Numbat is available on pypi
.
pip install numbat
From sources
You can also install it from the git
repository. Either using the following oneliner:
pip install 'numbat @ git+https://github.com/quarkslab/numbat'
or doing it in few steps:
# Download the repo
git clone https://gitlab.qb/firmware-re/cartography/numbat
cd numbat
# Install numbat locally
pip install .
Build Documentation
If you want to build the documentation by first installing Numbat with the required [doc]
dependencies and then serve the documentation on a local server.
# if you already have a local clone of the project
cd NUMBAT_DIR
pip install .[doc]
# otherwise
pip install 'numbat[doc]'
# serve doc locally
mkdocs serve
Basic Usage
A complete usage with examples is available in the documentation but here is a quick usage to begin with Numbat.
To use Numbat, you must first create a SourcetrailDB
object and either create a new database or open an existing one:
from pathlib import Path
from numbat import SourcetrailDB
# Create DB
db = SourcetrailDB.open(Path('my_db'), clear=True)
# Create a first class containing the method 'main'
my_main = db.record_class(name="MyMainClass")
meth_id = db.record_method(name="main", parent_id=my_main)
# Create a second class with a public field 'first_name'
class_id = db.record_class(name="PersonalInfo")
field_id = db.record_field(name="first_name", parent_id=class_id)
# The method 'main' is using the 'first_name' field
db.record_ref_usage(meth_id, field_id)
# Save modifications and close the DB
db.commit()
db.close()
Authors
- Sami Babigeon (@sbabigeon), Quarkslab
- Eloïse Brocas (@ebrocas), Quarkslab
The logo is a creation of Benoît Forgette and Sami Babigeon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file numbat-0.2.1.tar.gz
.
File metadata
- Download URL: numbat-0.2.1.tar.gz
- Upload date:
- Size: 761.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59a4cb6b37a368948cff858fe625c3554f699d828faa905deb67810e37d9b8c1 |
|
MD5 | 46d7ec0877ae45ae607ccdd925b64899 |
|
BLAKE2b-256 | c9330c69acc3e626433d5bf2b23e1edb005dbe85a662b1ba86c01a2c165da764 |
File details
Details for the file numbat-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: numbat-0.2.1-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33c763d87a1384ed29f886cfb3930d67ea7b5d23f6fa21c4800797835204793a |
|
MD5 | 052dd2bbc50f81e7e7878dfca51a1324 |
|
BLAKE2b-256 | a2bf8c8aa5c1474f25025ab5aded6d42ed8b1833c62512ed7cf0b87eb69fa7db |