AribotDevelopers Sign in

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-cli

aribot 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

bash
npm i -g @ayurak/aribot-cli
aribot --version

# or without installing
npx @ayurak/aribot-cli check --gate-config 12

Requires 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:

bash
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 key

In CI, set the key as a secret environment variable:

bash
export ARIBOT_API_KEY=...    # takes precedence over the keychain

The 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:

OSKeychainNotes
macOSlogin keychain, through /usr/bin/securityThe first time one CLI reads an entry the other one wrote, macOS may ask you to allow access.
LinuxSecret Service, through secret-tool (package libsecret-tools)Needs a running keyring (GNOME Keyring, KWallet and others).
Windowsnot supportedSet ARIBOT_API_KEY in your environment.
VariablePurpose
ARIBOT_API_KEYAPI key for CI pipelines
ARIBOT_APIAPI host, https only (default https://aribot.ayurak.com)
ARIBOT_TOKENJWT access token, for owner and security-manager actions such as signing rules
ARIBOT_CA_BUNDLEExtra CA certificate file (PEM) for a self-hosted server with a private CA
ARIBOT_GATE_CONFIGGate configuration id for aribot check and aribot explain
ARIBOT_BASEBase ref for aribot check (default origin/main)
ARIBOT_SIGNING_KEYSigning key file for aribot keys and aribot rules

Check a change

bash
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 request

aribot 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:

CodeMeaning
0Allow (or warn, without --strict)
1Block
2Warn, with --strict
3Configuration, 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:

yaml
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):

sh
#!/bin/sh
npx --no-install aribot check --gate ide --staged

Both need ARIBOT_GATE_CONFIG and a key from aribot login (or ARIBOT_API_KEY).

CI example (GitHub Actions)

yaml
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.sarif

Pin the actions to commit SHAs in your own workflows.

Scans and traceability

bash
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 versions

aribot 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

bash
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.pem

The 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

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.