# Metis: AI-Powered Security Code Review [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/) [![Ruff](https://img.shields.io/badge/lint%20%26%20format-Ruff-D7FF64.svg)](https://docs.astral.sh/ruff/) [![Python](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://python.org) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/arm/metis/badge)](https://securityscorecards.dev/viewer/?uri=github.com/arm/metis) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10876/badge)](https://www.bestpractices.dev/projects/10876) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache2.0-yellow.svg)](LICENSE) ![Logo](.github/logo-light.png#gh-light-mode-only) ![Logo](.github/logo-dark.png#gh-dark-mode-only) Metis is an open-source, agentic AI security framework for deep security code review, created by [Arm's Product Security Team](https://www.arm.com/products/product-security). It helps engineers detect subtle vulnerabilities, improve secure coding practices, and reduce review fatigue. This is especially valuable in large, complex, or legacy codebases where traditional tooling often falls short. **Metis** is named after the Greek goddess of wisdom, deep thought and counsel. ## Features - **Deep Reasoning** Unlike linters or traditional static analysis tools, Metis doesn’t rely on hardcoded rules. It uses LLMs capable of semantic understanding and reasoning. - **Deterministic Local Evidence** Reviews and triage emphasize source-local analysis, language plugins, and deterministic evidence collection over broad retrieval. - **Plugin-Friendly and Extensible** Designed with extensibility in mind: support for additional languages, models, and new prompts is straightforward. - **Issue validation** Validates findings from its own analysis and third-party SAST tools, gathering evidence to reduce false positives. - **Provider Flexibility** Support for major LLM services and local models (OpenAI, Azure OpenAI, Anthropic, Gemini, AWS Bedrock, Bedrock Mantle, vLLM, Ollama, llama.cpp, LiteLLM etc.). See [Set up LLM Provider](#2-set-up-llm-provider). ### Supported Languages Metis includes support for the following languages: | Language | Review | Triage | Notes | | --- | --- | --- | --- | | C | Simple LLM and CodeGraph Reachability | Navigation-assisted LLM with CodeGraph context | Tree-sitter-backed CodeGraph | | C++ | Simple LLM and CodeGraph Reachability | Navigation-assisted LLM with CodeGraph context | Tree-sitter-backed CodeGraph | | Java | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | C# | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Python | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Ruby | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Rust | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Solidity | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | TypeScript | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Terraform | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Go | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | TableGen | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Verilog | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | SystemVerilog | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | JavaScript | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Kotlin | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Perl | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | PHP | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | AArch64 Assembly | Language-plugin simple LLM review | Navigation-assisted LLM | Tree-sitter code splitting | | Jupyter Notebook | Language-plugin simple LLM review | Navigation-assisted LLM | Python Tree-sitter code splitting | | Other languages | Default-plugin simple LLM review with navigation | Navigation-assisted LLM | UTF-8 text; no indexing or CodeGraph | For the current review graph and SARIF triage flow, see [docs/execution-graph.md](docs/execution-graph.md) and [docs/triage-flow.md](docs/triage-flow.md). Optional compilation-database filtering for C/C++ review is documented in [docs/config/compilation_profile.md](docs/config/compilation_profile.md). Metis uses a plugin-based language system, making it easy to extend support to additional languages. It supports ChromaDB, PostgreSQL with pgvector, and Qdrant vector-store backends. ## Getting Started By default, Metis uses **ChromaDB** for local, no-setup usage. PostgreSQL with pgvector and Qdrant are available as optional backends. ### 1. **Installation** After cloning the repository, you can either create a virtual environment or install dependencies system-wide. To use a virtual environment (recommended): ```bash uv venv uv pip install . ``` or install system wide using --system: ```bash uv pip install . --system ``` To install with **PostgreSQL (pgvector)** backend support: ```bash uv pip install '.[postgres]' ``` To install with Qdrant backend support: ```bash uv pip install '.[qdrant]' ``` ### 1.1 **Docker** ```bash git clone https://github.com/arm/metis.git cd metis docker build -t metis . ``` ### 2. **Set up LLM Provider** **OpenAI** (default) Export your OpenAI API key before using Metis: ```bash export OPENAI_API_KEY="your-key-here" ``` **Other providers** Set `llm_provider.name` in a trusted configuration file, select it with `--config PATH`, and install the matching extra: | Provider | `name` | Install | Guide | |--------------------------|------------------|--------------------------------------|---------------------------------------------| | OpenAI | `openai` | included | — | | Azure OpenAI | `azure_openai` | included | [docs](docs/providers/azure_openai.md) | | Anthropic | `anthropic` | `uv pip install '.[anthropic]'` | [docs](docs/providers/anthropic.md) | | Google Gemini / Vertex | `gemini` | `uv pip install '.[gemini]'` | [docs](docs/providers/gemini.md) | | AWS Bedrock | `bedrock` | `uv pip install '.[bedrock]'` | [docs](docs/providers/bedrock.md) | | Bedrock Mantle (Claude) | `bedrock_mantle` | `uv pip install '.[bedrock-mantle]'` | [docs](docs/providers/bedrock_mantle.md) | | vLLM | `vllm` | included | [docs](docs/providers/vllm.md) | | Ollama | `ollama` | included | [docs](docs/providers/ollama.md) | | llama.cpp | `llamacpp` | included | [docs](docs/providers/llamacpp.md) | Or install everything with `uv pip install '.[all-providers]'`. Index operations need a configured embedding provider only when the selected vector backend does not already supply both embedding models. This includes the `index`, `ask`, and `update` commands and a selected `initialize.index` node. To use a different provider for embeddings than for chat (e.g. Anthropic chat + OpenAI embeddings), add a separate `embedding_provider` block — see [docs/providers/embedding-provider.md](docs/providers/embedding-provider.md). ### 3. Run Analysis Run the configured graph against a codebase: ``` uv run metis --codebase-path "/path/to/src" --verbose ``` Literal tokenizer markers such as `<|endoftext|>` in reviewed source are counted as ordinary text. Start the interactive prompt instead: ``` uv run metis --interactive --codebase-path "/path/to/src" ``` Then run commands such as: ``` init review_code ``` ### 3.1 Docker Go to your codebase path and run: ```bash docker run --rm -it -v "$PWD:/metis" metis ``` To pass environment variables use `-e`: ```bash docker run --rm -it -v "$PWD:/metis" -e "OPENAI_API_KEY=${OPENAI_API_KEY}" metis ``` You can pass arguments to metis: ```bash docker run --rm -it -v "$PWD:/metis" metis --codebase-path /metis --verbose --output-file /metis/results/review.json ``` ## Configuration **Metis Configuration (`metis.yaml`)** Without `--config`, Metis uses its packaged `src/metis/metis.yaml` defaults. It does not discover `metis.yaml` or `metis.yml` in the working directory or target repository. Select a custom configuration explicitly: ```bash uv run metis --config /path/to/trusted/metis.yaml --codebase-path /path/to/src ``` Relative config paths resolve from the working directory. A missing or invalid explicit config is an error, not a request to fall back to packaged defaults. Only select configuration you trust: it controls provider endpoints and credential environment-variable selection. Set `llm_provider.reasoning_effort` for reasoning-capable chat models; `query.reasoning_effort` overrides it. Supported levels depend on the provider and model. See [Bedrock](docs/providers/bedrock.md), [Bedrock Mantle](docs/providers/bedrock_mantle.md), and [Anthropic](docs/providers/anthropic.md) for their native request handling. A selected document does not inherit packaged `llm_provider`, `embedding_provider`, or `query` sections; `llm_provider` is required and the others have runtime fallbacks. Shared `metis_engine` settings inherit packaged defaults when omitted. Non-empty `model_tools`, `capabilities`, and `threat_model` mappings merge recursively; lists and scalars replace. Empty mappings replace at that level, although downstream validation may restore semantic defaults. An empty `model_tools` mapping is restored to its required defaults. `execution`, `codegraph`, `reachability`, `triage`, and `hnsw_kwargs` each replace the whole packaged mapping, after which their models may apply field defaults. When `execution` is omitted, Metis uses the packaged graph; when present, it is the complete graph. Configuration covers: - **LLM provider:** chat model and provider connection settings - **Embedding provider:** models and connection settings used by Index - **Engine behavior:** max workers, max token length, and per-node concurrency - **Query behavior:** model overrides, token limit, temperature, and similarity top-k - **Review checkpoints:** project-local resume storage, enabled by default; see [checkpoints and resume](docs/execution-graph.md#review-checkpoints-and-resume). - **Database connection:** PostgreSQL host, port, credentials, and database name - **Index storage:** selected by CLI options such as `--backend`, `--chroma-dir`, `--qdrant-url`, and `--project-schema` - **Capability settings:** index-search and navigation limits - **Reachability:** maximum reported path length and optional domain profiles and hints. An explicit configuration is optional when the packaged defaults are suitable. **Language Configuration** Language manifests, prompt templates, and splitter settings are packaged under `src/metis/plugins/`. External language packages expose a lightweight manifest through the `metis.language_plugins` entry-point group. See the [language plugin guide](docs/language-plugins.md) for the file layout, manifest contract, and extension steps. ## Running Metis Metis also provides an interactive CLI with several built-in commands: ### Global CLI Flags - `--config PATH` – load a trusted configuration file instead of packaged defaults. Repository-local configuration files are not discovered automatically. - `--custom-prompt PATH` – optional `.md` or `.txt` file containing additional security-review guidance. If omitted, Metis uses `.metis.md` from the project root when that file exists. - `--backend chroma|postgres|qdrant` – choose a vector-store backend (default `chroma`). - `--project-schema` namespaces PostgreSQL schemas and Qdrant collections. - `--chroma-dir` and `--qdrant-url` configure backend storage. - `--triage` – in the interactive prompt, triage findings after `review_code`, `review_dir`, `review_file`, or `review_patch` and annotate SARIF output. - `--include-triaged` – include findings already triaged by Metis when running triage. - `--verbose` – show the stages and nodes executed by the selected graph. - `--interactive` – start the command prompt instead of running the configured graph. - `--log-level` – configure Python logging independently of graph progress. - `--quiet`, `--output-file`, `--output-files` – control console and export output. - `--log-workflow-debug` – write a full local workflow trace containing prompts, model responses, tool calls, decisions, usage, and execution lifecycle data. - `--log-workflow-debug-path PATH` – choose the trace directory or a new exact `.ndjson` path; this also enables workflow tracing. See the [execution graph guide](docs/execution-graph.md) for stage, node, and output configuration, the [workflow run-log format](docs/workflow-log-format.md) for local trace capture, and [adding a capability](docs/capabilities/adding-capability.md) for shared runtime services and model-tool adapters. ### `init` Initializes the configured repository context. Configured threat-model files supply authoritative policy; Git-history lessons are optional and advisory. No threat model is generated from source code when those files are absent. See [repository memory](docs/repository-memory.md#configuration) for settings. The packaged graph does not build the vector index; add the `index` node to `initialize`, or run `index`, when retrieval is needed. ### `index` Builds the vector index used by `ask`, `update`, and nodes that use the Index capability. ### `review_code` Runs the configured Review stage over the selected codebase scope. Add `reachability` for CodeGraph-based review of supported C and C++ functions. ### `review_dir` Reviews an existing directory within `--codebase-path`; relative targets resolve from that root. Empty directories are valid. ### `review_file ` Reviews one file, resolving relative targets from `--codebase-path`. Missing or unreadable files fail the review. ### `review_patch ` Patch review requires `simple_llm_review` (enabled by default); Reachability reports patch requests as inconclusive. Invalid patches, unreadable source, and model failures fail the review. ### `update ` Incrementally updates the index using a diff. Avoids full reindexing. ### `ask ` Ask questions against the indexed codebase. ### `triage ` Annotates findings from Metis review JSON or SARIF (`.sarif` or `.json`), including other tools' SARIF. Completed decisions are skipped unless `--include-triaged` is set. `--output-file` selects destinations and formats; without an explicit or configured filename, triage updates its input. See [triage](docs/triage-flow.md). ## Examples #### Example 1: Chroma (default) ```bash uv run metis --interactive --codebase-path "/path/to/src" ``` #### Example 2: Postgres If you prefer not to use the default ChromaDB backend, you can switch to PostgreSQL either using a local installation or the provided Docker setup. To get started quickly, run: ```bash docker compose up -d ``` This will launch a PostgreSQL instance with the pgvector extension enabled, using the credentials specified in your `docker-compose.yml`. Then, run Metis with the PostgreSQL backend: ```bash uv run metis \ --project-schema myproject_main \ --codebase-path "/path/to/src" \ --backend postgres ``` For embedding models above pgvector's normal-vector HNSW limit, such as 3072-dimensional embeddings, Metis automatically enables pgvector `halfvec` storage for the PostgreSQL backend so HNSW indexes can still be created. You can override this in the configuration file selected with `--config PATH`: ```yaml metis_engine: embed_dim: 3072 pgvector_use_halfvec: auto # auto, true, or false ``` #### Example 3: Qdrant Qdrant must be running as a server. See the [Qdrant quickstart](https://qdrant.tech/documentation/quickstart/) for setup details, or start a local server with Docker: ```bash docker run -p 6333:6333 qdrant/qdrant ``` Metis connects to localhost by default: ```bash uv run metis --backend qdrant --project-schema myproject ``` For another Qdrant Server or Qdrant Cloud endpoint, pass `--qdrant-url` or set `QDRANT_URL`. Set `QDRANT_API_KEY` when authentication is required. Metis creates `_code` and `_docs` collections. #### Example 4: Usage and output ```console $ uv run metis --interactive --codebase-path "/path/to/src" > review_file src/memory/remap.c ``` Vulnerable source code: ```c // Remap memory addresses from one region to another for (uint32_t* ptr = start; ptr < end; ptr++) { uint32_t value = *ptr; if (value >= OLD_REGION_BASE && value < OLD_REGION_BASE + REGION_SIZE) { value = value - OLD_REGION_BASE + NEW_REGION_BASE; } } ``` Example output: ```text File: src/memory/remap.c Identified issue 1: Address Remapping Loop Does Not Update Memory Snippet: for (uint32_t* ptr = start; ptr < end; ptr++) { uint32_t value = *ptr; if... Why: In the remap_address_table function, the code is intended to adjust address references from an old memory region to a new one. However, the updated value stored in the local variable 'value' is never written back into memory at the pointer location (*ptr). This means the address entries remain unchanged, which can lead to unintended behavior if the system relies on those values being relocated correctly. Mitigation: Update the loop so that after computing the new address, the value is written back. For example: for (uint32_t* ptr = start; ptr < end; ptr++) { uint32_t value = *ptr; if (value >= OLD_REGION_BASE && value < OLD_REGION_BASE + REGION_SIZE) { value = ((value - OLD_REGION_BASE) + NEW_REGION_BASE); *ptr = value; } } This ensures that each entry is properly updated to point to the relocated memory region. Confidence: 1.0 ``` #### Example 5: Run the configured review and triage graph ```bash uv run metis --codebase-path "/path/to/src" --verbose --output-file results/full_review.json ``` #### Example 6: Review a patch from the interactive prompt ```console $ uv run metis --interactive --codebase-path "/path/to/src" --triage > review_patch changes.diff --output-file results/review.sarif ``` #### Example 7: Triage an existing SARIF file ```console $ uv run metis --interactive --include-triaged > triage results/review.sarif --output-file results/retriaged.sarif ``` ## Contributing See [CONTRIBUTION.md](CONTRIBUTION.md) for setup and checks. For built-in execution work, read [Adding built-in execution nodes and stages](docs/contributing/adding-execution-component.md). Separately distributed components use [Adding external nodes and stages](docs/execution-graph.md#adding-external-nodes-and-stages). See the contributor guides for [languages](docs/language-plugins.md), [capabilities](docs/capabilities/adding-capability.md), and [providers](docs/providers/adding-new-provider.md). ## License Metis is distributed under Apache v2.0 License.