Skip to main content

Python library to interact with DefectDojo - generated from OpenAPI

Project description

defectdojo-api-generated

ci test codecov PyPI pyversions Current version on PyPi Very popular Code style: black

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
    • installed only as an extra, to keep everything clean when package is used as library only

Example

Library

pip install defectojo-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

asciicast

uv recommended or pipx

uv tool install 'defectojo-api-generated[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 'defectojo-api-generated[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.

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

defectdojo_api_generated-2.56.4.tar.gz (410.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

defectdojo_api_generated-2.56.4-py3-none-any.whl (969.9 kB view details)

Uploaded Python 3

File details

Details for the file defectdojo_api_generated-2.56.4.tar.gz.

File metadata

File hashes

Hashes for defectdojo_api_generated-2.56.4.tar.gz
Algorithm Hash digest
SHA256 8cbaa7cf4dab37f977d26eb9200e2881a428f7a829a865c1e8587b5c10d6ecf3
MD5 bdeb55f6db0ae6b004566575187225bc
BLAKE2b-256 5b1033c5660a702d3f9967e855716a17b906438831a7777cfe7cbdbf74dc6371

See more details on using hashes here.

File details

Details for the file defectdojo_api_generated-2.56.4-py3-none-any.whl.

File metadata

File hashes

Hashes for defectdojo_api_generated-2.56.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c77fd2bd06aa956afb334fafa7464ee477b02ce2ce254fb1318b0e04fa8564a1
MD5 61eb84d715b775947b059143a97fcaa2
BLAKE2b-256 090076d8a9f23d216d191b571b8077a68e8820f3971cb111f1ded10555ea8cf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page