Aribot CLI for Node.js
Threat modeling checks for every code change, from your terminal, a pre-commit hook or a CI/CD pipeline.
npm i -g @ayurak/aribot-cliaribot asks the Aribot server for a gate decision on your change. You get the threats, requirements and findings that touch the lines you changed, each with its fix, and an exit code your pipeline can act on. Only file paths and changed line ranges leave your machine. File contents stay local.
This package is the Node.js port of the Python aribot-cli. Both have the same commands, options, output, JSON and exit codes, and they share the keychain entry and the signing key file, so a team can mix them: developers on npm, CI on either.
Install
npm i -g @ayurak/aribot-cli
aribot --version
# or without installing
npx @ayurak/aribot-cli check --gate-config 12Requires Node.js 18 or later. The only runtime dependency is @ayurak/sdk.
Sign in
Create an API key in Aribot under Company Admin > Developer & API, then:
aribot login # asks for the key (hidden) and stores it in the OS keychain
aribot login --with-token < key.txt # reads the key from standard input
aribot auth status # shows the API host and the key's last four characters
aribot logout # removes the stored keyIn CI, set the key as a secret environment variable:
export ARIBOT_API_KEY=... # takes precedence over the keychainThe CLI looks for a credential in this order: ARIBOT_API_KEY, the OS keychain entry for the API host, then ARIBOT_TOKEN. A key is never accepted as a command-line argument, never written to a plain file and never printed. To stop a key working, revoke it in Aribot.
The keychain entry is service aribot-cli, account = the API host, the same entry the Python CLI uses:
| OS | Keychain | Notes |
|---|---|---|
| macOS | login keychain, through /usr/bin/security | The first time one CLI reads an entry the other one wrote, macOS may ask you to allow access. |
| Linux | Secret Service, through secret-tool (package libsecret-tools) | Needs a running keyring (GNOME Keyring, KWallet and others). |
| Windows | not supported | Set ARIBOT_API_KEY in your environment. |
| Variable | Purpose |
|---|---|
ARIBOT_API_KEY | API key for CI pipelines |
ARIBOT_API | API host, https only (default https://aribot.ayurak.com) |
ARIBOT_TOKEN | JWT access token, for owner and security-manager actions such as signing rules |
ARIBOT_CA_BUNDLE | Extra CA certificate file (PEM) for a self-hosted server with a private CA |
ARIBOT_GATE_CONFIG | Gate configuration id for aribot check and aribot explain |
ARIBOT_BASE | Base ref for aribot check (default origin/main) |
ARIBOT_SIGNING_KEY | Signing key file for aribot keys and aribot rules |
Check a change
aribot check --gate-config 12 # git diff against the base branch
aribot check --gate-config 12 --staged # staged changes only
aribot check --gate-config 12 --sarif out.sarif # also write SARIF 2.1.0 for code scanning
aribot check --gate-config 12 --json # machine-readable decision, with exit_code
aribot explain src/orders/views.py:42 # requirements, threats, findings and fix steps
aribot explain src/orders/views.py --apply-patch # asks before writing the suggested patch
aribot gate status --pr 7 # latest gate decision for a pull requestaribot check runs git diff --unified=0 against the merge base of --base and HEAD and sends each changed file's path and new-side line ranges. In CI, fetch the base branch first (for example actions/checkout with fetch-depth: 0).
Exit codes
For aribot check:
| Code | Meaning |
|---|---|
| 0 | Allow (or warn, without --strict) |
| 1 | Block |
| 2 | Warn, with --strict |
| 3 | Configuration, sign-in, git or API error |
For the other commands: 0 ok, 1 gate failed (check --legacy, rules import with rejected rows, a runner decision of block), 2 usage error, 3 configuration or API error.
Pre-commit hook
The hook runs aribot check --gate ide --staged: findings on the staged lines are printed and the commit goes ahead. Add --strict to stop the commit on a warning. A missing key, an unreachable API or a git problem prints a note and lets the commit through.
With the pre-commit framework and the npm CLI installed:
repos:
- repo: local
hooks:
- id: aribot-check
name: Aribot gate check (staged changes)
entry: aribot check --gate ide --staged
language: system
pass_filenames: false
always_run: true
stages: [pre-commit]As a plain git hook (.git/hooks/pre-commit, or .husky/pre-commit with husky):
#!/bin/sh
npx --no-install aribot check --gate ide --stagedBoth need ARIBOT_GATE_CONFIG and a key from aribot login (or ARIBOT_API_KEY).
CI example (GitHub Actions)
jobs:
aribot:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # for the SARIF upload
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Aribot gate
run: npx --yes @ayurak/aribot-cli@3 check --gate build --base origin/${{ github.base_ref || 'main' }} --sarif aribot.sarif
env:
ARIBOT_API_KEY: ${{ secrets.ARIBOT_API_KEY }}
ARIBOT_GATE_CONFIG: "12"
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: aribot.sarifPin the actions to commit SHAs in your own workflows.
Scans and traceability
aribot scan ./src --diagram <diagram-uuid> --wait # upload local source and scan it
aribot verify <scan_id> --trigger --wait # verify every threat in the diagram against the code
aribot traceability <scan_id> # architecture, code and compliance matrix
aribot check --legacy ./src --fail-on high # the scan-based gate of earlier versionsaribot scan <path> and check --legacy <path> upload the source files under the path. Scans, uploads and rule management change data, so they need a signed-in user's access token (ARIBOT_TOKEN). API keys can run checks (check, explain, gate status) and read results.
Signed rule sets and the checker runner
aribot keys init # Ed25519 key at ~/.config/aribot/signing_key (mode 600)
aribot rules list
aribot rules import rules.json
aribot rules dry-run 3 --gate-config 12
aribot rules sign 3
aribot rules bind 3 4
aribot runner public-key --key-file runner.pem
aribot runner register --key-file runner.pem --name ci-main
aribot runner sign-and-send --results results.json --key-file runner.pemThe private key never leaves your machine; only the public key and signatures are sent. Key files are PKCS#8 PEM (as aribot keys init writes them), or a 32-byte Ed25519 seed as 64 hex characters or 32 raw bytes. Key files written by the Python CLI work here, and the other way round.
Security
- HTTPS only; plain http is accepted for
localhost,127.0.0.1and::1alone. - TLS is always verified. There is no option to switch it off.
ARIBOT_CA_BUNDLE: Node.js reads extra CA certificates fromNODE_EXTRA_CA_CERTSwhen it starts, so the CLI starts itself once more withNODE_EXTRA_CA_CERTSset to that file. The CA is added to Node's built-in list (the Python CLI uses the file as its only CA list).- Redirects are not followed, so the key is never sent to another host.
- Only read requests are retried (429, 502, 503, 504), honouring
Retry-Afterup to 30 seconds. Uploads and other writes run once. - The key reaches
securityandsecret-toolon standard input, so it does not show in the process list. On macOS the CLI runssecuritywithout a terminal so that it reads the key from standard input, then reads the entry back and removes it if it does not match. - git,
securityandsecret-toolare run directly, never through a shell. explain --apply-patchapplies only a patch that edits the one file you asked about, runsgit apply --checkfirst, and asks before applying unless you pass--yes.
Report a vulnerability to security@ayurak.com.
Upgrading from 1.x or 2.x
Versions 1.0.7 to 1.4.0 are deprecated. Do not use them; upgrade to 3.x.
Version 3.0.0 is a rebuild on the current Aribot API, matching the Python CLI.
- Sign-in: 2.x stored the key in
~/.aribot/config.jsonwitharibot config set-key <key>. Delete that file, then runaribot login(or setARIBOT_API_KEYin CI).aribot auth statusreplacesaribot config show. - The
--tokenoption is gone; a key on the command line shows in shell history and the process list. aribot scan <path>is now a code scan of source files. The 2.xscanuploaded an architecture diagram.aribot code-review <repo-url>is nowaribot scan <repo-url>.- The 2.x commands
threats,compliance,report,statusandmaestroare not part of 3.0. Use the Aribot web app, or call the API from@ayurak/sdk. - New:
check,explain,gate status,rules,keys,runner,login,logout,auth status,verifyandtraceability.