Skip to content

witnyx upload

witnyx upload sends a software bill of materials (SBOM), and the report that witnyx check wrote for it, to the hosted Witnyx service, which records the deploy. The hosted service is in development: it is not online yet, and its address may change before it is.

Use it in a deploy job, after check, to keep a record of what each deploy shipped. It is the only command that sends anything to Witnyx; the other commands never contact the service.

The key. upload reads the key only from the variable WITNYX_API_KEY. There is no option for it, so it never appears on a command line. It is sent only in the Authorization header, and it is never printed, written to a file or put in the upload document. The one exception: when the service refuses a key that starts with wxk_, the hint names its first 12 characters, the prefix that the service itself shows, so you can tell which key it was. Without a key, nothing is read and nothing is sent.

A failed upload never blocks a deploy by default. When the service does not record the upload, upload prints a warning on standard error and exits with code 0. With --require-upload, the warning becomes an error and the exit code is 2. upload never exits with 1. A failure is remembered in the folder uploads of the cache folder and reported with the next upload from this machine that succeeds, if the folder is kept. A missing key, and a value that upload refused before sending, are not remembered.

What is sent. One POST to https://app.witnyx.dev/api/v1/deploys per attempt, and at most three attempts, with these parts:

  • metadata: the environment (--env), the event (--event), the commit, this machine’s clock, the name and version of witnyx, and the failures remembered from earlier uploads;
  • sbom: the bytes of the --sbom file, unchanged;
  • report: the bytes of the --report file, unchanged, when it was given and passes the checks that the service makes. Otherwise the SBOM is sent without it, with a note.

Nothing else is sent: no other part, header or request, no name of this machine or of its user, no path and no other variable. The file names in the request are fixed, but the report holds the path of the SBOM that check read, in sbom.path; leave out --report if that path must stay on the machine. Without --commit, the commit comes from the first CI variable that holds one, such as GITHUB_SHA or CI_COMMIT_SHA. The upload contract, docs/upload-contract-v1.md in the repository, lists exactly what is sent and how the service answers.

Quote every value. A variable that is not set then becomes an empty value, which upload reports as a failure with exit code 0. Unquoted, it would become a missing value, which stops the command before it starts, with exit code 2.

Terminal window
witnyx check bom.json --output json=witnyx-report.json
witnyx upload --sbom "bom.json" --report "witnyx-report.json" --env "production"

A release, with the commit given, where a failed upload fails the job:

Terminal window
witnyx upload --sbom "bom.json" --env "$DEPLOY_ENV" --event "release" --commit "$RELEASE_SHA" --require-upload

When the upload is recorded, standard output gets one line that starts with Uploaded and names the deploy. When it is not, standard error gets these lines, the hint: line only when there is a hint:

warning <code>: The upload was not recorded: <message>
hint: <what to do>
note: The deploy is not blocked. <memory sentence> Pass --require-upload to fail the build instead.

With --require-upload, the first line starts with error instead, and the note: line holds only the memory sentence, which says whether and where the failure is remembered. The code is WX-UPLOAD for what the network or the service did; WX-CONFIG for a missing key, a value that upload refused, no --sbom, or an SBOM that is not a regular file or is larger than 50 MiB; a WX-SBOM code for an SBOM file that does not exist or cannot be read as an SBOM; and WX-INTERNAL for a fault in witnyx. Error codes explains each. In agent mode, standard output carries the upload document instead, and every line on standard error starts with witnyx: .

See also: Hosted service and Privacy.

Usage

witnyx upload [-hV] [--[no-]agent] [--require-upload] [--cache-dir=DIR] [--commit=SHA] [--env=NAME] [--event=EVENT] [--format=FORMAT] [--report=FILE] [--sbom=FILE] [--timeout=SECONDS]

Options

Option Value Default Description
--sbom FILE The SBOM to send: CycloneDX (JSON or XML) or SPDX 2.2/2.3 JSON, at most 50 MiB. Required.
--report FILE The report that witnyx check wrote for this SBOM (--output json=FILE), at most 8 MiB. A report the service would refuse is left out, with a note, and the SBOM is sent without it.
--env NAME The environment of the deploy, for example production: lower-case letters, digits and hyphens, at most 32 characters. Required.
--event EVENT deploy deploy or release (default: deploy).
--commit SHA The commit, 7 to 64 hexadecimal characters (default: the first CI variable that holds one, such as GITHUB_SHA or CI_COMMIT_SHA).
--require-upload Exit with code 2 when the service does not record the upload. Without it, the run prints a warning and exits 0, and the failure is reported with the next upload that succeeds.
--agent, --no-agent Agent mode: exactly one JSON document on standard output (the upload document) and short progress lines on standard error. On by default when the environment shows an AI coding agent; --no-agent turns it off.
--timeout SECONDS 120 Time budget in seconds (default: 120).
--cache-dir DIR Cache directory for public data (default: the platform’s cache folder).
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
--format FORMAT With --help: text (the default) or json, a machine-readable reference.

Exit codes

Code Meaning
0 The service recorded the upload; or it did not, and --require-upload was not given: a warning, and the failure is remembered and reported with the next upload that succeeds.
2 The arguments could not be parsed, or the service did not record the upload and --require-upload was given.

Witnyx is a record-keeping and workflow tool. It does not certify compliance. Nothing on this site is legal advice.