Skip to main content

A framework for implementing the Stateless OpenPGP CLI

Project description

The Stateless OpenPGP Command-Line Interface

The Stateless OpenPGP Command-Line Interface (or sop) is a specification that encourages OpenPGP implementors to provide a common, relatively simple command-line API for purposes of object security.

This Python module helps implementers build such a CLI from any implementation accessible to the Python interpreter.

It does not provide such an implementation itself -- this is just the scaffolding for the command line, which should make it relatively easy to supply a handful of python functions as methods to a class.

Note that if the user has argcomplete installed, they should also get tab completion in standard shells like bash basically for free.

Example

Here is an example of a minimal command-line tool that just implements the extract_cert() interface, using (imaginary) module foo that has the appropriate

#!/usr/bin/python3
# PYTHON_ARGCOMPLETE_OK
import sop
import foo

class FooSop(sop.StatelessOpenPGP):
    def __init__(self):
        super().__init__(prog='FooPGP', version='0.17')
    # overrides go here...
    def extract_cert(self, key:bytes, armor:bool=True, **kwargs:Namespace) -> bytes:
        self.raise_on_unknown_options(**kwargs)
        return foo.bytes_to_openpgp_key(key).get_certificate(armor=armor)

if __name__ = "__main__":
    foo = FooSop()
    foo.dispatch()

Module Goals

Extensibility

An implementer who wants to extend sop in a simple way (e.g. adding an option to an existing subcommand, or adding a special option) should be able to do so without breaking this interface.

Minimal dependencies

The aim is to only depend on modules from stdlib. We make an exception for optional modules like argcomplete, which can be skipped.

Type-checking

All the code in here should be well-annotated

Self-documenting

Implementers should learn what they need to know from the docstrings, like so:

import sop
help(sop)
help(sop.StatelessOpenPGP)

Semantic Versioning

The major version number will only change when backward-incompatible changes are made.

As long as the major version number is 0, the same holds true for the minor version number.

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

sop-0.3.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

sop-0.3.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file sop-0.3.0.tar.gz.

File metadata

  • Download URL: sop-0.3.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for sop-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9c33c8a2f77fbd9f58079d89d6479e7026a5c24517c84b5f893ec23e9998e6d
MD5 925d5ea1800780df1923c9f752cfbe4d
BLAKE2b-256 63cec081692002d90de968010a3081c5162e98868488c7cd9ecabf1fbd4aac8f

See more details on using hashes here.

File details

Details for the file sop-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sop-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for sop-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9a09fdde02dda91e0463e9abfd97ab9f9bc311c18d4fe237f9b4f7d8a03ae4
MD5 4cddc47f94da953a45b02bee56d0914f
BLAKE2b-256 0183d2188ef7ac51804b348c537845726c3f5e1126f70a70e81ad6f117509bcb

See more details on using hashes here.

Supported by

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