Use the command line.
Install the rivex command, then check and harden a Dockerfile from a terminal.
Install the CLI.
Install the rivex command with the script for your system, or by hand. Both check the file against the release's checksums.txt before they install it.
Install with the script.
The script is short enough to read in one screen. It finds your system, downloads the file and checksums.txt from the latest release over HTTPS, stops when the SHA-256 does not match, and installs rivex without sudo: in /usr/local/bin when you can write there, otherwise in ~/.local/bin. When cosign is installed, it also checks the Sigstore signature of checksums.txt. On macOS and Linux, download it, read it, then run it:
curl -fsSL https://rivexsecurity.com/install.sh -o install.sh
less install.sh
sh install.sh Or, when you trust the site, run it in one step:
curl -fsSL https://rivexsecurity.com/install.sh | sh On Windows, download the script, read it, then run it. It installs rivex.exe in %LOCALAPPDATA%\Programs\rivex for your user only:
Invoke-WebRequest -UseBasicParsing https://rivexsecurity.com/install.ps1 -OutFile install.ps1
Get-Content install.ps1
powershell -ExecutionPolicy Bypass -File .\install.ps1 Or, in one step:
irm https://rivexsecurity.com/install.ps1 | iex Install by hand.
Pick the block for your system. Each one is a single chain: when the checksum does not match, it stops before anything is installed. Copy the whole block.
On a Mac with Apple silicon:
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_darwin_arm64 &&
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt &&
shasum -a 256 -c --ignore-missing checksums.txt &&
chmod +x rivex_darwin_arm64 &&
sudo mkdir -p /usr/local/bin &&
sudo mv rivex_darwin_arm64 /usr/local/bin/rivex &&
rivex --version On an Intel Mac:
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_darwin_amd64 &&
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt &&
shasum -a 256 -c --ignore-missing checksums.txt &&
chmod +x rivex_darwin_amd64 &&
sudo mkdir -p /usr/local/bin &&
sudo mv rivex_darwin_amd64 /usr/local/bin/rivex &&
rivex --version On Linux with an x86-64 processor:
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_amd64 &&
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt &&
sha256sum -c --ignore-missing checksums.txt &&
chmod +x rivex_linux_amd64 &&
sudo mv rivex_linux_amd64 /usr/local/bin/rivex &&
rivex --version On Linux with an Arm processor:
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_linux_arm64 &&
curl -fsSLO https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt &&
sha256sum -c --ignore-missing checksums.txt &&
chmod +x rivex_linux_arm64 &&
sudo mv rivex_linux_arm64 /usr/local/bin/rivex &&
rivex --version Alpine Linux ships a sha256sum without --ignore-missing, so on Alpine use the script. To install without sudo, replace the last two commands of a block with mkdir -p ~/.local/bin && mv <file> ~/.local/bin/rivex, and put ~/.local/bin on your PATH.
A file you download with a browser carries the quarantine flag, and macOS Gatekeeper warns that it could not verify the file, while a file you download with curl does not carry it. If you downloaded the file and checksums.txt into ~/Downloads with a browser, check the file first and clear the flag only when the check passes:
cd ~/Downloads && shasum -a 256 -c --ignore-missing checksums.txt &&
xattr -d com.apple.quarantine rivex_darwin_arm64 On Windows, this block checks the file and installs it only when the hashes match. For Windows on Arm, use rivex_windows_arm64.exe in place of rivex_windows_amd64.exe, in both places:
Invoke-WebRequest -UseBasicParsing https://github.com/Rivex-Security/rivex-cli/releases/latest/download/rivex_windows_amd64.exe -OutFile rivex.exe
Invoke-WebRequest -UseBasicParsing https://github.com/Rivex-Security/rivex-cli/releases/latest/download/checksums.txt -OutFile checksums.txt
$want = ((Get-Content checksums.txt | Where-Object { $_ -match ' rivex_windows_amd64\.exe$' }) -split '\s+')[0]
if ((Get-FileHash -Algorithm SHA256 rivex.exe).Hash -eq $want) {
Unblock-File rivex.exe
New-Item -ItemType Directory -Force "$env:LOCALAPPDATA\Programs\rivex" | Out-Null
Move-Item -Force rivex.exe "$env:LOCALAPPDATA\Programs\rivex\rivex.exe"
& "$env:LOCALAPPDATA\Programs\rivex\rivex.exe" --version
} else { Write-Error 'checksum mismatch, nothing was installed' } If rivex is not found afterwards, add %LOCALAPPDATA%\Programs\rivex to your user PATH: open "Edit environment variables for your account" from the Start menu, edit the Path variable and add the folder.
The checksums.txt of each release is signed with Sigstore: the repository's README shows how to verify that signature. The source code is in the same repository, under the Apache License 2.0.
Every command on this page expects to find rivex on your PATH. Check the install:
rivex --version Update the CLI.
rivex update replaces the rivex file you run with the latest release:
rivex update It finds the latest release on https://github.com/Rivex-Security/rivex-cli, downloads the file for your system and the release's checksums.txt, and checks the file's SHA-256 against its line. Only then does it put the new file in place of the old one, with the same permissions. When the latest release can't be found, a download fails or the check fails, the old file stays as it was and the command exits with 2. When you already have the latest release, it says so and downloads nothing.
To see your version and the latest one without changing anything, add --check:
rivex update --check What rivex update checks:
- It connects only to
github.comover HTTPS, and follows a redirect only to GitHub's download serversrelease-assets.githubusercontent.comandobjects.githubusercontent.com, over HTTPS. - The file must match its SHA-256 in
checksums.txtand be at most 100 MiB. - It sends no API key and no token to GitHub.
What it does not check: the Sigstore signature of checksums.txt. checksums.txt comes from the same release as the file, so the check catches a corrupted or incomplete download, not a release that was tampered with. To rule that out, download the release by hand and check the signature with cosign, as the repository's README shows.
When you can't write to the directory that holds rivex, for example /usr/local/bin, rivex update never runs sudo. It prints the commands that install the release by hand, the last one with sudo, and exits with 1. A rivex you built from source reports the version dev and can't update itself: install a release as shown above.
Create an API key.
rivex harden sends your Dockerfile to the Rivex API, and the API needs a key. You need a verified email address. Open the API keys page, type a Name and select Create key. The page shows the key once: select Copy and store it somewhere safe.
Put the API address and the key in two shell variables. Replace <your-api-key> with the key you copied:
export RIVEX_API_URL=https://api.rivexsecurity.com
export RIVEX_API_KEY='<your-api-key>' The CLI reads the key from RIVEX_API_KEY by itself, so it never appears on the command line. It does not read RIVEX_API_URL: each command below passes it with --api-url, which is optional. Without it the CLI uses https://api.rivexsecurity.com.
Keep the key in a file.
To keep the key out of your shell profile, put the line RIVEX_API_KEY='<your-api-key>' in a file of its own and pass it with --env-file:
chmod 600 .rivex.env
rivex --env-file .rivex.env harden Dockerfile The CLI never reads a .env file unless you pass --env-file. With it, the RIVEX_* variables of the environment are ignored, even the ones the file doesn't set, and the CLI names them on standard error. Flags still win over the file. Keep the file chmod 600 and in .gitignore: the CLI warns when other users can read it. Lines are KEY=VALUE, with # comments, an optional export and optional quotes. There is no $VAR expansion, no inline comment and no multi-line value. Only RIVEX_ keys are used.
Harden a Dockerfile.
rivex harden sends a Dockerfile to the Rivex API and gets the hardened version and the findings back. To follow along, save this file as Dockerfile:
FROM ubuntu
EXPOSE 8080
MAINTAINER a@b.c rivex --api-url "$RIVEX_API_URL" harden Dockerfile > Dockerfile.hardened The hardened Dockerfile goes to standard output, here into Dockerfile.hardened. The findings go to standard error, so they stay on your terminal.
When the base image is too big for an SBOM, standard error says so, with the size and a slim tag when Rivex knows them: SBOM: skipped — node:22 is 408 MB compressed, over the size limit. Slim variants such as node:22-slim fit. Running the command again does not help. The exit code does not change.
To name the output file with a flag, use --output or -o. It replaces a file that already exists.
rivex --api-url "$RIVEX_API_URL" harden --output Dockerfile.hardened Dockerfile To read the Dockerfile from standard input, pass - as the path:
rivex --api-url "$RIVEX_API_URL" harden - < Dockerfile > Dockerfile.hardened rivex harden waits up to 10 minutes for the API, because build verification starts a sandbox and builds the image, which takes a few minutes. Other commands wait 30 seconds. Change that with --timeout, for example --timeout 2m.
Fail a build on findings.
--fail-on makes rivex harden exit with 4 when a finding has the severity you name or a higher one. The values are critical, high, medium, low and none. The default is none, which never fails.
rivex --api-url "$RIVEX_API_URL" harden --fail-on high --output Dockerfile.hardened Dockerfile The hardened file is written before the command exits.
Use a policy or a deployment context.
A policy switches rules off. You create one on Policies. To find its ID, list your policies and read the id field:
curl -sf -H "X-API-Key: $RIVEX_API_KEY" "$RIVEX_API_URL/v1/policies" Pass the ID with --policy-id. Replace <policy-id> with it:
rivex --api-url "$RIVEX_API_URL" harden --policy-id '<policy-id>' Dockerfile A deployment context tells Rivex how the container runs. Write it as a JSON file and pass the file with --context-file:
cat > context.json <<'EOF'
{
"runtime": {
"user": "1000",
"read_only_root_fs": true,
"cap_drop": ["ALL"]
}
}
EOF
rivex --api-url "$RIVEX_API_URL" harden --context-file context.json --output Dockerfile.hardened Dockerfile The context reference lists every field.
An image on a private registry is pinned to a digest only when Rivex can read it with your credential. Set the environment variable RIVEX_REGISTRY_AUTH to one host=username:secret entry for each registry, separated by spaces or new lines. The secret may contain : and =. Use a short-lived, read-only token. Replace <token> with it.
RIVEX_REGISTRY_AUTH='ghcr.io=me:<token>' rivex --api-url "$RIVEX_API_URL" harden Dockerfile There is no flag for it, because the arguments of a command (argv) are visible to other processes on the machine. A malformed value exits with 1 before any request, and the message names the entry's position, never its content. The server refuses a secret that is shorter than 8 characters, and the command then exits with 3. Registry credentials lists the registries and the tokens to use.
Verify the build with your project files.
When the server has build verification on, Rivex builds the hardened Dockerfile in an isolated sandbox. A Dockerfile that copies project files with COPY or ADD can't build from the Dockerfile alone. Without the files, standard error says so, for example: Build verification: not run — line 3 copies project files (COPY backend ./) that weren't sent. To verify with them, run again with --build-context <project folder>, for example --build-context . This is not a failure, and the exit code does not change. Rivex looks for COPY and ADD of local files and for RUN --mount=type=bind without from=.
When the operator turned build verification off for the whole server, standard error says Build verification: turned off on this server. When it is available but not turned on for the workspace, it says Build verification: not enabled for this organization (the run used an organization's policy) or Build verification: not enabled for your account. The SBOM: line uses the same texts. These are not failures, and the exit code does not change.
When the build fails, standard error says why, from the build's log: the line of the hardened Dockerfile, its instruction and the exit code, then the build's error lines, one per line and indented, for example Build verification: failed — the step on line 3 (RUN make) exited with code 2. followed by the line main.c:3:5: error: unknown type name 'foo'. A build that installs packages with pip, npm, Maven or apt runs with a short-lived sandbox credential, so Rivex never shows its output: for those builds the line names the error only when Rivex recognizes it, for example npm ci needs a package-lock.json or npm-shrinkwrap.json, and the build had none. When the Dockerfile copies no project files and the errors point at missing ones, it adds This step seems to need project files, but the Dockerfile copies none. Add a COPY for them before line 3. The CLI then adds the API's own sentence, The website only sends your Dockerfile. To build with your project files, run from your project folder: rivex harden Dockerfile --build-context . It comes from the API, so the same text shows on the website. When the log can't be read, it prints Build verification: failed — the hardened Dockerfile did not build in the sandbox, then Build verified: false and the error line as before.
To send the files, pass the project folder with --build-context. It is not the deployment context: that is --context-file.
rivex --api-url "$RIVEX_API_URL" harden --build-context . --output Dockerfile.hardened Dockerfile Before sending, the CLI prints one line to standard error, for example Sending build context: 12 files, 0.1 MiB (after .dockerignore).
- The CLI reads
<Dockerfile>.dockerignorenext to the Dockerfile if there is one, else the folder's.dockerignore, with Docker's rules, and leaves out what it matches. Leave out what the build doesn't need, such as.git,node_modulesand build output. - It also leaves out the
Dockerfileat the top of the folder, because the server puts the hardened one there, a top-levelDockerfile.dockerignore, the.rivexfolder, and symbolic links that are absolute or point outside the folder. - The limits are 20 MiB compressed, 200 MiB unpacked and 20,000 files and folders. Over 20 MiB compressed, the CLI exits with 2 before sending anything and says how big the folder is. Over the other limits, or when the server is already unpacking as many contexts as it allows, the server refuses the request and the CLI exits with 3; in the second case, try again shortly.
- The files are used only for this build. They go to the sandbox with the Dockerfile and are deleted when the build ends. Rivex never stores them and never writes them to a log. A server with build verification off ignores them.
Each build in the sandbox uses one of the month's verified builds of your plan: 5 for a personal workspace, 50 for an organization unless Rivex set another number. When they are used up, standard error says so, for example Build verification: not run — this month's verified builds are used up (5 of 5). They renew on December 1, 2026. The hardened Dockerfile and the findings come back as usual, and the exit code does not change.
Choose whether to verify the build.
Each build in the sandbox uses one of the month's verified builds, so you choose when to spend one. rivex harden verifies the build when you run it by hand, and doesn't in a CI job, where your pipeline usually builds the image itself. To turn it off for one run:
rivex --api-url "$RIVEX_API_URL" harden --verify-build=false --output Dockerfile.hardened Dockerfile Standard error then says Build verification: not run — skipped for this run. This is not a failure, and the exit code does not change. With verification off, --build-context is not sent, and the CLI says so on standard error.
The CLI decides in this order:
--verify-buildor--verify-build=false, when given.- The environment variable
RIVEX_VERIFY_BUILD, set totrueorfalse, for a shell or a CI job. Another value exits with1before any request. - Off in CI: when
CIis set to a true value (GitHub Actions, GitLab CI, CircleCI, Bitbucket Pipelines, Buildkite, Travis CI), orTF_BUILDis set (Azure Pipelines), orJENKINS_URLis set (Jenkins). In CI, standard error saysBuild verification: not run — skipped in CI. To build it in the sandbox, add --verify-build (uses one of this month's verified builds). - Otherwise on.
To verify the build in a CI job, add --verify-build --build-context . to the command. The server counts verified builds whatever the CLI sends, so this choice only saves your allowance.
Generate a CI configuration.
rivex ci init prints a ready-made job for GitLab CI, Jenkins, Azure DevOps or Bitbucket Pipelines. It needs no API key. --platform takes gitlab, jenkins, azure or bitbucket.
rivex ci init --platform gitlab Add --output or -o to write a file instead. It replaces a file that already exists.
rivex ci init --platform gitlab --output rivex-gitlab.yml Run Rivex in CI covers each platform and the GitHub Action.
Check a Dockerfile against its attestation.
rivex harden --attestation-out FILE saves the signed attestation, and --sbom-out FILE saves the software bill of materials, each exactly as the API returned it. rivex verify then checks, on your machine, that a Dockerfile is the one Rivex hardened and signed. It needs no API key and never contacts Rivex; its only network access is Sigstore's public trust root. Without --bundle it reads attestation.sigstore.json next to the Dockerfile.
Check hardened Dockerfiles in CI has the jobs for each CI system. Here a missing bundle fails the check before any network access:
rivex verify --bundle missing.sigstore.json Dockerfile Flags.
Flags for every command.
--api-url: the address of the Rivex API. Default:https://api.rivexsecurity.com.--api-key: your API key. Default: theRIVEX_API_KEYvariable, unless--tokenis given. Prefer the variable: a flag shows in the process list and the shell history.--env-file: read theRIVEX_*settings from this file, not from the environment. Read only byrivex harden, and only when you give it.--token: a sign-in token, used only when--api-keyis empty. Use--api-keyunless you have a reason not to.--timeout: how long to wait for the API, for example45sor2m; forrivex update, how long to wait for GitHub. Default:10mforrivex harden,5mforrivex update,30sfor other commands.--helpor-h: show the help for a command.--versionor-v: print the version. Onlyrivexitself takes it.
Flags for rivex harden.
--outputor-o: write the hardened Dockerfile to this file, not to standard output.--fail-on: exit with 4 when a finding has this severity or a higher one. Default:none.--policy-id: the ID of the policy to apply.--context-file: a JSON file that describes how the container runs.--build-context: the project folder to send for build verification, after its.dockerignore. Not sent when build verification is off.--verify-build: build the hardened Dockerfile in the sandbox;--verify-build=falsedoesn't. Default: on by hand, off in CI, or the value ofRIVEX_VERIFY_BUILD.
--attestation-out: save the signed attestation (a Sigstore bundle) to this file. Nothing is written when the server returned none; stderr says why. When the hardened file still contains a secret, nothing is signed and stderr printsAttestation: not signed — the hardened file still contains a secret on line N. Remove it and run again.(without "on line N" when the line is not known).--sbom-out: save the CycloneDX SBOM to this file. Nothing is written when the server returned none; stderr says why.
Both files are overwritten if they exist, and the directory must exist. The two paths must differ from each other, from the Dockerfile and from --output.
Flags for rivex verify.
--bundle: the attestation to check. Default:attestation.sigstore.jsonnext to the Dockerfile.--no-disabled-rules: fail when a policy turned off any rule for this Dockerfile.
Flags for rivex ci init.
--platform:gitlab,jenkins,azureorbitbucket.--outputor-o: write the snippet to this file, not to standard output.
Flags for rivex update.
--check: print the current and the latest version, and change nothing.
Exit codes.
Every command exits with 1 when you give it a flag or a command it does not know.
Exit codes of rivex harden.
0: the Dockerfile was hardened.1: the input is wrong: a bad flag value, a missing Dockerfile, a context file that cannot be read, a--build-contextfolder that cannot be read, an output file that cannot be written or a malformedRIVEX_REGISTRY_AUTH, or an env file that cannot be read or has a malformed line.2: the API gave no usable answer: no connection, a timeout or a response the CLI cannot read. Also a--build-contextover 20 MiB compressed, before any request.3: the API answered with an error, for example because the key is missing or wrong.4: a finding met--fail-on.
Without a key, the API refuses the request. Here RIVEX_API_KEY= empties the variable for one command:
RIVEX_API_KEY= rivex --api-url "$RIVEX_API_URL" harden Dockerfile A missing file never reaches the API:
rivex --api-url "$RIVEX_API_URL" harden missing.Dockerfile Exit codes of rivex verify.
0: the Dockerfile is the one Rivex hardened.1: the arguments are wrong, or the Dockerfile or the bundle can't be read.2: Sigstore's public trust root could not be fetched.5: the check failed: the attestation is missing, too large, malformed, made in the legacy format, not signed by Rivex, or does not match the Dockerfile; or--no-disabled-rulesfound a rule turned off.
Exit codes of rivex ci init.
0: the snippet was printed or written.1: the--platformvalue is unknown, or the output file cannot be written.
rivex ci init --platform circleci Exit codes of rivex update.
0:rivexwas updated, was already up to date, or--checkprinted the versions.1:rivexcan't update itself: it is adevbuild,--timeoutis not greater than zero, its directory can't be written, or the new file can't be written or put in place. The message says whether the old file is still in place, and if not, which file to rename back.2: nothing was changed because the latest release can't be found, a download failed or the file didn't matchchecksums.txt.