Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

DCSO Portal Python SDK

Copyright (c) 2020, 2021, DCSO Deutsche Cyber-Sicherheitsorganisation GmbH

DCSO Portal Python Software Development Kit (SDK) helps you create application which need to interact with the DCSO Portal.

Documentation: https://dcso.github.io/dcso-portal-python-sdk/dcso/portal/

Requirements

This library is, when installed, pure Python. We use only 3rd party tools for installation and documentation generation.

  • Python v3.7 or greater (Python v3.6 as best effort)
  • Requirements:
    • for distribution, see requirements_dist.txt

Requirements can be installed using, for example, pip:

$ pip install -r requirements_dist.txt

We strongly advise to use a Virtual Environment for testing or for development. This makes sure your local Python environment stays clean.

$ python3 -m venv venvdir
$ source ./venvdir/bin/activate
(venvdir)$ pip install -r requirements.txt 

Installation

This section explains how to install the DCSO Portal Python SDK. You can get a copy and source on GitHub.

From Python Package Index (PyPI)

$ pip install -U dcso-portal-python-sdk

Using Source

Installation is done using setup.py:

$ pip install .
or
$ python3 setup.py install

It is advised, when developing or testing, to use a Virtual Environment (see Prerequisites in this document).

Documentation

Documentation is available as HTML in the docs/dcso/portal folder.

It is possible to generate it using:

$ ./gendocs.py

Alternatively, it is also possible to have the documentation service by the pdoc3 web server. This is mostly useful for working on the documentation since it will rebuild automatically:

$ PYTHONPATH="./lib" pdoc --http : --html \
    --template-dir support/doc_templates dcso.portal

open http://localhost:8080/dcso.portal/

See pdoc --help for more information.

Examples

The folder examples contains code which can be used to learn how to use this SDK.

When running the examples, within the root of the repository, use the PYTHONPATH variable:

$ PYTHONPATH="lib" python3 examples/basic.py

example/portal_cli.py

The portal_cli.py, Portal Command-Line Intereface, show how to create an interactive client. It will prompt for username, password, and if needed, also the one-time password.
The result is showing all permissions the user has, and whether the user has TDH Coordinator access.

example/exec_graphql.py

The exec_graphql.py shows how to connect using a Machine Token (also known as API Tokene), and execute some GraphQL.

Development

The SDK itself and its tests stays as pure Python as possibly can be.
An exception is the Setuptools requirement for installation or any tools for packaging.

DCSO Namespace

We use the dcso package namespace, which can be recognized lacking the __init__.py. This helps having other Python project which can then install in the same location.

Running Tests

Directly using the unittest package from command line:

$ PYTHONPATH="lib" python3 -m unittest discover -s ./lib/dcso/ -vv

Or using the wrapper script, to run all tests:

$ python3 test.py

IDE Tips

PyCharm

Right click on the lib/ folder in the root of the repository and select 'Mark Directory as > Sources Root'. This will make sure PyCharm add the code to its PYTHONPATH.

Distribution

DCSO Portal Python SDK is make available for downloading from GitHub as source distributions are made available with each release.

We also upload to the Python Package Index (PyPI) using twine, and an API token.

Preparing a Release

It is a good idea to start with a fresh Virtual Environment when creating a new release.

  1. Install requirements: pip install -r requirements_dist.txt
  2. Create a supporting branch which contains the version number to be releases, for example, release/1.0.0-beta3
  3. Update lib/dcso/portal/_version.py and update the __version__ variable
  4. Generate documentation: ./gendocs.py
  5. Create source distribution: python setup.py sdist --formats=zip (will be created in sub folder dist)

Upload to PyPI

With the source distribution created as ZIP-archive, we can now upload to PyPI using the Twine module.

python3 -m twine upload dist/dcso_portal_python_sdk-1.0.0b3.zip

The twine module is installed using pip install -r requirements_dist.txt.

Twine will ask you for credentials:

  1. Use __token__ as username
  2. As Password, enter the PyPI API Token for the dcso-portal-python-sdk project (note that this includes the pypi- prefix)

License

MIT

Metadata

Release files for dcso-portal-python-sdk 1.0.0b4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dcso-portal-python-sdk 1.0.0b4
File Size Uploaded Provenance Actions
dcso_portal_python_sdk-1.0.0b4.zip 35.9 kB Without provenance Details for dcso_portal_python_sdk-1.0.0b4.zip

Release files / dcso_portal_python_sdk-1.0.0b4.zip

Download URL dcso_portal_python_sdk-1.0.0b4.zip
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
55ce42526a6a2abc4e154b896638ce649608f9b554a495f594139a9ff36cee87
BLAKE2b-256 checksum
How to use checksums
dbaa06a10da1d43857c4d0a133a7a084cd1e4678b9d38b72473937efd56def27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Security for dcso-portal-python-sdk 1.0.0b4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page