Skip to main content

Utility scripts for ManySecured-D3 claims

Project description

ManySecured d3-cli

Utility cli for ManySecured-D3 claims

Installation

This api may be installed using pip like so:

pip install d3-cli

When developing these scripts, Python Poetry is used to install and manage dependencies as well as publish to PyPI.

Poetry will create a python isolated virtual environment in the ./.venv folder and install dependencies if you run:

poetry install

You cannot run the cli or scripts directly from the ./src/d3-scripts since we are using Python relative imports.

Instead, you must run the d3-cli script defined in the [tool.poetry.scripts] field of pyproject.toml: You can run the command line interface locally, directly from source code without building/installing by running poetry run d3-cli.

Usage

usage: d3-cli [-h] [--version] [--guid] [--output [OUTPUT]] [--mode [{build,lint,export,website}]] [--skip-mal]
              [--build-dir [BUILD_DIR]] [--check_uri_resolves] [--web-address [WEB_ADDRESS]] [--verbose | --quiet]
              [input ...]

ManySecured D3 CLI for creating, linting and exporting D3 claims

positional arguments:
  input                 folders containing D3 YAML files.

optional arguments:
  -h, --help            show this help message and exit
  --version             show the version and exit.
  --guid, --uuid        generate and show guid and exit.
  --output [OUTPUT], -o [OUTPUT]
                        directory in which to output built claims.
  --mode [{build,lint,export,website}], -m [{build,lint,export,website}]
                        mode to run d3-cli in.
                        build creates a directory of D3 claims in json format, with the parent and child types resolved, and CVEvulnerabilities added.
                        lint lints the claims to check they confirm to the yaml syntax and schemas.
                        export creates a directory with the CSVs of the tables of types, behaviours andfirmwares.
                        website creates a directory containing the source for a static website of claims which can be browsed,with unique uris for each type.
  --skip-mal            skip malicious url lookup.
                                This takes a bit of time, and requires an internet connection
                                so you may wish to skip this step for local testing.
  --build-dir [BUILD_DIR]
                        build directory with json claims to export to build website with.
                                Specifying this will skip build step in export mode and website mode.
  --check_uri_resolves  check that URIs/refs resolve.
                                This can be very slow, so you may want to leave this off normally.
  --web-address [WEB_ADDRESS]
                        web address to use for website build
  --verbose, -v
  --quiet, -q

Example: d3-cli ./manufacturers

Tests

Tests can be run via:

poetry run pytest

Publish

The d3-cli utility is published here.

In order to publish you must run:

poetry build
poetry publish

And then enter the credentials for the NquiringMinds pypi account.

D3 type explorer web page

This static page is generated from (post-processed) D3 statements and hosted here. This site relies upon two Github actions in the D3DB repository

  • Run D3 Build of website for github pages - processes all files, exporting html files
  • Publish website (main-branch only) deploys the pelecan site to Github pages

In order for the pelican graphviz plugin which generates the digraph's in the webpage to work you need to have graphviz installed on your pc. For linux machines this can be done with sudo apt install graphviz, for windows graphviz installers may be downloaded from here.

Running Locally

To generate the site files inside a defined directory:

cd d3-cli
poetry install
poetry run d3-cli --mode website "path-to-d3-yaml-files" --output "output-file" 

serving the static site:

cd "output-file"/output
python -m http.server 8000

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

d3_cli-0.2.5.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

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

d3_cli-0.2.5-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file d3_cli-0.2.5.tar.gz.

File metadata

  • Download URL: d3_cli-0.2.5.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.7 Linux/5.15.0-67-generic

File hashes

Hashes for d3_cli-0.2.5.tar.gz
Algorithm Hash digest
SHA256 e937dbb360fae478faf8dfacf66dea6fddc7ba3d3e96589a9c788eeec487d200
MD5 bbca05879a56e280d94051f14b504729
BLAKE2b-256 2604a8ab968e4e34a58a9a166f627f0d02b8c4a09301114dbfa7d434a3b5a833

See more details on using hashes here.

File details

Details for the file d3_cli-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: d3_cli-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.7 Linux/5.15.0-67-generic

File hashes

Hashes for d3_cli-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 96dd9105b9f642d7cf290e6e951e487b1c590707bc7b3a18bcbf79ede21a3d26
MD5 c50b7a029d90d278b0eb93c3ec9e2b24
BLAKE2b-256 cf1e94ebc8fde87b0a8eeef115f51b9514cef67a8dda456f6be2e33550a2382a

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