defectdojo-api-generated
Python library to interact with DefectDojo - generated from OpenAPI definition using https://openapi-generator.tech/
Multiple changes done on top of default openapi-generator:
- A friendlier Client class
- Tweak validations to reduce package import time to about 1/3
- Remove most of pydantic/schema validations due to inconsistencies with actual database schema/requirements (tracked in https://github.com/fopina/defectdojo-api-generated/issues/39)
- Iterator methods for every list API method to handle pagination automatically
- A nice CLI exposing all the API methods <3
- published as
defectdojo-cli, a separate package to keep library-only installs free of console-script conflicts
- published as
Example
Library
pip install defectdojo-api-generated
from defectdojo_api_generated import DefectDojo
# password publicly available in https://github.com/DefectDojo/django-DefectDojo/?tab=readme-ov-file#demo
dojo = DefectDojo(base_url='https://demo.defectdojo.org/', auth=('admin', PASSWORD))
for ind, finding in enumerate(dojo.findings_api.list_iterator(title='Stored XSS')):
if not ind:
print(f'Total matched findings: {finding.page.count}')
print(f'- [{finding.result.severity}] {finding.result.title} - {finding.result.description}')
r = dojo.system_settings_api.list(limit=1)
print(f'- {r.results[0]}')
Full documentation readthedocs
CLI
uv tool install defectdojo-cli
$ dojo
Usage: dojo [OPTIONS] COMMAND [ARGS]...
DefectDojo CLI
Options:
...
Commands:
api Interact directly with any API/method
config Show or edit the current CLI configuration
status Quick connectivity check
You can also skip tool install and just run it with:
$ uvx defectdojo-cli
Usage: dojo [OPTIONS] COMMAND [ARGS]...
...
Contributing
Check out CONTRIBUTING.md
API notes
Required properties
DefectDojo's OpenAPI schema and actual database/API validations are inconsistent in some places, so this library assumes all properties as not required skipping client-side validation and delegating those validations to server.
Refer to https://github.com/fopina/defectdojo-api-generated/issues/31 and https://github.com/fopina/defectdojo-api-generated/issues/39 for more details / reasoning.
Server versions
This library is versioned after the OpenAPI schema version (DefectDojo version) it was generated against, eg: when re-generated against DefectDojo 2.57.0 schema, it will be released as 2.57.0
Any changes done to the package (such as packaging metadata or extra schema tweaks), while on the same schema version, will be released as post fixes, eg: 2.57.0.post1
Given the very few validations kept (previous note), there might be no issue using "latest" version of this package against an older DefectDojo. However, if there is any, just install the closest matching version.
Metadata
Release files for defectdojo-api-generated 2.57.2.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| defectdojo_api_generated-2.57.2.post1.tar.gz | 416.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| defectdojo_api_generated-2.57.2.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / defectdojo_api_generated-2.57.2.post1.tar.gz
| Download URL | defectdojo_api_generated-2.57.2.post1.tar.gz |
|---|---|
| Size | 416.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b15cdbc8ee97ed12ef1ece50e22c710a0a725d57f614acc8547997ad4e58911
|
|
BLAKE2b-256 checksum How to use checksums |
88260bbb31b1fbcca23361db7c7b152e6419910a53a008c7ef8910c3901d7dd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / defectdojo_api_generated-2.57.2.post1-py3-none-any.whl
| Download URL | defectdojo_api_generated-2.57.2.post1-py3-none-any.whl |
|---|---|
| Size | 981.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db1b996095bd21738748c914cfaa09256d57ba0df20ff328639983349a90dc18
|
|
BLAKE2b-256 checksum How to use checksums |
c5d28f5d848fe98bc053a72d5ebe5179620cd4c498a1a3339aef5c1c65627e0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|